-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRules
86 lines (71 loc) · 1.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
#!/usr/bin/env ruby
#
# ---- PREPROCESS RULES --------------------------------------------------------
#
preprocess do
# setting a URL
items.select{ |item| item[:title] != nil }.each{ |item|
item[:title_full] = 'Ploggy - ' + item[:title]
splitId = item.identifier.chop.split('/')
joinId = splitId[2..-1].join('/')
item[:url] = (joinId.length > 0 ? '/' : '') + joinId + '/'
}
# Ploggy-specific handling
logs_found = 0
items.select{ |item| item.identifier.chop.split('/')[1] == 'logs' }
.each{ |item|
PloggyHelper.log_items.push(item)
logs_found += 1
}
Nanoc::CLI::Logger.instance.log(:low,
sprintf('Found %d log entries.', logs_found))
end
#
# ---- COMPILE RULES -----------------------------------------------------------
#
compile '/assets/*/' do
nil
end
compile '/items/*' do
filter :erb
layout 'default'
filter :tidy
filter :relativize_paths, :type => :html
end
compile '/less/*/' do
if item.identifier.chop.split('/').last == 'ploggy'
filter :less
if item[:yuiCompress]
filter :yui_compressor, :type => :css
end
filter :relativize_paths, :type => :css
else
nil
end
end
compile '/logs/*/' do
filter :kramdown
end
#
# ---- ROUTING RULES -----------------------------------------------------------
#
route '/assets/*/' do
item.identifier[7..-2]
end
route '/items/*' do
item[:url] + 'index.html'
end
route '/less/*/' do
if item.identifier.chop.split('/').last == 'ploggy'
item.identifier.chop.gsub('less', 'css') + '.css'
else
nil
end
end
route '/logs/*/' do
nil
end
#
# ---- LAYOUT RULES ------------------------------------------------------------
#
layout '*', :erb