-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.rb
123 lines (102 loc) · 3.86 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
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
# With alternative layout
# page "/path/to/file.html", layout: :otherlayout
# 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" }
# Reload the browser automatically whenever files change
configure :development do
activate :livereload, no_swf: true
activate :autoprefixer
end
activate :i18n, langs: [:en, :de], mount_at_root: :en, templates_dir: "pages"
activate :sprockets
set :css_dir, 'assets/stylesheets'
set :js_dir, 'assets/javascripts'
set :images_dir, 'assets/images'
#activate :directory_indexes
set :relative_links, true
activate :relative_assets
###
# Helpers
###
helpers do
# Returns an array of available languages besides the current one
def other_langs
langs - [I18n.locale]
end
#
# returns the correct path in the current locale
# @example
# = link_to "bar", url("foo/bar.html")
#
def path(url, options = {})
lang = options[:lang] || I18n.locale.to_s
if lang.to_s == 'en'
prefix = ''
else
prefix = "/#{lang}"
end
prefix + "/" + clean_from_i18n(url)
end
# removes an i18n lang code from url if its present
def clean_from_i18n(url)
parts = url.split('/').select { |p| p && p.size > 0 }
parts.shift if langs.map(&:to_s).include?(parts[0])
parts.join('/')
end
end
# Build-specific configuration
configure :build do
activate :minify_css
activate :minify_javascript
activate :minify_html do |html|
html.remove_multi_spaces = true # Remove multiple spaces
html.remove_comments = true # Remove comments
html.remove_intertag_spaces = false # Remove inter-tag spaces
html.remove_quotes = true # Remove quotes
html.simple_doctype = false # Use simple doctype
html.remove_script_attributes = false # Remove script attributes
html.remove_style_attributes = false # Remove style attributes
html.remove_link_attributes = false # Remove link attributes
html.remove_form_attributes = false # Remove form attributes
html.remove_input_attributes = false # Remove input attributes
html.remove_javascript_protocol = true # Remove JS protocol
html.remove_http_protocol = false # Remove HTTP protocol
html.remove_https_protocol = false # Remove HTTPS protocol
html.preserve_line_breaks = false # Preserve line breaks
html.simple_boolean_attributes = true # Use simple boolean attributes
html.preserve_patterns = nil # Patterns to preserve
end
end
activate :imageoptim do |options|
# Use a build manifest to prevent re-compressing images between builds
options.manifest = true
# Silence problematic image_optim workers
options.skip_missing_workers = true
# Cause image_optim to be in shouty-mode
options.verbose = false
# Setting these to true or nil will let options determine them (recommended)
options.nice = true
options.threads = true
# Image extensions to attempt to compress
options.image_extensions = %w(.png .jpg .gif .svg)
# Compressor worker options, individual optimisers can be disabled by passing
# false instead of a hash
options.advpng = { :level => 4 }
options.gifsicle = { :interlace => false }
options.jpegoptim = { :strip => ['all'], :max_quality => 75 }
options.jpegtran = { :copy_chunks => false, :progressive => true, :jpegrescan => true }
options.optipng = { :level => 6, :interlace => false }
options.pngcrush = { :chunks => ['alla'], :fix => false, :brute => false }
options.pngout = { :copy_chunks => false, :strategy => 0 }
options.svgo = false
end