-
Notifications
You must be signed in to change notification settings - Fork 216
Expand file tree
/
Copy pathconfig.rb
More file actions
240 lines (198 loc) · 8.76 KB
/
config.rb
File metadata and controls
240 lines (198 loc) · 8.76 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
Dir.glob(File.expand_path("../lib/config/*.rb", __FILE__), &method(:require))
require_relative "lib/versions"
config[:versions] = VERSIONS
config[:latest_version] = config[:versions].last
activate :syntax
activate :i18n
activate :search do |search|
search.resources = ["index.html", "#{config[:latest_version]}/", "changelog.html", "compatibility.html", "conduct.html"]
search.index_path = "search/lunr-index.json"
search.fields = {
title: {boost: 100, store: true, required: true},
content: {boost: 50},
url: {index: false, store: true},
description: {index: false, store: true},
}
end
set :layout, :base
set :images_dir, "images"
set :markdown_engine, :kramdown
# Markdown extentions
set :markdown,
input: "GFM",
autolink: true,
fenced_code_blocks: true,
footnotes: true,
gh_codeblock: true,
highlight: true,
no_intra_emphasis: true,
quote: true,
smartypants: true,
strikethrough: true,
superscript: true,
tables: true,
hard_wrap: false
# Webpack
activate :external_pipeline,
name: :webpack,
command: build? ? "npm run build" : "npm run start",
source: ".tmp/dist",
latency: 1
# Make documentation for the latest version available at the top level, too.
# Any pages with names that conflict with files already at the top level will be skipped.
Dir.glob("./source/#{config[:latest_version]}/*.haml").each do |file_path|
file_path = file_path.sub(/\.haml$/, "")
page_path = file_path.sub(/^\.\/source\//, "")
proxy_path = file_path["./source/#{config[:latest_version]}/".length..-1]
proxy proxy_path, page_path unless file_exist?(proxy_path)
end
# Same for localizable
Dir.glob("./source/localizable/#{config[:latest_version]}/**/*").select{ |f| File.file?(f) }.each do |file_path|
matched = file_path.match(/(localizable\/v\d+.\d+\/(.*)\.(.{2})\.html)/)
next unless matched
page_path = matched[1]
proxy_path = "#{matched[2]}.html"
country = matched[3]
next if file_exist?(proxy_path)
proxy "#{country}/#{proxy_path}", page_path, locale: country.to_sym
proxy proxy_path, page_path, locale: :en if country == "en"
end
# Redirect removed guide pages to https://guides.rubygems.org/
guides_target = "https://guides.rubygems.org/"
## /guides/creating_gem.html, /guides/using_bundler_in_applications.html (localizable guides, non-en)
%w[creating_gem using_bundler_in_applications].each do |filename|
%w[es pl].each do |lang|
redirect "#{lang}/guides/#{filename}.html", to: guides_target
end
end
## Top-level pages that were previously redirected to guides/
%w[bundler_workflow gemfile gemfile_ruby rationale rubygems rubymotion].each do |filename|
redirect "#{filename}.html", to: guides_target
end
## /v1.12/rails23.html, /v1.12/rails3.html
%w[rails23 rails3].each do |filename|
redirect "v1.12/#{filename}.html", to: guides_target
end
## Versioned guide redirects for v1.12-v1.14
%w[1.12 1.13 1.14].each do |version|
%w[bundler_setup bundler_sharing deploying faq git git_bisect groups rails sinatra updating_gems].each do |filename|
redirect "v#{version}/#{filename}.html", to: guides_target
end
end
## Versioned localizable guide redirects for v1.12-v1.15
%w[1.12 1.13 1.14 1.15].each do |version|
["", "pl/"].each do |lang|
redirect "#{lang}v#{version}/guides/creating_gem.html", to: guides_target
redirect "#{lang}v#{version}/guides/using_bundler_in_applications.html", to: guides_target
end
end
## v1.15 guides
%w[bundler_setup bundler_sharing deploying faq git git_bisect groups rails rubygems_tls_ssl_troubleshooting_guide sinatra updating_gems].each do |filename|
redirect "v1.15/guides/#{filename}.html", to: guides_target
end
%w[bundler_setup bundler_sharing].each do |filename|
redirect "es/v1.15/guides/#{filename}.html", to: guides_target
end
## Versioned guide redirects for v1.16-v2.3
%w[1.16 1.17 2.0 2.1 2.2 2.3].each do |version|
%w[
bundler_docker_guide bundler_in_a_single_file_ruby_script bundler_plugins
bundler_setup bundler_sharing deploying faq git git_bisect groups rails
rubygems_tls_ssl_troubleshooting_guide sinatra updating_gems
].each do |filename|
redirect "v#{version}/guides/#{filename}.html", to: guides_target
end
%w[bundler_workflow gemfile gemfile_ruby rationale rubygems rubymotion].each do |filename|
redirect "v#{version}/#{filename}.html", to: guides_target
end
["", "pl/"].each do |lang|
redirect "#{lang}v#{version}/guides/creating_gem.html", to: guides_target
redirect "#{lang}v#{version}/guides/using_bundler_in_applications.html", to: guides_target
end
end
## v2.0-v2.3 bundler_2_upgrade
%w[2.0 2.1 2.2 2.3].each do |version|
redirect "v#{version}/guides/bundler_2_upgrade.html", to: guides_target
end
# Redirect old pages in this repo to manpages (see https://github.com/rubygems/bundler-site/issues/723)
%w[help binstubs check clean console init inject install open outdated plugin show version viz].each do |command|
redirect "bundle_#{command}.html", to: "man/bundle-#{command}.1.html"
end
# Redirect meaningless pages proxied for 6 years to the original pages
# https://github.com/rubygems/bundler-site/issues/807
config[:versions].each do |version|
Dir.glob("./source/#{version}/man/**/*").select{ |f| File.file?(f) }.each do |file_path|
file_path = file_path[0..-5]
page_path = file_path.sub(/^\.\/source/, "")
man_page_name_matched = file_path.match(/man\/(.*)\.html$/)
next unless man_page_name_matched
man_page_name = man_page_name_matched[1].gsub(/\.\d+$/, "").gsub("-", "_")
man_page_name = "gemfile_man" if man_page_name == "gemfile"
redirect "#{version}/#{man_page_name}.html", to: page_path unless man_page_exists?(man_page_name, version)
end
end
%w[1.12 1.13 1.14 1.15].each do |version|
# Redirect old pages in this repo to manpages (see https://github.com/rubygems/bundler-site/issues/723)
%w[help binstubs check clean console init inject install open outdated show version viz].each do |command|
redirect "v#{version}/bundle_#{command}.html", to: "v1.15/man/bundle-#{command}.1.html"
end
# /v:ver/docs.html is now the center of versioned docs
redirect "v#{version}/index.html", to: "v#{version}/docs.html"
end
%w[1.16 1.17 2.0 2.1 2.2 2.3].each do |version|
# Redirect old pages in this repo to manpages (see https://github.com/rubygems/bundler-site/issues/723)
%w[help binstubs check clean console init inject install open outdated plugin show version viz].each do |command|
next if %w[plugin].include?(command) && version < "2.3"
redirect "v#{version}/bundle_#{command}.html", to: "v#{version}/man/bundle-#{command}.1.html"
end
# /v:ver/docs.html is now the center of versioned docs
redirect "v#{version}/index.html", to: "v#{version}/docs.html"
end
redirect "sponsors.html", to: "https://rubygems.org/pages/sponsors" # Backwards compatibility
page "/changelog.html", layout: :two_column_layout
page "/conduct.html", layout: :two_column_layout
page "/compatibility.html", layout: :two_column_layout
page "/whats_new.html", layout: :two_column_layout
page /\/v(\d+.\d+)\/(?!bundle_|commands|docs|man)(.*)/, layout: :two_column_layout
page /\/v(.*)\/man\/(.*)/, layout: :two_column_layout
page /man\/(.*)/, layout: :two_column_layout
page /\/doc\/(.*)/, layout: :two_column_layout # Imported from rubygems/bundler
page "/sitemap.xml", layout: false
redirect "issues.html", to: "https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md" # Backwards compatibility
redirect "commands.html", to: "man/bundle.1.html" # Backwards compatibility
redirect "older_versions.html", to: "whats_new.html" # Backwards compatibility
redirect "team.html", to: "https://guides.rubygems.org/contributing" # https://github.com/rubygems/bundler-site/issues/842
redirect "contributors.html", to: "https://guides.rubygems.org/contributing"
# Backwards compatibility for year/month/day index
ymds = %w[
2013/10/12 2013/12/07
2014/07/16 2014/08/14 2014/08/15
2015/03/19 2015/03/20 2015/03/21 2015/06/24 2015/12/12
2016/04/28 2016/07/10 2016/09/08
2017/03/28 2017/05/19 2017/10/31
2018/01/08 2018/01/17 2018/03/09 2018/04/09 2018/05/07 2018/06/07 2018/07/12 2018/08/10 2018/09/10 2018/10/15 2018/10/25 2018/11/04 2018/11/05 2018/12/08
2019/01/03 2019/01/04 2019/02/02 2019/03/12 2019/05/14
2020/04/27 2020/12/09
2021/02/15
2022/01/23
]
## /blog/YYYY/MM/DD/
ymds.each do |ymd|
redirect "blog/#{ymd}/index.html", to: "/blog/"
end
## /blog/YYYY/MM/
ymds.map { |ymd| ymd.sub(%r{/\d+$}, "") }.each do |ym|
redirect "blog/#{ym}/index.html", to: "/blog/"
end
## /blog/YYYY/
ymds.map { |ymd| ymd.sub(%r{/\d+/\d+$}, "") }.each do |y|
redirect "blog/#{y}/index.html", to: "/blog/"
end
configure :development do
config[:css_dir] = ".tmp/dist"
config[:js_dir] = ".tmp/dist"
end
configure :build do
config[:css_dir] = ""
config[:js_dir] = ""
end