]> CyberLeo.Net >> Repos - CDN/www.cyberleo.net.git/blob - Rules
Initial commit: functionally identical to production site
[CDN/www.cyberleo.net.git] / Rules
1 #!/usr/bin/env ruby
2
3 # A few helpful tips about the Rules file:
4 #
5 # * The string given to #compile and #route are matching patterns for
6 #   identifiers--not for paths. Therefore, you can’t match on extension.
7 #
8 # * The order of rules is important: for each item, only the first matching
9 #   rule is applied.
10 #
11 # * Item identifiers start and end with a slash (e.g. “/about/” for the file
12 #   “content/about.html”). To select all children, grandchildren, … of an
13 #   item, use the pattern “/about/*/”; “/about/*” will also select the parent,
14 #   because “*” matches zero or more characters.
15
16 compile '/stylesheet/' do
17   # don’t filter or layout
18 end
19
20 compile '*' do
21   if item.binary?
22     # don’t filter binary items
23   else
24     filter :erb
25     layout 'default'
26   end
27 end
28
29 route '/stylesheet/' do
30   '/style.css'
31 end
32
33 route '*' do
34   if item.binary?
35     # Write item with identifier /foo/ to /foo.ext
36     item.identifier.chop + '.' + item[:extension]
37   else
38     # Write item with identifier /foo/ to /foo/index.html
39     item.identifier + 'index.html'
40   end
41 end
42
43 layout '*', :erb