-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRules
172 lines (140 loc) · 3.07 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
#!/usr/bin/env ruby
require 'compass'
# Create new items for each of our tags
preprocess do
tags = Set.new
articles.each do |item|
item[:tags].each { |t| tags.add(t) } if item[:tags]
end
tags.each do |tag|
items << Nanoc::Item.new(
"",
{ :tag => tag },
"/tags/#{slugify(tag)}/")
end
end
Compass.add_project_configuration 'config/compass.rb'
BYPASS_FILES = %w(crossdomain.xml humans.txt robots.txt) unless defined?(BYPASS_FILES)
IMAGE_COMPRESS_ENABLE = false
IMAGE_COMPRESS_OPTIONS = { :pngout => false } unless defined?(IMAGE_COMPRESS_OPTIONS)
# Compilation Rules
BYPASS_FILES.each do |file|
compile("/#{file.sub /\..+/, ''}/") do
# don't filter bypass files
end
end
compile '/assets/sass/app/' do
filter :sass, Compass.sass_engine_options
end
compile '/assets/sass/*' do
# dont' filter or layout
end
compile '/i/*' do
if IMAGE_COMPRESS_ENABLE
filter :image_compressor, IMAGE_COMPRESS_OPTIONS if item.binary?
end
end
compile '/assets/images/*' do
# dont' filter or layout
end
compile '/assets/javascripts/lib/*' do
# dont' filter or layout
end
compile '/assets/javascripts/vendor/*' do
#filter :uglify_js
end
compile '/assets/javascripts/*' do
filter :concat_js
filter :uglify_js
end
compile '/articles/*' do
case item[:extension]
when 'md'
filter :erb
filter :kramdown, :auto_ids => false
when 'markdown'
filter :erb
filter :kramdown, :auto_ids => false
when 'html'
filter :erb
when 'erb'
filter :erb
else
filter :kramdown, :auto_ids => false
end
layout 'article'
filter :cache_buster
end
compile '/tags/*/' do
filter :erb
layout 'tags'
filter :cache_buster
end
compile '/atom/' do
filter :erb
end
compile '/sitemap/' do
filter :erb
end
compile '*' do
if item.binary?
# don’t filter binary items
else
case item[:extension]
when 'md'
filter :erb
filter :kramdown, :auto_ids => false
when 'haml'
filter :haml
when 'erb'
filter :erb
else
filter :erb
end
layout item[:layout] || 'default'
filter :cache_buster
end
end
# Routes
BYPASS_FILES.each do |file|
route("/#{file.sub /\..+/, ''}/") do
"/#{file}" # route bypass files as is
end
end
route '/assets/sass/app/' do
"/assets/css/app#{fingerprint(item[:filename])}.css"
end
route '/assets/sass/*' do
nil
end
route '/assets/images/*' do
item.identifier.chop + "." + item[:extension]
end
route '/assets/javascripts/vendor/*' do
item.identifier.chop + '.js'
end
route '/assets/javascripts/lib/*' do
nil
end
route '/assets/javascripts/*' do
item.identifier.chop + fingerprint(item[:filename]) + '.js'
end
route '/articles/*' do
item.identifier.gsub('/articles', '') + 'index.html'
end
route '/atom/' do
'/atom.xml'
end
route '/sitemap/' do
'/sitemap.xml'
end
route '*' do
if item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.chop + '.' + item[:extension]
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier + 'index.html'
end
end
layout '*', :erb