-
Notifications
You must be signed in to change notification settings - Fork 41
/
config.rb
90 lines (72 loc) · 2.34 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
::I18n.config.enforce_available_locales = false
require 'bootstrap-sass'
require "active_support/core_ext/array"
require 'dotenv'
Dotenv.load
set :build_dir, ".build"
set :markdown, enable_coderay: false, input: "GFM"
ignore "*.graffle"
# activate :compass
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
activate :minify_css
# This breaks the site.
# activate :minify_javascript
activate :sprockets
helpers do
# Calculate the years for a copyright
def copyright_years(start_year)
end_year = Date.today.year
if start_year == end_year
start_year.to_s
else
start_year.to_s + '-' + end_year.to_s
end
end
# Holder.js image placeholder helper
def img_holder(width, height, opts = {})
img = "<img data-src=\"holder.js/#{width}x#{height}/auto"
img << "/#{opts[:bgcolor]}:#{opts[:fgcolor]}" if opts[:fgcolor] && opts[:bgcolor]
img << "/text:#{opts[:text].gsub(/'/,"\'")}" if opts[:text]
img << "\" width=\"#{width}\" height=\"#{height}\">"
img
end
def github_edit_url
p = Pathname(current_page.source_file).relative_path_from(Pathname(root))
"https://github.com/tsaleh/tammersaleh.com/edit/master/#{p}"
end
def index_article_background_url(article)
"#{article.url}cover.png"
end
def img(name, path)
"![#{name}](#{current_page.url + path})"
end
def vimeo_embed(vimeo_id, opts = {})
w = opts[:width] || 500
h = opts[:height] || 280
"<iframe src='//player.vimeo.com/video/#{vimeo_id}?title=0&byline=0&portrait=0' width='#{w}' height='#{h}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"
end
def hacker_news_link(hn_id, title)
'<a href="https://news.ycombinator.com/item?id=' + hn_id + '">' + title + "</a>"
end
end
# Build-specific configuration
configure :build do
end
Time.zone = "Pacific Time (US & Canada)"
activate :blog do |blog|
blog.prefix = "posts"
blog.permalink = ":title.html"
blog.layout = "post"
blog.default_extension = ".markdown.erb"
blog.new_article_template = "scripts/article.tt"
end
page "/posts.atom", layout: false
page "/404.html", :directory_index => false
activate :directory_indexes
activate :cache_buster
module Middleman::Blog::BlogArticle
def body_with_fixed_img_tags
body.gsub(%r{src="/posts.atom(.*)}, 'src="http://tammersaleh.com' + url + '\1')
end
end