From a51fcb12278165401946a233ff312083a1ef12c0 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Sat, 8 Mar 2014 15:19:34 -0800 Subject: [PATCH 1/2] Add support for non-inheriting CSS files --- bin/dcssd | 23 +++++++++++++++-------- readme.md | 11 +++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bin/dcssd b/bin/dcssd index 3821367..7bd4817 100755 --- a/bin/dcssd +++ b/bin/dcssd @@ -34,16 +34,23 @@ 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') + p files body = "/* dotcss is working */\n" 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. From 5f0a3584646e9134b2e90da45890ce0cc077d4a4 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Sat, 8 Mar 2014 20:28:02 -0800 Subject: [PATCH 2/2] Remove debugging line --- bin/dcssd | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/dcssd b/bin/dcssd index 7bd4817..af53ddc 100755 --- a/bin/dcssd +++ b/bin/dcssd @@ -50,8 +50,6 @@ dotcss = Class.new(WEBrick::HTTPServlet::AbstractServlet) do files.unshift File.expand_path('default.css') end - p files - body = "/* dotcss is working */\n" files.each do |file|