-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rb
160 lines (132 loc) · 5.08 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
# General configuration
config[:domain] = 'howicode.com'
config[:www_prefix] = false
config[:cloudfront_distribution] = 'ES5EDHXD7WPUA'
config[:twitter_owner] = 'wossname'
config[:twitter_creator] = 'mathie'
config[:fb_app_id] = '276208079383599'
config[:gtm_id] = 'GTM-WQZC49'
config[:google_plus_id] = '107453897972450014488'
# Generic metadata
config[:short_title] = 'How I Code'
config[:long_title] = "#{config[:short_title]}: A conversation on the art and craft of software development"
config[:description] = "I want to go on a holistic exploration of how developers write code in a sustainable, enjoyable way."
config[:logo] = 'wossname-industries.png'
config[:company] = 'Wossname Industries'
config[:company_url] = 'https://woss.name/'
config[:telephone] = '+44 (0)7949 077744'
config[:site_category] = "Software Development"
config[:site_tags] = ['Podcast', 'Software Development', 'Productivity',
'Sustainability']
config[:related] = {
# facebook: 'https://www.facebook.com/wossname-industries',
twitter: "https://twitter.com/#{config[:twitter_owner]}",
google: 'https://plus.google.com/+WossnameIndustries',
linkedin: 'https://www.linkedin.com/company/wossname-industries'
}
# Mailing list signup form configuration
config[:mailchimp_url] = "//howicode.us1.list-manage.com/subscribe/post?u=e2954746a3d6f76209fcd2a6a&id=1038bb42e1"
config[:mailchimp_group_id] = "5137"
config[:mailchimp_antispam] = "b_e2954746a3d6f76209fcd2a6a_1038bb42e1"
# UTM-related bits
config[:default_utm_medium] = 'website'
config[:default_utm_campaign] = 'howicode'
# Calculated Configuration
config[:hostname] = config[:www_prefix] ? "www.#{config[:domain]}" : config[:domain]
config[:url] = "https://#{config[:hostname]}"
config[:email_address] = "hello@#{config[:domain]}"
config[:default_utm_source] = config[:domain]
config[:gravatar] = "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(config[:email_address])}"
config[:copyright] = "Copyright © 2015-#{Time.now.year} #{config[:author]}. All rights reserved."
# Pages with no layout
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
# General configuration
activate :directory_indexes
activate :asset_hash
activate :gzip
activate :external_pipeline,
name: :gulp,
command: "./node_modules/gulp/bin/gulp.js #{build? ? 'build' : ''}",
source: 'intermediate/'
# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end
# Build-specific configuration
configure :build do
activate :minify_html
end
activate :s3_sync do |s3|
s3.bucket = config[:hostname]
s3.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
s3.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
end
activate :cloudfront do |cf|
cf.access_key_id = ENV['AWS_ACCESS_KEY_ID']
cf.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
cf.distribution_id = config[:cloudfront_distribution]
cf.filter = /\.(html|xml|txt)$/
end
caching_policy 'text/html', max_age: 0, must_revalidate: true
caching_policy 'application/xml', max_age: 0, must_revalidate: true
caching_policy 'text/plain', max_age: 0, must_revalidate: true
default_caching_policy max_age: (60 * 60 * 24 * 365)
helpers do
def mail_to_link(options = {})
mail_to config[:email_address], config[:email_address], options
end
def utm_link_to(title_or_url, url_or_options = nil, options = {}, &block)
if block_given?
title = nil
url = title_or_url
options = url_or_options || {}
else
title = title_or_url
url = url_or_options
options = options
end
utm_source = options.delete(:source) || config[:default_utm_source]
utm_medium = options.delete(:medium) || config[:default_utm_medium]
utm_campaign = options.delete(:campaign) || config[:default_utm_campaign]
utm_content = options.delete(:content) || title
query = {
utm_source: utm_source,
utm_medium: utm_medium,
utm_campaign: utm_campaign,
utm_content: utm_content
}.merge(options.delete(:query) || {}).reject { |k, v| v.nil? }
options = { query: query }.merge(options)
if block_given?
link_to url, options, &block
else
link_to title, url, options
end
end
def title_meta
current_page.data.title || config[:long_title]
end
def description_meta
current_page.data.description || config[:description]
end
def category_meta
current_page.data.category || config[:site_category]
end
def tags_meta
(current_page.data.tags || []) + (config[:site_tags] || [])
end
def published_at_meta
current_page.data.published_at || Time.now
end
def updated_at_meta
current_page.data.updated_at || published_at_meta
end
def url_meta
"#{config[:url]}#{current_page.url}"
end
def xml_timestamp(dateish = Time.now)
timestamp = dateish.respond_to?(:strftime) ? dateish : Date.parse(dateish)
timestamp.strftime('%FT%H:%M:%S%:z')
end
end