This repository has been archived by the owner on Jan 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRules
executable file
·125 lines (103 loc) · 3.24 KB
/
Rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
=begin
Copyright Daniel Meißner <dm@3st.be>, 2012
This file is part of FreifunkKBUInfoPage.
FreifunkKBUInfoPage is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FreifunkKBUInfoPage is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreifunkKBUInfoPage. If not, see <http://www.gnu.org/licenses/>.
=end
# 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 '/sass/_*/' do
# Don't waste time compiling partials that will never be output
nil
end
compile '/img/*/' do
# Don't waste time compiling partials that will never be output
nil
end
compile '/txt/*/' do
# Don't waste time compiling partials that will never be output
nil
end
compile '/sass/*/' do
#filter :sass, Compass.sass_engine_options
filter :sass, { :syntax => :scss }
filter :relativize_paths, :type => :css
end
compile 'sitemap' do
filter :erb
end
compile '*' do
unless item.binary?
case item[:extension]
when 'css'
filter :relativize_paths, :type => :css
when 'md'
filter :kramdown
layout 'default'
filter :relativize_paths, :type => :html
when 'haml'
filter :haml, { :ugly => true }
layout 'default'
filter :relativize_paths, :type => :html
when 'js'
nil
else
nil
end
end
end
route '/start_page/' do
item[:locale] = :de
'/index.html'
# (routing code here)
end
route '/sass/_*/' do
# Don't output partials
nil
end
route '/sass/*/' do
# /sass/foo/ -> /css/foo.css
item.identifier.chop.sub('sass', 'css') + '.css'
end
route '/img/*/' do
item.identifier.chop + '.' + item[:extension]
end
route '/txt/*/' do
item.identifier.chop + '.' + item[:extension]
end
route 'sitemap' do
item.identifier.chop + '.xml'
end
route '*' do
# Maybe negate the logic here? Only do the chopping to formats we know converted to HTML?
if item.binary? or item[:extension] == 'css' or item[:extension] == 'js' or item[:extension] == 'xml'
# /foo/ -> /foo.ext
item.identifier.chop + '.' + item[:extension]
else
# /foo/ -> /foo/home.haml.html
item.identifier + 'index.html'
end
end
# I don't believe there's a way to choose the appropriate layout
# filter based on file extension because layouts are matched based on
# identifier and the identifier does not include the extension. Could
# do it based on folders but that is a little lame.
layout 'default', :haml, {:attr_wrapper => '"', :ugly => true }
layout '*', :haml, {:ugly => true}