-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.rb
205 lines (172 loc) · 6.52 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
# ========================================================================
# Hello Jason
# http://hellojason.net
# ========================================================================
$:.push File.expand_path('../source', __FILE__)
# Copy ./source/environment_variables.example to ./source/environment_variables.rb
# then update settings there.
require 'environment_variables'
# ========================================================================
# Site settings
# ========================================================================
set :site_title, "Middleman Site"
set :site_description, "This is an example meta description."
set :site_url_production, ENV['site_url_production']
set :site_url_development, ENV['site_url_development']
set :css_dir, 'assets/css'
set :js_dir, 'assets/js'
set :images_dir, 'assets/img'
set :fonts_dir, 'assets/fonts'
# Sitemap URLs (use trailing slashes)
set :url_sample, "/sample/"
# Place additional URLs here...
# Sitemap XML
require "builder"
page "/sitemap.xml", :layout => false
# Slim template engine
require "slim"
# Internationalization
# activate :i18n
# Use relative URLs
activate :relative_assets
# Pretty URLs
activate :directory_indexes
# Autoprefixer
activate :autoprefixer do |config|
config.browsers = ['last 2 versions', 'Explorer >= 9']
config.cascade = false
config.inline = false
end
# Reload the browser automatically whenever files change
activate :livereload
# ========================================================================
# 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
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html",
# :locals => {:which_fake_page => "Rendering a fake page with a local
# variable" }
# ========================================================================
# Helpers
# ========================================================================
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
# Methods defined in the helpers block are available in templates
# helpers do
# def some_helper
# "Helping"
# end
# end
helpers do
# Gets partials from the _partials directory
def _partial(partial_filename)
partial "_partials/#{partial_filename}"
end
# Formats li item, and determines when to put class=active on li element
# (according to Bootstrap >3.1.1 spec)
def nav_li(label, url, css_class="", icon="")
# Determine if icon is specified
nav_icon = ""
unless icon.nil? or icon.empty?
nav_icon = " <i class='fa #{icon}'></i>"
end
# Normalize name string for use as HTML class
li_classes = ""
unless css_class.nil? or css_class.empty?
# Assign processed name to variable
li_classes = "#{css_class}"
else
label_formatted = label.downcase.tr(" ", "-")
li_classes = "nav-item-#{label_formatted}"
end
if current_page.url == url
li_classes += " active"
end
"<li class='#{li_classes}'><a href='#{site_url}#{url}'>#{label}#{nav_icon}</a></li>"
end
end
# ========================================================================
# Development-specific configuration
# ========================================================================
configure :development do
set :site_url, "#{site_url_development}"
end
# ========================================================================
# Build-specific configuration
# ========================================================================
configure :build do
set :site_url, "#{site_url_production}"
set :sass, line_comments: false, style: :nested
activate :minify_css
activate :minify_html
activate :minify_javascript
activate :gzip
# Enable cache buster
activate :asset_hash, :exts => ['.css', '.png', '.jpg', '.gif']
# Ignore files/dir during build process
ignore "environment_variables.rb"
ignore "environment_variables.rb.sample"
ignore "favicon_template.png"
ignore "sitemap.yml"
ignore "imageoptim.manifest.yml"
# Compress and optimise images during build
# Documentation: https://github.com/plasticine/middleman-imageoptim
activate :imageoptim do |options|
# Image extensions to attempt to compress
options.image_extensions = %w(.png .jpg .gif .svg)
# Cause image_optim to be in shouty-mode
options.verbose = false
end
# Create favicon and device-specific icons
# Edit favicon_template.png for custom icon
activate :favicon_maker, :icons => {
"favicon_template.png" => [
{ icon: "apple-touch-icon-152x152-precomposed.png" },
{ icon: "apple-touch-icon-144x144-precomposed.png" },
{ icon: "apple-touch-icon-120x120-precomposed.png" },
{ icon: "apple-touch-icon-114x114-precomposed.png" },
{ icon: "apple-touch-icon-76x76-precomposed.png" },
{ icon: "apple-touch-icon-72x72-precomposed.png" },
{ icon: "apple-touch-icon-60x60-precomposed.png" },
{ icon: "apple-touch-icon-57x57-precomposed.png" },
{ icon: "apple-touch-icon-precomposed.png", size: "57x57" },
{ icon: "apple-touch-icon.png", size: "57x57" },
{ icon: "favicon-196x196.png" },
{ icon: "favicon-160x160.png" },
{ icon: "favicon-96x96.png" },
{ icon: "favicon-32x32.png" },
{ icon: "favicon-16x16.png" },
{ icon: "favicon.png", size: "16x16" },
{ icon: "favicon.ico", size: "64x64,32x32,24x24,16x16" },
{ icon: "mstile-144x144", format: "png" },
]
}
end
# ========================================================================
# Deployment-specific configuration
# ========================================================================
# Middleman-deploy can deploy a site via rsync, ftp, sftp, or git.
# Documentation: https://github.com/karlfreeman/middleman-deploy
# ========================================================================
activate :deploy do |deploy|
deploy.build_before = true
deploy.method = :rsync
deploy.host = 'server'
deploy.user = 'username'
deploy.path = 'path/to/docroot'
# Optional Settings
# deploy.port = 5309 # ssh port, default: 22
# deploy.clean = true # remove orphaned files on remote host, default: false
end