-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathconfig.rb
106 lines (90 loc) · 2.94 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
require 'pathname'
require 'yaml'
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
set :relative_links, true
ignore '*.bak'
# Reload the browser automatically whenever files change
activate :livereload
activate :syntax
activate :blog do |blog|
blog.prefix = 'blog'
blog.paginate = true
end
page "index.html", :layout => :base_layout
page "blog/*", :layout => :blog_layout
page "doc/manual/*", :layout => :manual_layout
page "versions/*", :layout => :manual_layout
activate :s3_sync do |s3_sync|
auth_file = File.expand_path('~/.howl-auth')
if File.exists?(auth_file)
if File.stat(auth_file).world_readable?
raise "'#{auth_file}' is world readable, please fix"
end
creds = YAML.load_file(auth_file)
s3_sync.aws_access_key_id = creds['access_key']
s3_sync.aws_secret_access_key = creds['secret_key']
else
$stderr.puts "WARN: #{auth_file} not present"
end
s3_sync.bucket = 'howl.io'
s3_sync.region = 'eu-west-1'
s3_sync.add_caching_policy :default, max_age: 60 * 30
end
require "redcarpet"
set :markdown_engine, :redcarpet
set :markdown, {
fenced_code_blocks: true,
smartypants: true,
autolink: true,
tables: true,
with_toc_data: true,
no_intra_emphasis: true,
footnotes: true
}
require 'middleware/auto_format'
require 'middleware/blog_adjustments'
use AutoFormat
use BlogAdjustments
helpers do
def hdr_link(idx, title, path)
"<h4><span class=\"hdr-idx\">#{idx}</span> <a href=\"#{path}\">#{title}</a></h4>"
end
def breadcrumbs
component = Struct.new(:path, :title, :document_exists?)
base = Pathname.new("/#{current_resource.destination_path}").parent
components = []
path = Pathname.new '/'
parts = current_resource.path.split('/').reject { |p| p =~ /index\./ }
parts.each do |part|
path = path.join part
resource = sitemap.find_resource_by_path(path.to_s) || sitemap.find_resource_by_path("#{path}/index.html")
title = resource && (resource.metadata[:locals][:page_title] || resource.metadata[:page]['title'])
title ||= part =~ /([^.]+(?:\.\d+))/ && $1.capitalize
components << component.new(path.relative_path_from(base), (title or part), !!resource)
end
return '' if components.empty?
crum = '<ol class="breadcrumb">'
crum += '<li><a href="/">Home</a></li>'
components[0..-2].each do |component|
if component.document_exists?
crum << "<li><a href='#{component.path}/'>#{component.title}</a></li>"
else
crum << "<li>#{component.title}</li>"
end
end
crum += "<li>#{components[-1].title}</li>"
crum + '</ol>'
end
end
['steinom', 'monokai', 'solarized-light', 'tomorrow-night-blue', 'blueberry-blend', 'dracula'].each do |theme|
proxy "/screenshots/#{theme}.html", "/templates/screenshots.html", {
locals: {
theme: theme,
theme_name: theme.tr('-', ' ').capitalize,
page_title: theme.tr('-', ' ').capitalize + ' theme'
},
ignore: true
}
end