]> CyberLeo.Net >> Repos - CDN/www.cyberleo.net.git/blob - Rules
Set ruby version to 2.3.0
[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     filter :svg2png if item[:extension] == 'svg'
24   else
25     filter :erb
26     layout 'default'
27   end
28 end
29
30 route '/stylesheet/' do
31   '/style.css'
32 end
33
34 route '*' do
35   if item.binary?
36     # Write item with identifier /foo/ to /foo.ext
37     if item[:extension] == 'svg'
38       # SVGs are transcoded by :svg2png filter
39       item.identifier.chop + '.png'
40     else
41       item.identifier.chop + '.' + item[:extension]
42     end
43   else
44     # Write item with identifier /foo/ to /foo/index.html
45     item.identifier + 'index.html'
46   end
47 end
48
49 layout '*', :erb