forked from ManageIQ/manageiq.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
383 lines (302 loc) · 9.82 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
###
# Site settings
###
# Look in data/site.yml for general site configuration
Time.zone = data.site.timezone || "UTC"
# Automatic image dimensions on image_tag helper
activate :automatic_image_sizes
# Syntax highlighting
activate :syntax
# Make URLs relative
set :relative_links, true
# Set HAML to render HTML5 by default (when unspecified)
# It's important HAML outputs "ugly" HTML to not mess with code blocks
set :haml, :format => :html5, :ugly => true
# Set Markdown features for Kramdown
# (So our version of Markdown resembles GitHub's w/ other nice stuff)
set :markdown,
transliterated_header_ids: true,
parse_block_html: true,
parse_span_html: true,
tables: true,
hard_wrap: false,
input: 'GFM' # add in some GitHub-flavor (``` for fenced code blocks)
set :markdown_engine, :kramdown
set :asciidoc_attributes, %w(source-highlighter=coderay imagesdir=images)
set :asciidoctor,
:toc => true,
:numbered => true
# Set directories
set :css_dir, 'stylesheets'
set :fonts_dir, 'stylesheets/fonts'
set :js_dir, 'javascripts'
set :images_dir, 'images'
set :partials_dir, 'layouts'
###
# Blog settings
###
activate :blog do |blog|
blog.prefix = "blog/"
blog.layout = "post"
blog.tag_template = "tag.html"
blog.calendar_template = "calendar.html"
blog.default_extension = ".md"
blog.sources = ":year-:month-:day-:title.html"
#blog.permalink = ":year/:month/:day/:title.html"
blog.permalink = ":year/:month/:title.html"
blog.year_link = ":year.html"
blog.month_link = ":year/:month.html"
#blog.day_link = ":year/:month/:day.html"
blog.taglink = "tag/:tag.html"
#blog.summary_separator = /(READMORE)/
#blog.summary_length = 99999
blog.paginate = true
blog.per_page = 10
blog.page_link = "page=:num"
end
#activate :authors
#activate :drafts
# Enable blog layout for all blog pages
with_layout :post do
page "/blog.html"
page "/blog/*"
end
# Make pretty URLs
activate :directory_indexes
###
# Compass
###
# Change Compass configuration
# compass_config do |config|
# config.output_style = :compact
# end
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
# page "/path/to/file.html", :layout => false
#
# With alternative layout
# page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end
# Don't have a layout for XML
page "*.xml", :layout => false
# Docs all have the docs layout
with_layout :docs do
#page "/documentation/*"
#page "/documentation*"
end
# Don't make these URLs have pretty URLs
page "/404.html", :directory_index => false
page "/.htacces.html", :directory_index => false
# Dev docs: Treat README.md as an index
proxy "/documentation/development/index.html", "/documentation/development/README.html"
# Proxy pages (http://middlemanapp.com/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html", :locals => {
# :which_fake_page => "Rendering a fake page with a local variable" }
proxy "/.htaccess", "/.htaccess.html", :locals => {}, :ignore => true
data.deploy_types.each do |deploy_type, deploy_name|
proxy "/download/#{deploy_type}.html", "/download/index.html", locals: {deploy_type: deploy_type, deploy_name: deploy_name, build_type: "stable"}
proxy "/download/devel/#{deploy_type}.html", "/download/index.html", locals: {deploy_type: deploy_type, deploy_name: deploy_name, build_type: "devel"}
proxy "/download/rc/#{deploy_type}.html", "/download/index.html", locals: {deploy_type: deploy_type, deploy_name: deploy_name, build_type: "rc"}
end
proxy "/download/devel.html", "/download/index.html", locals: {build_type: "devel"}
proxy "/download/rc.html", "/download/index.html", locals: {build_type: "rc"}
ready do
# Add author pages
sitemap.resources.group_by {|p| p.data["author"]}.each do |author, pages|
proxy "/blog/author/#{author.parameterize.downcase}.html", "author.html", locals: {author: author, pages: pages}, :ignore => true if author
end
proxy "/blog/author.html", "author.html", :ignore => true
# Add blog feeds
blog.tags.each do |tag_name, tag_data|
proxy "/blog/tag/#{tag_name.downcase}.xml", "feed.xml", locals: {tag_name: tag_name}, :ignore => true if tag_name
end
proxy "/blog/feed.xml", "feed.xml", :ignore => true
proxy "/blog/tag/index.html", "tag.html", :ignore => true
# Remap extensions to the extension viewer
sitemap.resources.group_by {|p| p.url.match(/^\/depot\/extension\/.*\/$/)}.each do |url, pages|
next if url.to_s.match(/README/) or url.nil?
name = url.to_s.split('/')[3]
proxy "/depot/extension/#{name}/index.html", "depot/view.html", locals: {extension_name: name}, ignore: true
end
end
###
# Helpers
###
# Methods defined in the helpers block are available in templates
# helpers do
# def some_helper
# "Helping"
# end
# end
#helpers do
#end
require 'lib/site_helpers.rb'
activate :site_helpers
require 'lib/blog_helpers.rb'
activate :blog_helpers
activate :piwik do |f|
f.id = 1
f.domain = 'analytics.manageiq.org'
end
activate :google_analytics do |ga|
ga.tracking_id = 'UA-58883457-1'
end
###
# Monkey patches
###
helpers do
alias_method :_link_to, :link_to
alias_method :_image_tag, :image_tag
# Monkeypatch Middleman's link_to to remove .md from local files
# (Used for imported Markdown documentation in the dev git module)
def link_to(*args, &block)
dev_root = /^documentation\/development/
url_index = block_given? ? 0 : 1
url = args[url_index]
current_path = if current_page.path.match(/\.json$/)
# Evil global variable, defined in:
# - lib/site_helpers.rb and
# - source/search-results.json.haml
$current_path
else
current_page.path
end
if current_path.match(dev_root)
current_path = '/' + current_path.gsub(/[^\/]*$/, '')
if url.respond_to?('gsub') && url.respond_to?('match') && !url.match(/^http|^#/)
args[url_index] = current_path + url.gsub(/\.md$/, "")
end
end
_link_to(*args, &block)
end
# Support local images first and fall-back on site-wide images
def image_tag(path, params={})
current_path = "#{File.split(current_page.path).first}"
full_file = File.join(root, source, current_path, path.split('?').first)
if path !~ /^(http|\/)/ and File.exists? full_file
path = "/#{current_path}/#{path}"
end
_image_tag(path, params)
end
end
require 'lib/monkeypatch_blog_date.rb'
###
# Development-only configuration
###
#
configure :development do
puts "\nUpdating git submodules..."
puts `git submodule init && git submodule sync`
puts `git submodule foreach "git pull -qf origin master"`
puts "\n"
puts "== Administration is at http://0.0.0.0:4567/admin/"
activate :livereload
#config.sass_options = {:debug_info => true}
#config.sass_options = {:line_comments => true}
compass_config do |config|
config.output_style = :expanded
config.sass_options = {:debug_info => true, :line_comments => true}
end
end
# Build-specific configuration
configure :build do
puts "\nUpdating git submodules..."
puts `git submodule init`
puts `git submodule foreach "git pull -qf origin master"`
puts "\n"
## Ignore administration UI
ignore "/admin/*"
ignore "/javascripts/admin*"
ignore "/stylesheets/lib/admin*"
## Ignore Gimp source files
ignore 'images/*.xcf*'
# Don't export source JS
ignore 'javascripts/vendor/*'
ignore 'javascripts/lib/*'
# Don't export source CSS
ignore 'stylesheets/vendor/*'
ignore 'stylesheets/lib/*'
ignore 'events-yaml*'
# Minify JavaScript and CSS on build
activate :minify_javascript
activate :minify_css
#activate :gzip
# Force a browser reload for new content by using
# asset_hash or cache buster (but not both)
activate :cache_buster
# activate :asset_hash
# Use relative URLs for all assets
#activate :relative_assets
# Compress PNGs after build
# First: gem install middleman-smusher
# require "middleman-smusher"
# activate :smusher
# Or use a different image path
# set :http_path, "/Content/images/"
# Favicon PNG should be 144×144 and in source/images/favicon_base.png
# Note: You need ImageMagick installed for favicon_maker to work
activate :favicon_maker do |f|
f.template_dir = File.join(root, 'source','images')
f.output_dir = File.join(root, 'build','images')
f.icons = {
"favicon_base.png" => [
{ icon: "favicon.png", size: "16x16" },
{ icon: "favicon.ico", size: "64x64,32x32,24x24,16x16" },
]
}
end
end
###
# Deployment
##
if data.site.openshift
os_token, os_host = data.site.openshift.match(/([0-9a-f]+)@([^\/]+)/).captures
deploy_config = {
method: :rsync,
user: os_token,
host: os_host,
path: "/var/lib/openshift/#{os_token}/app-root/repo",
clean: true, # remove orphaned files on remote host
build_before: true # default false
}
elsif data.site.rsync
rsync = URI.parse(data.site.rsync)
deploy_config = {
method: :rsync,
user: rsync.user || ENV[:USER],
host: rsync.host,
path: rsync.path,
port: rsync.port || 22,
clean: true, # remove orphaned files on remote host
build_before: true # default false
}
else
# For OpenShift,
#
# 1) use the barebones httpd cartridge from:
# http://cartreflect-claytondev.rhcloud.com/reflect?github=stefanozanella/openshift-cartridge-httpd
# (Add as URL at the bottom of the create from cartridge page)
#
# 2) Copy your new site's git repo URL and use it for 'production':
# git remote add production OPENSHIFT_GIT_REMOTE_HERE
#
# 3) Now, you can easily deploy to your new OpenShift site!
# bundle exec middleman deploy
deploy_config = {
method: :git,
remote: "production",
branch: "master",
build_before: true # default false
}
end
activate :deploy do |deploy|
deploy_config.each {|key, val| deploy[key] = val }
end