Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (75 sloc) 2.07 KB
# A few helpful tips about the Rules file:
#
# * The order of rules is important: for each item, only the first matching
# rule is applied.
#
# * Item identifiers start and end with a slash (e.g. “/about/” for the file
# “content/about.html”). To select all children, grandchildren, … of an
# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
# because “*” matches zero or more characters.
require 'compass'
Compass.add_project_configuration('compass_config.rb')
require 'active_support/core_ext/string'
### Precproccessing rules
preprocess do
# authors may unpublish items by setting meta attribute publish: false
items.delete_if { |item| item[:publish] == false }
# set sensible defaults for attributes
items.each do |item|
item[:is_hidden] = true if item.binary?
if item.identifier =~ %r(^/articles/) && !item.binary?
item[:kind] ||= 'article'
item[:updated_at] ||= item.mtime
end
end
create_category_pages
copy_static
end
### Compilation rules
compile '/stylesheets/_*/' do
nil
end
compile '/stylesheets/*/' do
filter :sass, Compass.sass_engine_options
end
compile '/code/*/' do
nil
end
compile '*' do
apply_filters_and_layout
end
### Routing rules
route '/stylesheets/_*/' do
nil # skip stylesheet partials
end
route '/stylesheets/*/' do
item.identifier.chop + '.css'
end
route '/sitemap/' do
item.identifier.chop + '.xml'
end
route '/feed/atom/' do
item.identifier.chop + '.xml'
end
route '/code/*/' do
item.identifier.chop + '.' + item[:extension]
end
route '/404/' do
item.identifier.chop + '.html'
end
route '/articles/*/' do
if item.binary?
item.identifier.sub(/^\/articles/,'').chop + '.' + item[:extension]
else
item.identifier.sub(/^\/articles/,'') + 'index.html'
end
end
route '*' do
if item.binary?
item.identifier.chop + '.' + item[:extension]
else
item.identifier + 'index.html'
end
end
### Layout rules
layout '*', :haml, :attr_wrapper => '"', :ugly => true, :format => :html5 # :ugly is essential to have code blocks not further indented