Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions bin/dcssd
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down