-
Notifications
You must be signed in to change notification settings - Fork 121
/
config.rb
327 lines (263 loc) · 7.53 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
# -*- coding: utf-8 -*-
###
# Site settings
###
# Look in data/site.yml for general site configuration
Time.zone = data.site.timezone || 'UTC'
# Admin needs i18n turned on for time_ago_in_words
activate :i18n, langs: [:en]
# 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 RedCarpet
# (So our version of Markdown resembles GitHub's)
set :markdown,
autolink: true,
fenced_code_blocks: true,
footnotes: true,
gh_blockcode: true,
highlight: true,
no_intra_emphasis: true,
quote: true,
smartypants: true,
strikethrough: true,
superscript: true,
tables: true
set :markdown_engine, :redcarpet
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 = 5
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 "/docs/*"
page "/docs*"
end
# Don't make these URLs have pretty URLs
page '/404.html', directory_index: false
page '/.htacces.html', directory_index: false
# 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
ready do
# Add author pages
sitemap.resources.group_by { |p| p.data['author'] }.each do |author, pages|
next unless author
proxy "/blog/author/#{author.parameterize.downcase}.html",
'author.html',
locals: { author: author, pages: pages },
ignore: true
end
proxy '/blog/author.html', 'author.html', ignore: true
# Add blog feeds
blog.tags.each do |tag_name, _tag_data|
next unless tag_name
proxy "/blog/tag/#{tag_name.downcase.parameterize}.xml",
'feed.xml',
locals: { tag_name: tag_name },
ignore: true
end
proxy '/blog/feed.xml', 'feed.xml', ignore: true
proxy '/blog/tag/index.html', 'tag.html', ignore: true
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
require 'lib/monkeypatch_blog_date.rb'
activate :piwik do |f|
f.id = 4
f.domain = 'tracker.osci.io'
f.url = 'piwik'
end
###
# 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