diff --git a/bin/dcssd b/bin/dcssd index 3821367..af53ddc 100755 --- a/bin/dcssd +++ b/bin/dcssd @@ -34,17 +34,22 @@ dotcss = Class.new(WEBrick::HTTPServlet::AbstractServlet) do files = [] paths = path.gsub('/', '').split('.') - until paths.empty? - file = File.expand_path(paths.join('.')) - files << file if File.file?(file) - paths.shift + # if subdomain .css file is marked as non-inheriting + if File.file?(file = File.expand_path("_" + paths.join('.'))) + files << file + else + until paths.empty? + file = File.expand_path(paths.join('.')) + files << file if File.file?(file) + paths.shift + end + + files.sort_by! { |f| f.length } + + # Default CSS to the front of the line! + files.unshift File.expand_path('default.css') end - files.sort_by! { |f| f.length } - - # Default CSS to the front of the line! - files.unshift File.expand_path('default.css') - body = "/* dotcss is working */\n" files.each do |file| diff --git a/readme.md b/readme.md index 3fe1ecc..19f9822 100644 --- a/readme.md +++ b/readme.md @@ -64,6 +64,17 @@ Attempting to run `rake install` within a tmux session may fail with the followi To avoid this, quit tmux before installing dotcss. +## Non-Inheriting Stylesheets + +If you'd like to avoid inheriting from parent CSS files, give your CSS file +a name of `_{domain}.css`. + +For example, on https://gist.github.com, by default, `gist.github.com.css` will +be loaded along with `github.com.css` and `default.css`. + +But if `_gist.github.com.css` exists in the `~/.css` directory, it will be +loaded by itself. + ## Thanks - [Chris Wanstrath][defunkt] for [dotjs][], which 90% of this is based on.