This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
/
config.rb
executable file
·178 lines (136 loc) · 4.25 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
# coding: utf-8
require "lib/helpers"
require "lib/image_helpers"
helpers MyHelpers
helpers ImageHelpers
require "susy"
###
# 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 :docs do
page "/docs/*"
end
with_layout :legal do
page "/legal/*"
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
###
set :markdown, :no_intra_emphasis => true,
:tables => true,
:gh_blockcode => true,
:fenced_code_blocks => true,
:autolink => true,
:strikethrough => true,
:lax_html_blocks => true,
:superscript => true,
:with_toc_data => true,
:hard_wrap => true,
:smartypants => true
set :markdown_engine, :redcarpet
activate :sitemap,
:gzip => false,
:hostname => "https://codio.com"
activate :syntax, line_numbers: true
activate :automatic_clowncar,
:sizes => {
:small => 400,
:medium => 600,
:large => 800,
:extraLarge => 1000
},
:namespace_directory => %w(artwork),
:filetypes => [:jpg, :jpeg, :png]
activate :asset_host
set :asset_host, ENV["M_ASSET_HOST"] || "http://localhost:4567"
set :cookie_consent, ENV["M_COOKIE_CONSENT"] || 'https://d32pm7l1p0vsmf.cloudfront.net/cookieconsent2.6c0a6314.js'
activate :directory_indexes
ignore '*.ordered'
# Need the extension for error pages
page "404.html", :directory_index => false
page "50x.html", :directory_index => false
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
activate :bower
activate :es6
activate :autoprefixer do |config|
config.browsers = ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']
end
# Reload the browser automatically whenever files change
configure :development do
activate :livereload, no_swf: true
set :file_watcher_ignore, [
%r{\.tern-port},
%r{flycheck_},
%r{node_modules/},
%r{vendor/},
%r{\.idea/},
%r{\.#}
]
end
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'img'
set :partials_dir, 'partials'
set :domain_tag, ENV["M_DOMAIN_TAG"] || 'https://codio.com'
set :intercom_id, ENV["M_INTERCOM_ID"] || "hzz6oifn"
set :codio_environment, ENV["M_CODIO_ENVIRONMENT"] || "development"
set :asset_host, ENV["M_ASSET_HOST"] || "http://localhost:4567"
set :tiny_host, ENV["M_TINY_HOST"] || "http://localhost:6789"
# Build-specific configuration
configure :build do
# Minification and Compression
activate :minify_css
activate :minify_javascript do |js|
require 'uglifier'
js.compressor = Uglifier.new(:output => {:comments => :none}, :screw_ie8 => true)
end
activate :minify_html do |html|
html.remove_http_protocol = false
html.remove_https_protocol = true
html.remove_input_attributes = false
end
activate :gzip do |gzip|
gzip.exts = %w(.js .css .html .htm .svg)
end
activate :cache_buster
# Enable cache buster
activate :asset_hash
set :asset_host, ENV["M_ASSET_HOST"] || "https://codio.com"
end
activate :sprockets
def createUrlNode(loc, priority, doc)
url = Nokogiri::XML::Node.new("url", doc)
urlpriority = Nokogiri::XML::Node.new("priority", doc)
urlpriority.content = priority
url << urlpriority
urlloc = Nokogiri::XML::Node.new("loc", doc)
urlloc.content = loc
url << urlloc
url
end
after_build do
sitemapfile = File.join(build_dir, "sitemap.xml")
# Read or initialize the data
if File.exist?(sitemapfile)
data = File.read(sitemapfile)
end
doc = Nokogiri::XML.parse data
urlset = doc.at_css('urlset')
urlset << createUrlNode("https://news.codio.com/", 0.9, doc)
urlset << createUrlNode("https://codio.com/start-edu-trial", 0.9, doc)
outfile = File.join(build_dir, "sitemap.xml")
File.open(outfile, 'w') {|f| f.write(doc) }
end