/
Rules
202 lines (165 loc) · 3.76 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env ruby
# Load settings
require './settings.rb' # There should be a settings.rb in root derived from dev or prod settings
require 'bourbon'
require 'tilt/kramdown'
require 'time'
require './sass_config.rb'
require 'benchmark'
# 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.
preprocess do
@items.delete_if { |post| post[:published] == false }
end
compile '/static/fonts/*/' do
end
# don't filter SASS partials
compile %r{/static/css/.*_.+/$} do
nil
end
# don't route SASS partials
route %r{/static/css/.*_.+/$} do
nil
end
compile '/static/css/*' do
if @item[:extension] =~ /sass$/
filter :sass, $sass_configuration
end
if $use_minified_css then
# compress css with rainpress
filter :rainpress
end
end
route '/static/fonts/*' do
item.identifier.gsub(/_/, '.').chomp('/')
end
route '/static/css/*/' do
hashed_route(@item)
end
compile '/static/js/*/' do
if item[:combined]
filter :haml
#filter :yui_compress unless $development_mode
end
end
route '/static/js/*/' do
if item[:combined]
#if combined haml, route to js file
hashed_route(@item)
else
path = @item.identifier.chop
path + '.' + @item[:extension]
end
end
compile '/static/img/*/' do
#don't compile static resources
end
route '/static/img/*/' do
item.identifier.chop + '.' + item[:extension]
end
compile '/static/files/*/' do
# Do nothing
end
route '/static/files/*/' do
# Make sure that "/files/thing/" becomes "/files/thing.mp4"
item.identifier.chop + '.' + item[:extension]
end
# Humans.txt
compile '/humans/' do
end
route '/humans/' do
'/humans.txt'
end
# Robots.txt
compile '/robots/' do
end
route '/robots/' do
'/robots.txt'
end
# Sitemap
compile '/sitemap/' do
filter :haml
end
route '/sitemap/' do
'/sitemap.xml'
end
# Atom Feed
compile '/writing/feed/' do
filter :haml
end
route '/writing/feed/' do
'/writing/feed.xml'
end
route '/writing/*/' do
"/writing/#{item[:slug]}/index.html"
end
compile '/writing/*/' do
if @item[:markup] == "markdown"
filter :kramdown
filter :colorize_syntax, {
# To use the default_colorizer option you need the nanoc3.2 version Colorize_Syntax filter.
:default_colorizer => :pygmentize,
}
end
filter :rubypants
layout 'post'
layout 'base'
end
compile '/books/*/' do
if @item[:markup] == "markdown"
filter :kramdown
filter :colorize_syntax, {
# To use the default_colorizer option you need the nanoc3.2 version Colorize_Syntax filter.
:default_colorizer => :pygmentize,
}
elsif @item[:markup] == "haml"
filter :haml
end
layout 'book'
layout 'base'
end
compile '/writing/' do
layout 'writing_root'
layout 'header'
layout 'base'
end
compile '/portfolio/' do
filter :haml
layout 'header'
layout 'base'
end
compile '/' do
layout 'homepage'
layout 'base'
end
compile '/404/' do
filter :haml
layout 'header'
layout 'base'
end
compile '*' do
if @item[:markup] == "markdown"
filter :kramdown
filter :colorize_syntax, {
# To use the default_colorizer option you need the nanoc3.2 version Colorize_Syntax filter.
:default_colorizer => :pygmentize,
}
elsif @item[:markup] == "haml"
filter :haml
end
layout 'generic'
layout 'header'
layout 'base'
end
route '*' do
item.identifier + 'index.html'
end
# Set :ugly=true for correct indentation for <pre>.
layout '*', :haml, :format => :html5, :ugly => true