forked from emberjs/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
182 lines (145 loc) · 3.69 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
179
180
181
182
require 'redcarpet'
require 'active_support'
require 'active_support/core_ext'
Dir['./lib/*'].each { |f| require f }
# Debugging
set(:logging, ENV['RACK_ENV'] != 'production')
set :markdown_engine, :redcarpet
set :markdown, :layout_engine => :erb,
:fenced_code_blocks => true,
:lax_html_blocks => true,
:renderer => Highlighter::HighlightedHTML.new
activate :asset_hash, :ignore => [/^sw/]
activate :directory_indexes
activate :toc
activate :sponsors
activate :highlighter
activate :column_balancer
activate :versions
activate :ember do |config|
config.templates_root = 'app/builds/templates'
end
activate :api_docs,
ember: {
name: "Ember",
default_class: "Ember",
root: "api",
data: "api",
repo_url: 'https://github.com/emberjs/ember.js'
},
data: {
name: "Ember Data",
default_class: "DS",
root: "api/data",
data: "data_api",
repo_url: "https://github.com/emberjs/data"
}
activate :internal_api_docs,
ember: {
name: "Ember",
default_class: "Ember",
root: "internal",
data: "api",
repo_url: 'https://github.com/emberjs/ember.js'
},
data: {
name: "Ember Data",
default_class: "DS",
root: "internal/data",
data: "data_api",
repo_url: "https://github.com/emberjs/data"
}
###
# Build
###
configure :build do
activate :minify_css
activate :minify_javascript, ignore: /.*examples.*js/
end
###
# Blog
###
activate :blog do |blog|
blog.prefix = 'blog'
blog.layout = 'layouts/blog'
blog.tag_template = 'blog/tag.html'
blog.paginate = true
blog.page_link = "page/{num}"
blog.per_page = 10
end
page '/blog/feed.xml', layout: false
###
# Pages
###
page 'guides*', layout: :guide
page 'community.html'
page 'index.html', proxy: 'about.html'
page '404.html', directory_index: false
# Don't build layouts standalone
ignore '*_layout.erb'
# Don't build API layouts
ignore 'api/class.html.erb'
ignore 'api/module.html.erb'
ignore 'internal_api/class.html.erb'
ignore 'internal_api/module.html.erb'
# Don't build templates for example apps because they are embedded in other JS
ignore 'javascripts/app/examples/*/templates/*'
###
# Builds
###
['release', 'beta', 'canary', 'tagged'].each do |tab|
proxy "/builds/#{tab}.html", '/builds/index.html'
end
###
# Helpers
###
helpers do
# Workaround for content_for not working in nested layouts
def partial_for(key, partial_name=nil)
@partial_names ||= {}
if partial_name
@partial_names[key] = partial_name
else
@partial_names[key]
end
end
def rendered_partial_for(key)
partial_name = partial_for(key)
partial(partial_name) if partial_name
end
def link_to_page name, url
path = request.path
current = path =~ Regexp.new('^' + url[1..-1] + '.*\.html')
if path == 'index.html' and name == 'about'
current = true
end
class_name = current ? ' class="active"' : ''
"<li#{class_name}><a href=\"#{url}\">#{name}</a></li>"
end
def page_classes(page)
classes = super
return 'not-found' if classes == '404'
if page.responsive
classes += ' responsive'
else
classes += ' not-responsive'
end
classes.gsub('internal', 'api')
end
def load_example_files
root = Pathname(__FILE__).join('../source/javascripts/app/examples')
all_files = Hash.new {|hash, key| hash[key] = [] }
Dir[root.join('**/*.*').to_s].each do |path|
relative_path = Pathname(path).relative_path_from(root)
match_data = relative_path.to_s.match(%r{^([^/]+)/(.+)$})
name = match_data[1]
file = match_data[2]
all_files[name] << {name: file, contents: File.read(path)}
end
all_files
end
end
###
# Redirects (These must be last!)
###
activate :alias