bridgetown-core 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -1
- data/bin/bridgetown +9 -23
- data/bridgetown-core.gemspec +3 -1
- data/lib/bridgetown-core.rb +9 -2
- data/lib/bridgetown-core/commands/apply.rb +73 -0
- data/lib/bridgetown-core/commands/base.rb +45 -0
- data/lib/bridgetown-core/commands/build.rb +91 -86
- data/lib/bridgetown-core/commands/clean.rb +30 -29
- data/lib/bridgetown-core/commands/concerns/actions.rb +128 -0
- data/lib/bridgetown-core/commands/concerns/build_options.rb +76 -0
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +18 -0
- data/lib/bridgetown-core/commands/concerns/summarizable.rb +13 -0
- data/lib/bridgetown-core/commands/console.rb +57 -39
- data/lib/bridgetown-core/commands/doctor.rb +126 -126
- data/lib/bridgetown-core/commands/new.rb +120 -155
- data/lib/bridgetown-core/commands/plugins.rb +167 -130
- data/lib/bridgetown-core/commands/registrations.rb +16 -0
- data/lib/bridgetown-core/commands/serve.rb +219 -215
- data/lib/bridgetown-core/concerns/convertible.rb +1 -4
- data/lib/bridgetown-core/concerns/site/renderable.rb +1 -2
- data/lib/bridgetown-core/drops/document_drop.rb +9 -1
- data/lib/bridgetown-core/drops/page_drop.rb +1 -1
- data/lib/bridgetown-core/excerpt.rb +4 -1
- data/lib/bridgetown-core/generators/prototype_generator.rb +2 -0
- data/lib/bridgetown-core/liquid_renderer.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
- data/lib/bridgetown-core/liquid_renderer/file_system.rb +3 -1
- data/lib/bridgetown-core/page.rb +3 -18
- data/lib/bridgetown-core/plugin_manager.rb +31 -17
- data/lib/bridgetown-core/renderer.rb +31 -18
- data/lib/bridgetown-core/tags/include.rb +14 -0
- data/lib/bridgetown-core/tags/render_content.rb +39 -16
- data/lib/bridgetown-core/tags/with.rb +15 -0
- data/lib/bridgetown-core/utils.rb +44 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +17 -10
- data/lib/site_template/Gemfile.erb +19 -0
- data/lib/site_template/bridgetown.config.yml +5 -3
- data/lib/site_template/package.json +1 -0
- data/lib/site_template/src/_components/footer.liquid +3 -0
- data/lib/site_template/src/_components/head.liquid +9 -0
- data/lib/site_template/src/{_includes/navbar.html → _components/navbar.liquid} +0 -0
- data/lib/site_template/src/_layouts/default.html +3 -3
- data/lib/site_template/start.js +1 -1
- data/lib/site_template/webpack.config.js +3 -3
- metadata +53 -19
- data/lib/bridgetown-core/command.rb +0 -112
- data/lib/bridgetown-core/commands/help.rb +0 -34
- data/lib/site_template/src/_components/.keep +0 -0
- data/lib/site_template/src/_includes/footer.html +0 -3
- data/lib/site_template/src/_includes/head.html +0 -9
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Tags
|
5
|
+
class WithTag < Liquid::Block
|
6
|
+
def render(context)
|
7
|
+
region_name = @markup.strip
|
8
|
+
context["content_with_region_#{region_name}"] = super
|
9
|
+
""
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Liquid::Template.register_tag("with", Bridgetown::Tags::WithTag)
|
@@ -287,6 +287,50 @@ module Bridgetown
|
|
287
287
|
merged
|
288
288
|
end
|
289
289
|
|
290
|
+
# Returns a string that's been reindented so that Markdown's four+ spaces =
|
291
|
+
# code doesn't get triggered for nested Liquid components
|
292
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
293
|
+
def reindent_for_markdown(input)
|
294
|
+
lines = input.lines
|
295
|
+
return input if lines.first.nil?
|
296
|
+
|
297
|
+
starting_indentation = lines.find { |line| line != "\n" }&.match(%r!^ +!)
|
298
|
+
return input unless starting_indentation
|
299
|
+
|
300
|
+
starting_indent_length = starting_indentation[0].length
|
301
|
+
|
302
|
+
skip_pre_lines = false
|
303
|
+
lines.map do |line|
|
304
|
+
continue_processing = !skip_pre_lines
|
305
|
+
|
306
|
+
if skip_pre_lines
|
307
|
+
skip_pre_lines = false if line.include?("</pre>")
|
308
|
+
end
|
309
|
+
if line.include?("<pre")
|
310
|
+
skip_pre_lines = true
|
311
|
+
continue_processing = false
|
312
|
+
end
|
313
|
+
|
314
|
+
if continue_processing
|
315
|
+
line_indentation = line.match(%r!^ +!).yield_self do |indent|
|
316
|
+
indent.nil? ? "" : indent[0]
|
317
|
+
end
|
318
|
+
new_indentation = line_indentation.rjust(starting_indent_length, " ")
|
319
|
+
|
320
|
+
if %r!^ +!.match?(line)
|
321
|
+
line
|
322
|
+
.sub(%r!^ {1,#{starting_indent_length}}!, new_indentation)
|
323
|
+
.sub(%r!^#{new_indentation}!, "")
|
324
|
+
else
|
325
|
+
line
|
326
|
+
end
|
327
|
+
else
|
328
|
+
line
|
329
|
+
end
|
330
|
+
end.join("")
|
331
|
+
end
|
332
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
333
|
+
|
290
334
|
private
|
291
335
|
|
292
336
|
def merge_values(target, overwrite)
|
@@ -39,17 +39,21 @@ module Bridgetown
|
|
39
39
|
def build_listener(site, options)
|
40
40
|
webpack_path = site.in_root_dir(".bridgetown-webpack")
|
41
41
|
FileUtils.mkdir(webpack_path) unless Dir.exist?(webpack_path)
|
42
|
+
plugin_paths_to_watch = site.plugin_manager.plugins_path.select do |path|
|
43
|
+
Dir.exist?(path)
|
44
|
+
end
|
45
|
+
|
42
46
|
Listen.to(
|
43
47
|
options["source"],
|
44
48
|
webpack_path,
|
45
|
-
*
|
49
|
+
*plugin_paths_to_watch,
|
46
50
|
ignore: listen_ignore_paths(options),
|
47
51
|
force_polling: options["force_polling"],
|
48
|
-
&listen_handler(site)
|
52
|
+
&listen_handler(site, options)
|
49
53
|
)
|
50
54
|
end
|
51
55
|
|
52
|
-
def listen_handler(site)
|
56
|
+
def listen_handler(site, options)
|
53
57
|
proc do |modified, added, removed|
|
54
58
|
t = Time.now
|
55
59
|
c = modified + added + removed
|
@@ -59,7 +63,7 @@ module Bridgetown
|
|
59
63
|
Bridgetown.logger.info "", "#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
|
60
64
|
|
61
65
|
c.each { |path| Bridgetown.logger.info "", path["#{site.root_dir}/".length..-1] }
|
62
|
-
process(site, t)
|
66
|
+
process(site, t, options)
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
@@ -95,7 +99,6 @@ module Bridgetown
|
|
95
99
|
# options - A Hash of options passed to the command
|
96
100
|
#
|
97
101
|
# Returns a list of relative paths from source that should be ignored
|
98
|
-
# rubocop: disable Metrics/AbcSize
|
99
102
|
def listen_ignore_paths(options)
|
100
103
|
source = Pathname.new(options["source"]).expand_path
|
101
104
|
paths = to_exclude(options)
|
@@ -117,13 +120,12 @@ module Bridgetown
|
|
117
120
|
end
|
118
121
|
end.compact + [%r!^\.bridgetown\-metadata!]
|
119
122
|
end
|
120
|
-
# rubocop:enable Metrics/AbcSize
|
121
123
|
|
122
124
|
def sleep_forever
|
123
125
|
loop { sleep 1000 }
|
124
126
|
end
|
125
127
|
|
126
|
-
def process(site, time)
|
128
|
+
def process(site, time, options)
|
127
129
|
begin
|
128
130
|
Bridgetown::Hooks.trigger :site, :pre_reload, site
|
129
131
|
Bridgetown::Hooks.clear_reloadable_hooks
|
@@ -131,9 +133,14 @@ module Bridgetown
|
|
131
133
|
site.process
|
132
134
|
Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
|
133
135
|
" #{(Time.now - time).ceil(2)} seconds."
|
134
|
-
rescue
|
135
|
-
Bridgetown.logger.
|
136
|
-
|
136
|
+
rescue Exception => e
|
137
|
+
Bridgetown.logger.error "Error:", e.message
|
138
|
+
|
139
|
+
if options[:trace]
|
140
|
+
Bridgetown.logger.info e.backtrace.join("\n")
|
141
|
+
else
|
142
|
+
Bridgetown.logger.warn "Error:", "Use the --trace option for more information."
|
143
|
+
end
|
137
144
|
end
|
138
145
|
Bridgetown.logger.info ""
|
139
146
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
# Hello! This is where you manage which Bridgetown version is used to run.
|
5
|
+
# When you want to use a different version, change it below, save the
|
6
|
+
# file and run `bundle install`. Run Bridgetown with `bundle exec`, like so:
|
7
|
+
#
|
8
|
+
# bundle exec bridgetown serve
|
9
|
+
#
|
10
|
+
# This will help ensure the proper Bridgetown version is running.
|
11
|
+
#
|
12
|
+
# To install a plugin, simply run bundle add and specify the group
|
13
|
+
# "bridgetown_plugins". For example:
|
14
|
+
#
|
15
|
+
# bundle add some-new-plugin -g bridgetown_plugins
|
16
|
+
#
|
17
|
+
# Happy Bridgetowning!
|
18
|
+
|
19
|
+
gem "bridgetown", "~> <%= Bridgetown::VERSION %>"
|
@@ -10,12 +10,14 @@
|
|
10
10
|
# For reloadable site metadata like title, SEO description, social media
|
11
11
|
# handles, etc., take a look at src/_data/site_metadata.yml
|
12
12
|
#
|
13
|
-
# If you need help with YAML syntax, here are some quick references for you:
|
13
|
+
# If you need help with YAML syntax, here are some quick references for you:
|
14
14
|
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
|
15
15
|
# https://learnxinyminutes.com/docs/yaml/
|
16
16
|
#
|
17
17
|
|
18
18
|
baseurl: "" # OPTIONAL: the subpath of your site, e.g. /blog
|
19
|
-
url: "" # the base hostname & protocol for your site, e.g.
|
19
|
+
url: "" # the base hostname & protocol for your site, e.g. https://example.com
|
20
20
|
|
21
|
-
|
21
|
+
permalink: pretty
|
22
|
+
|
23
|
+
# timezone: America/Los_Angeles
|
@@ -14,6 +14,7 @@
|
|
14
14
|
"devDependencies": {
|
15
15
|
"@babel/core": "^7.9.0",
|
16
16
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
17
|
+
"@babel/plugin-proposal-decorators": "^7.10.1",
|
17
18
|
"@babel/plugin-transform-runtime": "^7.9.0",
|
18
19
|
"@babel/preset-env": "^7.9.0",
|
19
20
|
"babel-loader": "^8.1.0",
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<meta charset="utf-8" />
|
2
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
3
|
+
{% capture page_title %}{{ title | strip_html | strip_newlines }}{% endcapture %}
|
4
|
+
<title>{% if page_title != "" %}{{ page_title | escape }} | {{ metadata.title | escape }}{% else %}{{ metadata.title | escape }}: {{ metadata.tagline | escape }}{% endif %}</title>
|
5
|
+
|
6
|
+
<meta name="description" content="{{ metadata.description }}" />
|
7
|
+
|
8
|
+
<link rel="stylesheet" href="{% webpack_path css %}" />
|
9
|
+
<script src="{% webpack_path js %}" defer></script>
|
File without changes
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<!doctype html>
|
2
2
|
<html lang="en">
|
3
3
|
<head>
|
4
|
-
{%
|
4
|
+
{% render "head", metadata: site.metadata, title: page.title %}
|
5
5
|
</head>
|
6
6
|
<body class="{{ page.layout }} {{ page.page_class }}">
|
7
|
-
{%
|
7
|
+
{% render "navbar", metadata: site.metadata, page: page %}
|
8
8
|
|
9
9
|
<main>
|
10
10
|
{{ content }}
|
11
11
|
</main>
|
12
12
|
|
13
|
-
{%
|
13
|
+
{% render "footer", metadata: site.metadata %}
|
14
14
|
</body>
|
15
15
|
</html>
|
data/lib/site_template/start.js
CHANGED
@@ -36,7 +36,8 @@ module.exports = {
|
|
36
36
|
options: {
|
37
37
|
presets: ["@babel/preset-env"],
|
38
38
|
plugins: [
|
39
|
-
"@babel/plugin-proposal-
|
39
|
+
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
40
|
+
["@babel/plugin-proposal-class-properties", { "loose" : true }],
|
40
41
|
[
|
41
42
|
"@babel/plugin-transform-runtime",
|
42
43
|
{
|
@@ -57,8 +58,7 @@ module.exports = {
|
|
57
58
|
options: {
|
58
59
|
sassOptions: {
|
59
60
|
includePaths: [
|
60
|
-
path.resolve(__dirname, "src/_components")
|
61
|
-
path.resolve(__dirname, "src/_includes"),
|
61
|
+
path.resolve(__dirname, "src/_components")
|
62
62
|
],
|
63
63
|
},
|
64
64
|
},
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: awesome_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: colorator
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,47 +151,47 @@ dependencies:
|
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '4.0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name: liquid-
|
154
|
+
name: liquid-component
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- - "
|
157
|
+
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0.
|
159
|
+
version: '0.1'
|
146
160
|
type: :runtime
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- - "
|
164
|
+
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0.
|
166
|
+
version: '0.1'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: liquid-render-tag
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
173
|
+
version: '0.2'
|
160
174
|
type: :runtime
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
180
|
+
version: '0.2'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
182
|
+
name: listen
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
187
|
+
version: '3.0'
|
174
188
|
type: :runtime
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
194
|
+
version: '3.0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: pathutil
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,6 +248,20 @@ dependencies:
|
|
234
248
|
- - "~>"
|
235
249
|
- !ruby/object:Gem::Version
|
236
250
|
version: '1.8'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: thor
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '1.0'
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '1.0'
|
237
265
|
description: Bridgetown is a Webpack-aware, Ruby-powered static site generator for
|
238
266
|
the modern Jamstack era
|
239
267
|
email: maintainers@bridgetownrb.com
|
@@ -249,14 +277,19 @@ files:
|
|
249
277
|
- lib/bridgetown-core/cache.rb
|
250
278
|
- lib/bridgetown-core/cleaner.rb
|
251
279
|
- lib/bridgetown-core/collection.rb
|
252
|
-
- lib/bridgetown-core/
|
280
|
+
- lib/bridgetown-core/commands/apply.rb
|
281
|
+
- lib/bridgetown-core/commands/base.rb
|
253
282
|
- lib/bridgetown-core/commands/build.rb
|
254
283
|
- lib/bridgetown-core/commands/clean.rb
|
284
|
+
- lib/bridgetown-core/commands/concerns/actions.rb
|
285
|
+
- lib/bridgetown-core/commands/concerns/build_options.rb
|
286
|
+
- lib/bridgetown-core/commands/concerns/configuration_overridable.rb
|
287
|
+
- lib/bridgetown-core/commands/concerns/summarizable.rb
|
255
288
|
- lib/bridgetown-core/commands/console.rb
|
256
289
|
- lib/bridgetown-core/commands/doctor.rb
|
257
|
-
- lib/bridgetown-core/commands/help.rb
|
258
290
|
- lib/bridgetown-core/commands/new.rb
|
259
291
|
- lib/bridgetown-core/commands/plugins.rb
|
292
|
+
- lib/bridgetown-core/commands/registrations.rb
|
260
293
|
- lib/bridgetown-core/commands/serve.rb
|
261
294
|
- lib/bridgetown-core/commands/serve/servlet.rb
|
262
295
|
- lib/bridgetown-core/concerns/convertible.rb
|
@@ -330,6 +363,7 @@ files:
|
|
330
363
|
- lib/bridgetown-core/tags/post_url.rb
|
331
364
|
- lib/bridgetown-core/tags/render_content.rb
|
332
365
|
- lib/bridgetown-core/tags/webpack_path.rb
|
366
|
+
- lib/bridgetown-core/tags/with.rb
|
333
367
|
- lib/bridgetown-core/url.rb
|
334
368
|
- lib/bridgetown-core/utils.rb
|
335
369
|
- lib/bridgetown-core/utils/ansi.rb
|
@@ -342,6 +376,7 @@ files:
|
|
342
376
|
- lib/bridgetown-core/version.rb
|
343
377
|
- lib/bridgetown-core/watcher.rb
|
344
378
|
- lib/site_template/.gitignore
|
379
|
+
- lib/site_template/Gemfile.erb
|
345
380
|
- lib/site_template/bridgetown.config.yml
|
346
381
|
- lib/site_template/frontend/javascript/index.js
|
347
382
|
- lib/site_template/frontend/styles/index.scss
|
@@ -349,11 +384,10 @@ files:
|
|
349
384
|
- lib/site_template/plugins/builders/.keep
|
350
385
|
- lib/site_template/plugins/site_builder.rb
|
351
386
|
- lib/site_template/src/404.html
|
352
|
-
- lib/site_template/src/_components
|
387
|
+
- lib/site_template/src/_components/footer.liquid
|
388
|
+
- lib/site_template/src/_components/head.liquid
|
389
|
+
- lib/site_template/src/_components/navbar.liquid
|
353
390
|
- lib/site_template/src/_data/site_metadata.yml
|
354
|
-
- lib/site_template/src/_includes/footer.html
|
355
|
-
- lib/site_template/src/_includes/head.html
|
356
|
-
- lib/site_template/src/_includes/navbar.html
|
357
391
|
- lib/site_template/src/_layouts/default.html
|
358
392
|
- lib/site_template/src/_layouts/home.html
|
359
393
|
- lib/site_template/src/_layouts/page.html
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bridgetown
|
4
|
-
class Command
|
5
|
-
class << self
|
6
|
-
# A list of subclasses of Bridgetown::Command
|
7
|
-
def subclasses
|
8
|
-
@subclasses ||= []
|
9
|
-
end
|
10
|
-
|
11
|
-
# Keep a list of subclasses of Bridgetown::Command every time it's inherited
|
12
|
-
# Called automatically.
|
13
|
-
#
|
14
|
-
# base - the subclass
|
15
|
-
#
|
16
|
-
# Returns nothing
|
17
|
-
def inherited(base)
|
18
|
-
subclasses << base
|
19
|
-
super(base)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Run Site#process and catch errors
|
23
|
-
#
|
24
|
-
# site - the Bridgetown::Site object
|
25
|
-
#
|
26
|
-
# Returns nothing
|
27
|
-
def process_site(site)
|
28
|
-
site.process
|
29
|
-
rescue Bridgetown::Errors::FatalException => e
|
30
|
-
Bridgetown.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
31
|
-
Bridgetown.logger.error "", "------------------------------------"
|
32
|
-
Bridgetown.logger.error "", e.message
|
33
|
-
exit(1)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Create a full Bridgetown configuration with the options passed in as overrides
|
37
|
-
#
|
38
|
-
# options - the configuration overrides
|
39
|
-
#
|
40
|
-
# Returns a full Bridgetown configuration
|
41
|
-
def configuration_from_options(options)
|
42
|
-
return options if options.is_a?(Bridgetown::Configuration)
|
43
|
-
|
44
|
-
Bridgetown.configuration(options)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Add common options to a command for building configuration
|
48
|
-
#
|
49
|
-
# cmd - the Bridgetown::Command to add these options to
|
50
|
-
#
|
51
|
-
# Returns nothing
|
52
|
-
# rubocop:disable Metrics/MethodLength
|
53
|
-
def add_build_options(cmd)
|
54
|
-
cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
|
55
|
-
Array, "Custom configuration file"
|
56
|
-
cmd.option "source", "-s", "--source [DIR]",
|
57
|
-
"Source directory (defaults to src)"
|
58
|
-
cmd.option "destination", "-d", "--destination [DIR]",
|
59
|
-
"Destination directory (defaults to output)"
|
60
|
-
cmd.option "root_dir", "-r", "--root_dir [DIR]", "The top-level root folder" \
|
61
|
-
" where config files are located"
|
62
|
-
cmd.option "plugins_dir", "-p", "--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]", Array,
|
63
|
-
"Plugins directory (defaults to plugins)"
|
64
|
-
cmd.option "layouts_dir", "--layouts [DIR]", String,
|
65
|
-
"Layouts directory (defaults to src/_layouts)"
|
66
|
-
cmd.option "future", "--future", "Publishes posts with a future date"
|
67
|
-
cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
|
68
|
-
"Limits the number of posts to parse and publish"
|
69
|
-
cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
|
70
|
-
cmd.option "baseurl", "-b", "--baseurl URL",
|
71
|
-
"Serve the website from the given base URL"
|
72
|
-
cmd.option "force_polling", "--force_polling", "Force watch to use polling"
|
73
|
-
cmd.option "lsi", "--lsi", "Use LSI for improved related posts"
|
74
|
-
cmd.option "unpublished", "-U", "--unpublished",
|
75
|
-
"Render posts that were marked as unpublished"
|
76
|
-
cmd.option "disable_disk_cache", "--disable-disk-cache",
|
77
|
-
"Disable caching to disk"
|
78
|
-
cmd.option "profile", "--profile", "Generate a Liquid rendering profile"
|
79
|
-
cmd.option "quiet", "-q", "--quiet", "Silence output."
|
80
|
-
cmd.option "verbose", "-V", "--verbose", "Print verbose output."
|
81
|
-
cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
|
82
|
-
cmd.option "strict_front_matter", "--strict_front_matter",
|
83
|
-
"Fail if errors are present in front matter"
|
84
|
-
end
|
85
|
-
# rubocop:enable Metrics/MethodLength
|
86
|
-
|
87
|
-
# Run ::process method in a given set of Bridgetown::Command subclasses and suggest
|
88
|
-
# re-running the associated command with --trace switch to obtain any additional
|
89
|
-
# information or backtrace regarding the encountered Exception.
|
90
|
-
#
|
91
|
-
# cmd - the Bridgetown::Command to be handled
|
92
|
-
# options - configuration overrides
|
93
|
-
# klass - an array of Bridgetown::Command subclasses associated with the command
|
94
|
-
#
|
95
|
-
# Note that all exceptions are rescued..
|
96
|
-
# rubocop: disable Lint/RescueException
|
97
|
-
def process_with_graceful_fail(cmd, options, *klass)
|
98
|
-
klass.each { |k| k.process(options) if k.respond_to?(:process) }
|
99
|
-
rescue Exception => e
|
100
|
-
raise e if cmd.trace
|
101
|
-
|
102
|
-
msg = " Please append `--trace` to the `#{cmd.name}` command "
|
103
|
-
dashes = "-" * msg.length
|
104
|
-
Bridgetown.logger.error "", dashes
|
105
|
-
Bridgetown.logger.error "Bridgetown #{Bridgetown::VERSION} ", msg
|
106
|
-
Bridgetown.logger.error "", " for any additional information or backtrace. "
|
107
|
-
Bridgetown.logger.abort_with "", dashes
|
108
|
-
end
|
109
|
-
# rubocop: enable Lint/RescueException
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|