-
Notifications
You must be signed in to change notification settings - Fork 315
/
Copy pathconfig.rb
146 lines (127 loc) · 5.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
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
require 'slim'
set :markdown_engine, :redcarpet
set :markdown, fenced_code_blocks: true, tables: true, no_intra_emphasis: true, with_toc_data: true
###
# 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
page '/blog/feed.xml', layout: false
# With alternative layout
page 'about/*', layout: :sidebar, locals: { sidebar_layout: 'about' }
page 'docs/*', layout: :sidebar, locals: { sidebar_layout: 'docs' }
page 'legal/*', layout: :sidebar, locals: { sidebar_layout: 'legal' }
page 'tutorials/index.html', layout: :tutorials
page 'tutorials/get-started/*', layout: :tutorials_sidebar, locals: { sidebar_layout: 'get_started' }
page 'tutorials/download/*', layout: :tutorials_sidebar, locals: { sidebar_layout: 'download' }
page 'tutorials/sample-app/linux/*', layout: :tutorials_sidebar, locals: { sidebar_layout: 'sample_app_linux' }
page 'tutorials/sample-app/windows/*', layout: :tutorials_sidebar, locals: { sidebar_layout: 'sample_app_windows' }
page 'tutorials/sample-app/mac/*', layout: :tutorials_sidebar, locals: { sidebar_layout: 'sample_app_mac' }
page 'tutorials/sample-app/*', layout: :tutorials_sidebar, locals: { sidebar_layout: 'sample_app' }
page '/blog/index.html', layout: :blog_index
activate :blog do |blog|
blog.prefix = 'blog'
blog.layout = 'layouts/blog_post'
blog.permalink = '{year}/{month}/{title}.html'
blog.default_extension = '.md'
blog.summary_separator = /READMORE/
blog.summary_length = 250
blog.paginate = true
blog.per_page = 10
blog.page_link = 'page/{num}'
blog.taglink = ':tag.html'
blog.tag_template = 'blog/tag.html'
blog.calendar_template = 'blog/calendar.html'
end
###
# Helpers
###
# Methods defined in the helpers block are available in templates
require 'lib/sidebar_helpers'
require 'lib/blog_helpers'
helpers SidebarHelpers
helpers BlogHelpers
helpers do
def layout_class
layout = current_page.options.fetch(:layout, nil)
if layout == :sidebar
'has-sidebar'
elsif layout == :try
'try-hab'
elsif layout == :blog_post
'blogs'
elsif layout == :blog_index
'has-sidebar'
elsif layout == :tutorials
'tutorials'
else
''
end
end
def path_starts_with?(path)
current_page.path.start_with?(path)
end
def builder_web_url
ENV['BUILDER_WEB_URL'] || 'https://bldr.habitat.sh'
end
def render_markdown(text)
Kramdown::Document.new(text).to_html
end
end
configure :development do
# Reload the browser automatically whenever files change
activate :livereload
end
configure :build do
# Asset hash to defeat caching between builds
activate :asset_hash
end
activate :autoprefixer
activate :directory_indexes
set :trailing_slash, false
activate :s3_sync do |s3_sync|
s3_sync.path_style = false
s3_sync.region = ENV['AWS_DEFAULT_REGION']
end
###
# Redirects
###
redirect 'about/index.html', to: '/about/announcement/'
redirect 'docs/build-packages-overview.html', to: '/docs/create-packages-build/'
redirect 'docs/get-habitat.html', to: '/tutorials/download/'
redirect 'download/index.html', to: '/tutorials/download/'
redirect 'downloads/index.html', to: '/tutorials/download/'
redirect 'try/index.html', to: '/tutorials/get-started/demo/'
redirect 'try/index.html', to: '/tutorials/'
redirect 'try/2/index.html', to: '/tutorials/'
redirect 'try/3/index.html', to: '/tutorials/'
redirect 'try/4/index.html', to: '/tutorials/'
redirect 'try/5/index.html', to: '/tutorials/'
redirect 'try/6/index.html', to: '/tutorials/'
redirect 'try/7/index.html', to: '/tutorials/'
redirect 'try/8/index.html', to: '/tutorials/'
redirect 'try/9/index.html', to: '/tutorials/'
redirect 'try/10/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/linux/add-hooks/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/linux/basic-concepts/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/linux/create-plan/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/linux/configure-plan/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/linux/process-build/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/linux/setup-environment/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/mac/add-hooks/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/mac/basic-concepts/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/mac/create-plan/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/mac/configure-plan/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/mac/process-build/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/mac/setup-environment/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/windows/add-hooks/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/windows/basic-concepts/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/windows/create-plan/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/windows/configure-plan/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/windows/process-build/index.html', to: '/tutorials/'
redirect 'tutorials/getting-started/windows/setup-environment/index.html', to: '/tutorials/'
redirect 'tutorials/sample-app/basic-concepts/index.html', to: '/tutorials/sample-app/'