/
config.rb
239 lines (195 loc) · 10.2 KB
/
config.rb
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
require 'abbrev'
activate :directory_indexes
# Methods defined in the helpers block are available in templates
helpers do
def table_of_contents
return sitemapGen()
end
def sitemapGen()
html = '<ul>'
html << "<li class='header'>Pages</li>"
html << getListElementForResource(sitemap.find_resource_by_destination_path("/index.html"))
html << getSitemapForResource(sitemap.find_resource_by_destination_path("/index.html"))
return html << '</ul>'
end
def getSitemapForResource(resource)
html = ''
if resource.data["no-toc"]
return ''
end
if resource.children.length > 0
if resource.url != "/"
html << '<ul>'
end
children = resource.children
children.sort_by! { |child| -child.children.length } # Make resources who have children appear first
begin
children.sort_by! { |child| child.data.sort_order || children.length }
rescue
children.sort_by! { |child| child.data.title || "" }
end
children.each do |child|
if !child.data.title || resource.data["no-toc"]
next
end
childHtml = getSitemapForResource(child)
html << '<li>'
if child.path.include?("index") && child.children.length > 0 # Is parent
checkedStr = ''
if shouldBeChecked(child)
checkedStr = 'checked'
end
html << "<input #{checkedStr} type='checkbox' id='checkbox_#{child.path}' />"
html << "<label for='checkbox_#{child.path}'>#{getResourceLink(child)}</label>"
else
html << link_to(child.data.title, child.url)
end
html << childHtml
html << '</li>'
end
if resource.url != "/"
html << '</ul>'
end
end
return html == "<ul></ul>" ? "" : html # Checks if all children were skipped
end
def shouldBeChecked(resource)
dirs = [resource.path, current_page.path]
common_prefix = dirs.abbrev.keys.min_by {|key| key.length}.chop # => "/home/user1/tmp/cove"
common_directory = common_prefix.sub(%r{/[^/]*$}, '') # => "/home/user1/tmp"
return common_directory.length > 0
end
def getListElementForResource(resource)
return '<li>' << getResourceLink(resource) << '</li>'
end
def getResourceLink(resource)
if resource.data["nolink"]
return !resource.data['title'] ? resource.path : resource.data['title']
else
return link_to(!resource.data['title'] ? resource.path : resource.data['title'], resource.url);
end
end
def generate_recipes(crafting_recipes)
html = ''
for recipe in crafting_recipes["recipes"] do
html << crafting_recipe(recipe)
end
return html
end
def crafting_recipe(crafting_recipe)
html = '<table class="crafting_table"><tr class="crafting_name"><td colspan="4">' + (crafting_recipe["name"] || "Crafting Recipe") + '</td></tr><tr><td><table class="crafting_grid">'
for rowCounter in 0..2 do # 3 rows
row = crafting_recipe["rows"][rowCounter]
if row != nil
html << '<tr>'
for counter in 0..2 do # 3 items pwer row
begin
if row[counter] != nil
html << '<td class="item_slot">' + link_to(row[counter]["displayName"], row[counter]["wikiLink"]) + '</td>'
end
rescue Exception => e
html << '<td class="item_slot"></td>'
end
end
html << "</tr>"
end
end
html << "</table></td>"
html << "<td><table><tr><td class='crafting_arrow'></td></tr></table></td>"
html << "<td><table><tr><td class='item_slot round_corners'>" << link_to(crafting_recipe["output"]["displayName"]) << "</td></tr></table></td>"
html << "</tr></table>"
return html
end
def favicon_gen
favicon = <<-FAVICON
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="apple-touch-icon-152x152-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png" />
<link rel="shortcut icon" href="favicon.png" />
<link rel="icon" type="image/ico" href="favicon.ico" />
FAVICON
return unindent(favicon)
end
def unindent(string)
indent = string.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0
return string.gsub(/^[[:blank:]]{#{indent}}/, '')
end
def link(link_content, link_id)
# return "<a href='#{links[link_id]}'>#{link_content}</a>"
return link_to(link_content, links[link_id])
end
def octicon(code)
classes = "octicon octicon-#{code.to_s.dasherize}"# + options[:class]
content_tag :span, '', :class => classes
end
end
set :markdown_engine, :kramdown
set :markdown, :input => 'GFM'
activate :relative_assets
set :relative_links, true
set :css_dir, 'stylesheets'
set :js_dir, 'javascript'
set :images_dir, 'images'
config[:links] = {
'disguise' => "/block_extenders/block_extenders.html#disguising",
'filter' => "/filtering.html",
'regular-block-extender' => "/block_extenders/block_extender_regular.html",
'filtered-block-extender' => "/block_extenders/block_extender_filtered.html",
'advanced-block-extender' => "/block_extenders/block_extender_advanced.html",
'advanced-filtered-block-extender' => "/block_extenders/block_extender_advanced_filtered.html",
'wireless-block-extender' => "/block_extenders/block_extender_wireless.html",
'regular-buffer' => "/buffers/buffer_regular.html",
'filtered-buffer' => "/buffers/buffer_filtered.html",
'advanced-buffer' => "/buffers/buffer_advanced.html",
'relocator' => "/relocators/index.html"
}
activate :deploy do |deploy|
deploy.method = :git
deploy.branch = "master"
deploy.commit_message = "Deploy source to pages with " << `git rev-parse HEAD` # git rev-parse HEAD returns the last commit hash.
end
ignore 'stylesheets/octicons'
# Build-specific configuration
configure :build do
# For example, change the Compass output style for deployment
activate :minify_css
# Minify Javascript on build
activate :minify_javascript
activate :favicon_maker, :icons => {
"favicon_template.png" => [
{ icon: "apple-touch-icon-152x152-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for retina iPad with iOS7.
{ icon: "apple-touch-icon-144x144-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for retina iPad with iOS6 or prior.
{ icon: "apple-touch-icon-120x120-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for retina iPhone with iOS7.
{ icon: "apple-touch-icon-114x114-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for retina iPhone with iOS6 or prior.
{ icon: "apple-touch-icon-76x76-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for non-retina iPad with iOS7.
{ icon: "apple-touch-icon-72x72-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for non-retina iPad with iOS6 or prior.
{ icon: "apple-touch-icon-60x60-precomposed.png" }, # Same as apple-touch-icon-57x57.png, for non-retina iPhone with iOS7.
{ icon: "apple-touch-icon-57x57-precomposed.png" }, # iPhone and iPad users can turn web pages into icons on their home screen. Such link appears as a regular iOS native application. When this happens, the device looks for a specific picture. The 57x57 resolution is convenient for non-retina iPhone with iOS6 or prior. Learn more in Apple docs.
{ icon: "apple-touch-icon-precomposed.png", size: "57x57" }, # Same as apple-touch-icon.png, expect that is already have rounded corners (but neither drop shadow nor gloss effect).
{ icon: "apple-touch-icon.png", size: "57x57" }, # Same as apple-touch-icon-57x57.png, for "default" requests, as some devices may look for this specific file. This picture may save some 404 errors in your HTTP logs. See Apple docs
{ icon: "favicon-196x196.png" }, # For Android Chrome M31+.
{ icon: "favicon-160x160.png" }, # For Opera Speed Dial (up to Opera 12; this icon is deprecated starting from Opera 15), although the optimal icon is not square but rather 256x160. If Opera is a major platform for you, you should create this icon yourself.
{ icon: "favicon-96x96.png" }, # For Google TV.
{ icon: "favicon-32x32.png" }, # For Safari on Mac OS.
{ icon: "favicon-16x16.png" }, # The classic favicon, displayed in the tabs.
{ icon: "favicon.png", size: "16x16" }, # The classic favicon, displayed in the tabs.
{ icon: "favicon.ico", size: "64x64,32x32,24x24,16x16" }, # Used by IE, and also by some other browsers if we are not careful.
{ icon: "mstile-70x70.png", size: "70x70" }, # For Windows 8 / IE11.
{ icon: "mstile-144x144.png", size: "144x144" },
{ icon: "mstile-150x150.png", size: "150x150" },
{ icon: "mstile-310x310.png", size: "310x310" },
{ icon: "mstile-310x150.png", size: "310x150" }
]
}
# activate :imageoptim do |options|
# options.pngcrush_options = { :chunks => [''], :fix => false }
# end
# Enable cache buster
# activate :asset_hash
# Use relative URLs
# activate :relative_assets
# Or use a different image path
# set :http_prefix, "/Content/images/"
end