-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rules
135 lines (119 loc) · 3.28 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
#!/usr/bin/env ruby
# A few helpful tips about the Rules file:
#
# * The string given to #compile and #route are matching patterns for
# identifiers--not for paths. Therefore, you can’t match on extension.
#
# * 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
generate_ical_items @config
generate_ical_items_latest @config
generate_tag_pages
end
#
# This route matches all entries below /talks which have the following schema:
#
# <4 digit year>-<2 digit month>-<2 digit month>-<no-whitespace-char-title>.md
#
# Note that only .md files (markdown) will be parsed. We do explicitely not
# allow executeable code (erb) in the posts.
#
compile %r</talks/\d{4}-\d{2}-\d{2}\-\S*/*> do
raise "Item shouldn't be binary" if item.binary?
raise "Item is not Markdown: #{item[:filename]}" if item[:extension] != 'md'
filter :kramdown
layout '/talk.*'
layout '/default.*'
end
#
# The blog is structured into
#
# <4 digit year>/<title>/article.md
#
# The purpose of the additional hierarchy <title> is because we can also place
# additional content in this directory, right next to the article file.
#
# The year folder level is for keeping the directory clean. There won't be more
# than 3-4 blog posts per year, I guess (or better: hope), so we don't need
# a monthly level.
#
compile %r</blog/\d{4}/\S*/article/*> do
raise "Item shouldn't be binary" if item.binary?
raise "Item is not Markdown" if item[:extension] != 'md'
filter :kramdown
layout '/blogarticle.*'
layout '/default.*'
end
#
# This compile rule is for the member profiles. Each member is allowed to add
# her or his own profile.
#
# <name of the member>.md
#
compile %r</profiles/\S*/*> do
raise "Item is not Markdown" if item[:extension] != 'md'
raise "Item shouldn't be binary" if item.binary?
filter :kramdown
layout '/member.*'
layout '/default.*'
end
compile '/ical*/*' do
# Nothing
end
compile '/tags/' do
filter :erb
layout '/default.*'
end
compile '/tags/**/*' do
filter :erb
layout '/tagpage.*'
layout '/default.*'
end
compile '/sitemap.html' do
filter :erb
end
compile '/atom.html' do
filter :erb
end
compile '/static/*' do
# Nothing
end
compile '/*' do
if item[:extension] == 'css'
# don’t filter stylesheets or icalendar files
elsif item[:extension] == 'md'
filter :kramdown
layout '/default.*'
elsif item.binary?
# don’t filter binary items
else
filter :erb
layout '/default.*'
end
end
route '/ical*/*' do
item.identifier.chop
end
route '/index.html' do
item.identifier.to_s
end
route '/**/*' do
if item[:extension] == 'css'
# Write item with identifier /foo/ to /foo.css
item.identifier.to_s
elsif item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.chop + (item[:extension] ? '.' + item[:extension] : '')
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier.without_ext + "/index.html"
end
end
layout '/ical/', nil
layout '/*', :erb