Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Created June 22, 2010 15:04
Show Gist options
  • Save ryanflorence/448583 to your computer and use it in GitHub Desktop.
Save ryanflorence/448583 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# 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.
compile '*' do
# define multiple filters per file
item[:filter].each{ |f| filter f } if item[:filter]
# choose your own layout per file
layout item[:layout] || 'default' unless item[:layout] == 'none'
end
# these will be changed to id/index.html
html_extensions = %w[ md haml txt html ]
# these will be changed to id/index.{ext}
other_pretty_extensions = %w[ php ]
# everything else gets id.{ext}
route '*' do
if html_extensions.include?(item[:extension])
item.identifier + 'index.html'
elsif other_pretty_extensions.include?(item[:extension])
item.identifier + "index.#{item[:extension]}"
else
item.identifier.chop + ".#{item[:extension]}"
end
end
layout '*', :erb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment