bridgetown-core 0.21.5 → 1.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bridgetown +2 -0
- data/bridgetown-core.gemspec +3 -0
- data/lib/bridgetown-core/cleaner.rb +0 -8
- data/lib/bridgetown-core/collection.rb +59 -81
- data/lib/bridgetown-core/commands/base.rb +60 -1
- data/lib/bridgetown-core/commands/build.rb +26 -6
- data/lib/bridgetown-core/commands/concerns/build_options.rb +3 -10
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +3 -1
- data/lib/bridgetown-core/commands/doctor.rb +3 -3
- data/lib/bridgetown-core/commands/new.rb +9 -3
- data/lib/bridgetown-core/commands/plugins.rb +1 -2
- data/lib/bridgetown-core/commands/serve.rb +14 -12
- data/lib/bridgetown-core/commands/start.rb +106 -0
- data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +2 -2
- data/lib/bridgetown-core/concerns/site/configurable.rb +0 -12
- data/lib/bridgetown-core/concerns/site/content.rb +6 -117
- data/lib/bridgetown-core/concerns/site/localizable.rb +3 -1
- data/lib/bridgetown-core/concerns/site/processable.rb +8 -20
- data/lib/bridgetown-core/concerns/site/renderable.rb +19 -30
- data/lib/bridgetown-core/concerns/site/ssr.rb +53 -0
- data/lib/bridgetown-core/concerns/site/writable.rb +5 -8
- data/lib/bridgetown-core/configuration.rb +18 -47
- data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
- data/lib/bridgetown-core/configurations/turbo.rb +1 -1
- data/lib/bridgetown-core/converters/erb_templates.rb +2 -1
- data/lib/bridgetown-core/converters/liquid_templates.rb +3 -2
- data/lib/bridgetown-core/current.rb +4 -0
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/generated_page_drop.rb +23 -0
- data/lib/bridgetown-core/drops/resource_drop.rb +3 -3
- data/lib/bridgetown-core/drops/site_drop.rb +3 -47
- data/lib/bridgetown-core/filters/url_filters.rb +3 -1
- data/lib/bridgetown-core/frontmatter_defaults.rb +44 -80
- data/lib/bridgetown-core/{page.rb → generated_page.rb} +34 -58
- data/lib/bridgetown-core/generators/prototype_generator.rb +10 -21
- data/lib/bridgetown-core/helpers.rb +7 -2
- data/lib/bridgetown-core/layout.rb +15 -4
- data/lib/bridgetown-core/log_writer.rb +6 -0
- data/lib/bridgetown-core/model/base.rb +10 -2
- data/lib/bridgetown-core/model/builder_origin.rb +22 -10
- data/lib/bridgetown-core/model/origin.rb +3 -0
- data/lib/bridgetown-core/model/plugin_origin.rb +34 -0
- data/lib/bridgetown-core/model/repo_origin.rb +1 -1
- data/lib/bridgetown-core/plugin_manager.rb +0 -2
- data/lib/bridgetown-core/rack/boot.rb +47 -0
- data/lib/bridgetown-core/rack/logger.rb +22 -0
- data/lib/bridgetown-core/rack/roda.rb +66 -0
- data/lib/bridgetown-core/rack/routes.rb +92 -0
- data/lib/bridgetown-core/rack/static_indexes.rb +30 -0
- data/lib/bridgetown-core/reader.rb +16 -48
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +8 -7
- data/lib/bridgetown-core/renderer.rb +1 -11
- data/lib/bridgetown-core/resource/base.rb +33 -10
- data/lib/bridgetown-core/resource/permalink_processor.rb +20 -10
- data/lib/bridgetown-core/resource/relations.rb +2 -3
- data/lib/bridgetown-core/resource/transformer.rb +1 -1
- data/lib/bridgetown-core/ruby_template_view.rb +5 -5
- data/lib/bridgetown-core/site.rb +4 -8
- data/lib/bridgetown-core/static_file.rb +10 -15
- data/lib/bridgetown-core/tags/include.rb +0 -13
- data/lib/bridgetown-core/tags/link.rb +4 -0
- data/lib/bridgetown-core/tags/live_reload_dev_js.rb +13 -0
- data/lib/bridgetown-core/tags/post_url.rb +4 -9
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +54 -0
- data/lib/bridgetown-core/url.rb +2 -1
- data/lib/bridgetown-core/utils/aux.rb +57 -0
- data/lib/bridgetown-core/utils/ruby_exec.rb +3 -45
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +22 -7
- data/lib/bridgetown-core/utils.rb +37 -2
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +2 -4
- data/lib/bridgetown-core.rb +14 -22
- data/lib/site_template/Gemfile.erb +6 -2
- data/lib/site_template/README.md +6 -6
- data/lib/site_template/Rakefile +49 -0
- data/lib/site_template/bridgetown.config.yml +2 -3
- data/lib/site_template/config/puma.rb +27 -0
- data/lib/site_template/config.ru +7 -0
- data/lib/site_template/package.json.erb +1 -9
- data/lib/site_template/server/roda_app.rb +22 -0
- data/lib/site_template/server/routes/hello.rb.sample +10 -0
- data/lib/site_template/src/_components/head.liquid +2 -1
- data/lib/site_template/src/about.md +0 -1
- data/lib/site_template/src/posts.md +2 -3
- metadata +62 -18
- data/lib/bridgetown-core/concerns/data_accessible.rb +0 -20
- data/lib/bridgetown-core/concerns/validatable.rb +0 -56
- data/lib/bridgetown-core/document.rb +0 -437
- data/lib/bridgetown-core/drops/document_drop.rb +0 -80
- data/lib/bridgetown-core/drops/excerpt_drop.rb +0 -19
- data/lib/bridgetown-core/drops/page_drop.rb +0 -18
- data/lib/bridgetown-core/excerpt.rb +0 -200
- data/lib/bridgetown-core/readers/data_reader.rb +0 -89
- data/lib/bridgetown-core/readers/page_reader.rb +0 -26
- data/lib/bridgetown-core/readers/post_reader.rb +0 -109
- data/lib/bridgetown-core/regenerator.rb +0 -202
- data/lib/bridgetown-core/related_posts.rb +0 -55
- data/lib/site_template/config/.keep +0 -0
- data/lib/site_template/start.js +0 -17
- data/lib/site_template/sync.js +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 835cfe03f425b73a33a5086c3d36a343c81bad231d31bf01049a4f7dd0d6cea5
|
4
|
+
data.tar.gz: 9c9a1a226a5ec9f40ad74203d8b692c4d4c126b3e35ab672893f69bea71dc79b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad5c876760ccc74c3662b989e682e7aa774fa91fb55e616ecc88d9237b37fede1edb0b5e2a48eccb9d9ecf5880cef46d5c8357ec4fb8550f4cad48c88c4b66b7
|
7
|
+
data.tar.gz: fa62ec5bbb0b5a121a1f0d0d68e11a562dba1a6714539c1a29802994722b9c783722313bc43248b99b75f87e979d9d74a7e84a40e11da567e9555dd3ae4b295c
|
data/bin/bridgetown
CHANGED
data/bridgetown-core.gemspec
CHANGED
@@ -46,6 +46,9 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_runtime_dependency("liquid", "~> 5.0")
|
47
47
|
s.add_runtime_dependency("liquid-component", ">= 0.1")
|
48
48
|
s.add_runtime_dependency("listen", "~> 3.0")
|
49
|
+
s.add_runtime_dependency("rack-indifferent", ">= 1.2.0")
|
50
|
+
s.add_runtime_dependency("rake", ">= 13.0")
|
51
|
+
s.add_runtime_dependency("roda", "~> 3.46")
|
49
52
|
s.add_runtime_dependency("rouge", "~> 3.0")
|
50
53
|
s.add_runtime_dependency("terminal-table", "~> 1.8")
|
51
54
|
s.add_runtime_dependency("thor", "~> 1.1")
|
@@ -13,7 +13,6 @@ module Bridgetown
|
|
13
13
|
# Cleans up the site's destination directory
|
14
14
|
def cleanup!
|
15
15
|
FileUtils.rm_rf(obsolete_files)
|
16
|
-
FileUtils.rm_rf(metadata_file) unless @site.incremental?
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
@@ -28,13 +27,6 @@ module Bridgetown
|
|
28
27
|
out
|
29
28
|
end
|
30
29
|
|
31
|
-
# Private: The metadata file storing dependency tree and build history
|
32
|
-
#
|
33
|
-
# Returns an Array with the metdata file as the only item
|
34
|
-
def metadata_file
|
35
|
-
[site.regenerator.metadata_file]
|
36
|
-
end
|
37
|
-
|
38
30
|
# Private: The list of existing files, apart from those included in
|
39
31
|
# keep_files and hidden files.
|
40
32
|
#
|
@@ -6,7 +6,6 @@ module Bridgetown
|
|
6
6
|
attr_reader :site
|
7
7
|
|
8
8
|
attr_reader :label, :metadata
|
9
|
-
attr_writer :docs
|
10
9
|
|
11
10
|
attr_writer :resources
|
12
11
|
|
@@ -24,22 +23,10 @@ module Bridgetown
|
|
24
23
|
label.in? %w(posts pages data).freeze
|
25
24
|
end
|
26
25
|
|
27
|
-
def legacy_reader?
|
28
|
-
label.in? %w(posts data).freeze
|
29
|
-
end
|
30
|
-
|
31
26
|
def data?
|
32
27
|
label == "data"
|
33
28
|
end
|
34
29
|
|
35
|
-
# Fetch the Documents in this collection.
|
36
|
-
# Defaults to an empty array if no documents have been read in.
|
37
|
-
#
|
38
|
-
# @return [Array<Bridgetown::Document>]
|
39
|
-
def docs
|
40
|
-
@docs ||= []
|
41
|
-
end
|
42
|
-
|
43
30
|
# Fetch the Resources in this collection.
|
44
31
|
# Defaults to an empty array if no resources have been read in.
|
45
32
|
#
|
@@ -48,10 +35,23 @@ module Bridgetown
|
|
48
35
|
@resources ||= []
|
49
36
|
end
|
50
37
|
|
51
|
-
#
|
52
|
-
#
|
38
|
+
# Fetch the collection resources and arrange them by slug in a hash.
|
39
|
+
#
|
40
|
+
# @return [Hash<String, Bridgetown::Resource::Base>]
|
41
|
+
def resources_by_slug
|
42
|
+
resources.group_by { |item| item.data.slug }.transform_values(&:first)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Fetch the collection resources and arrange them by relative URL in a hash.
|
46
|
+
#
|
47
|
+
# @return [Hash<String, Bridgetown::Resource::Base>]
|
48
|
+
def resources_by_relative_url
|
49
|
+
resources.group_by(&:relative_url).transform_values(&:first)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Iterate over Resources
|
53
53
|
def each(&block)
|
54
|
-
|
54
|
+
resources.each(&block)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Fetch the static files in this collection.
|
@@ -67,38 +67,32 @@ module Bridgetown
|
|
67
67
|
static_files
|
68
68
|
end
|
69
69
|
|
70
|
-
# Read the allowed
|
70
|
+
# Read the allowed resources into the collection's array of resources.
|
71
71
|
#
|
72
72
|
# @return [Bridgetown::Collection] self
|
73
|
-
def read
|
73
|
+
def read
|
74
74
|
filtered_entries.each do |file_path|
|
75
75
|
full_path = collection_dir(file_path)
|
76
76
|
next if File.directory?(full_path)
|
77
77
|
|
78
|
-
if
|
79
|
-
next if File.basename(file_path).starts_with?("_")
|
78
|
+
next if File.basename(file_path).starts_with?("_")
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
read_static_file(file_path, full_path)
|
86
|
-
end
|
87
|
-
elsif Utils.has_yaml_header? full_path
|
88
|
-
read_document(full_path)
|
80
|
+
if label == "data" || Utils.has_yaml_header?(full_path) ||
|
81
|
+
Utils.has_rbfm_header?(full_path)
|
82
|
+
read_resource(full_path)
|
89
83
|
else
|
90
84
|
read_static_file(file_path, full_path)
|
91
85
|
end
|
92
86
|
end
|
93
87
|
site.static_files.concat(static_files)
|
94
|
-
|
88
|
+
sort_resources!
|
95
89
|
|
96
90
|
self
|
97
91
|
end
|
98
92
|
|
99
93
|
# All the entries in this collection.
|
100
94
|
#
|
101
|
-
# @return [Array<String>] file paths to the
|
95
|
+
# @return [Array<String>] file paths to the resources in this collection
|
102
96
|
# relative to the collection's folder
|
103
97
|
def entries
|
104
98
|
return [] unless exists?
|
@@ -178,7 +172,7 @@ module Bridgetown
|
|
178
172
|
@entry_filter ||= Bridgetown::EntryFilter.new(
|
179
173
|
site,
|
180
174
|
base_directory: folder_name,
|
181
|
-
include_underscores:
|
175
|
+
include_underscores: true
|
182
176
|
)
|
183
177
|
end
|
184
178
|
|
@@ -186,7 +180,7 @@ module Bridgetown
|
|
186
180
|
#
|
187
181
|
# @return [String]
|
188
182
|
def inspect
|
189
|
-
"#<#{self.class} @label=#{label}
|
183
|
+
"#<#{self.class} @label=#{label} resources=#{resources}>"
|
190
184
|
end
|
191
185
|
|
192
186
|
# Produce a sanitized label name
|
@@ -202,7 +196,7 @@ module Bridgetown
|
|
202
196
|
# Produce a representation of this Collection for use in Liquid.
|
203
197
|
# Exposes two attributes:
|
204
198
|
# - label
|
205
|
-
# -
|
199
|
+
# - resources
|
206
200
|
#
|
207
201
|
# @return [Bridgetown::Drops::CollectionDrop] representation of this
|
208
202
|
# collection for use in Liquid
|
@@ -210,7 +204,7 @@ module Bridgetown
|
|
210
204
|
Drops::CollectionDrop.new self
|
211
205
|
end
|
212
206
|
|
213
|
-
# Whether the collection's
|
207
|
+
# Whether the collection's resources ought to be written as individual
|
214
208
|
# files in the output.
|
215
209
|
#
|
216
210
|
# @return [Boolean] true if the 'write' metadata is true, false otherwise.
|
@@ -226,15 +220,6 @@ module Bridgetown
|
|
226
220
|
end
|
227
221
|
end
|
228
222
|
|
229
|
-
# LEGACY: The URL template to render collection's documents at.
|
230
|
-
#
|
231
|
-
# @return [String]
|
232
|
-
def url_template
|
233
|
-
@url_template ||= metadata.fetch("permalink") do
|
234
|
-
Utils.add_permalink_suffix("/:collection/:path", site.permalink_style)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
223
|
# Extract options for this collection from the site configuration.
|
239
224
|
#
|
240
225
|
# @return [HashWithDotAccess::Hash]
|
@@ -287,11 +272,30 @@ module Bridgetown
|
|
287
272
|
|
288
273
|
# Read in resource from repo path
|
289
274
|
# @param full_path [String]
|
290
|
-
def read_resource(full_path)
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
275
|
+
def read_resource(full_path, manifest: nil) # rubocop:todo Metrics/AbcSize
|
276
|
+
scheme = manifest ? "plugin" : "repo"
|
277
|
+
id = +"#{scheme}://#{label}.collection/"
|
278
|
+
id += "#{manifest.origin}/" if manifest
|
279
|
+
id += Addressable::URI.escape(
|
280
|
+
Pathname(full_path).relative_path_from(
|
281
|
+
manifest ? Pathname(manifest.content) : Pathname(site.source)
|
282
|
+
).to_s
|
283
|
+
).gsub("#", "%23")
|
284
|
+
model = Bridgetown::Model::Base.find(id)
|
285
|
+
|
286
|
+
if model.attributes.key?(:locale) && model.locale.to_sym == :multi
|
287
|
+
site.config.available_locales.each do |locale|
|
288
|
+
model.locale = locale
|
289
|
+
add_model_resource model
|
290
|
+
end
|
291
|
+
return
|
292
|
+
end
|
293
|
+
|
294
|
+
add_model_resource model
|
295
|
+
end
|
296
|
+
|
297
|
+
def add_model_resource(model)
|
298
|
+
resource = model.to_resource.read!
|
295
299
|
resources << resource if site.config.unpublished || resource.published?
|
296
300
|
end
|
297
301
|
|
@@ -301,50 +305,24 @@ module Bridgetown
|
|
301
305
|
@container ||= site.config["collections_dir"]
|
302
306
|
end
|
303
307
|
|
304
|
-
def
|
305
|
-
doc = Document.new(full_path, site: site, collection: self).tap(&:read)
|
306
|
-
docs << doc if site.config.unpublished || doc.published?
|
307
|
-
end
|
308
|
-
|
309
|
-
def sort_docs!
|
308
|
+
def sort_resources!
|
310
309
|
if metadata["sort_by"].is_a?(String)
|
311
|
-
sort_docs_by_key!
|
312
310
|
sort_resources_by_key!
|
313
311
|
else
|
314
|
-
docs.sort!
|
315
312
|
resources.sort!
|
316
313
|
end
|
317
|
-
docs.reverse! if metadata.sort_direction == "descending"
|
318
314
|
resources.reverse! if metadata.sort_direction == "descending"
|
319
315
|
end
|
320
316
|
|
321
317
|
# A custom sort function based on Schwartzian transform
|
322
318
|
# Refer https://byparker.com/blog/2017/schwartzian-transform-faster-sorting/ for details
|
323
|
-
def sort_docs_by_key!
|
324
|
-
meta_key = metadata["sort_by"]
|
325
|
-
# Modify `docs` array to cache document's property along with the Document instance
|
326
|
-
docs.map! { |doc| [doc.data[meta_key], doc] }.sort! do |apples, olives|
|
327
|
-
order = determine_sort_order(meta_key, apples, olives)
|
328
|
-
|
329
|
-
# Fall back to `Document#<=>` if the properties were equal or were non-sortable
|
330
|
-
# Otherwise continue with current sort-order
|
331
|
-
if order.nil? || order.zero?
|
332
|
-
apples[-1] <=> olives[-1]
|
333
|
-
else
|
334
|
-
order
|
335
|
-
end
|
336
|
-
|
337
|
-
# Finally restore the `docs` array with just the Document objects themselves
|
338
|
-
end.map!(&:last)
|
339
|
-
end
|
340
|
-
|
341
319
|
def sort_resources_by_key!
|
342
320
|
meta_key = metadata["sort_by"]
|
343
|
-
# Modify
|
344
|
-
resources.map! { |
|
321
|
+
# Modify array to cache property along with the Resource instance
|
322
|
+
resources.map! { |r| [r.data[meta_key], r] }.sort! do |apples, olives|
|
345
323
|
order = determine_sort_order(meta_key, apples, olives)
|
346
324
|
|
347
|
-
# Fall back to `
|
325
|
+
# Fall back to `Resource::Base#<=>` if the properties were equal or were non-sortable
|
348
326
|
# Otherwise continue with current sort-order
|
349
327
|
if order.nil? || order.zero?
|
350
328
|
apples[-1] <=> olives[-1]
|
@@ -352,7 +330,7 @@ module Bridgetown
|
|
352
330
|
order
|
353
331
|
end
|
354
332
|
|
355
|
-
# Finally restore the `
|
333
|
+
# Finally restore the `resources` array with just the objects themselves
|
356
334
|
end.map!(&:last)
|
357
335
|
end
|
358
336
|
|
@@ -369,9 +347,9 @@ module Bridgetown
|
|
369
347
|
end
|
370
348
|
end
|
371
349
|
|
372
|
-
def order_with_warning(sort_key,
|
350
|
+
def order_with_warning(sort_key, resource, order)
|
373
351
|
Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in" \
|
374
|
-
" #{
|
352
|
+
" #{resource.relative_path}"
|
375
353
|
order
|
376
354
|
end
|
377
355
|
|
@@ -19,11 +19,55 @@ module Bridgetown
|
|
19
19
|
def find_command_possibilities(subcommand)
|
20
20
|
if subcommand == "c"
|
21
21
|
["console"]
|
22
|
+
elsif subcommand == "s"
|
23
|
+
["start"]
|
22
24
|
else
|
23
25
|
super
|
24
26
|
end
|
25
27
|
end
|
28
|
+
|
29
|
+
def display_rake_tasks(rake)
|
30
|
+
rake.options.show_all_tasks = true
|
31
|
+
rake.options.show_task_pattern = Regexp.new("")
|
32
|
+
rake.options.show_tasks = :tasks
|
33
|
+
rake.display_tasks_and_comments
|
34
|
+
end
|
35
|
+
|
36
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Style/GlobalVars
|
37
|
+
def handle_no_command_error(cmd, _has_namespace = $thor_runner)
|
38
|
+
require "rake"
|
39
|
+
Rake::TaskManager.record_task_metadata = true
|
40
|
+
|
41
|
+
Rake.with_application do |rake|
|
42
|
+
rake.instance_variable_set(:@name, "bridgetown")
|
43
|
+
rake.standard_exception_handling do
|
44
|
+
rakefile, _location = rake.find_rakefile_location
|
45
|
+
unless rakefile
|
46
|
+
puts "No Rakefile found (searching: #{rake.class::DEFAULT_RAKEFILES.join(", ")})\n"
|
47
|
+
new.invoke("help")
|
48
|
+
return # rubocop:disable Lint/NonLocalExitFromIterator
|
49
|
+
end
|
50
|
+
rake.load_rakefile
|
51
|
+
rake.top_level
|
52
|
+
end
|
53
|
+
cmd = cmd.split("[")
|
54
|
+
args = []
|
55
|
+
if cmd[1]
|
56
|
+
args = cmd[1].gsub('\,', "__COMMA__").delete_suffix!("]").split(",").map do |item|
|
57
|
+
item.gsub("__COMMA__", ",")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if Rake::Task.task_defined?(cmd[0])
|
62
|
+
Rake::Task[cmd[0]].invoke(*args)
|
63
|
+
else
|
64
|
+
puts "Unknown task: #{cmd[0]}\n\nHere's a list of tasks you can run:"
|
65
|
+
display_rake_tasks(rake)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
26
69
|
end
|
70
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Style/GlobalVars
|
27
71
|
|
28
72
|
desc "dream", "There's a place where that idea still exists as a reality"
|
29
73
|
def dream
|
@@ -35,7 +79,7 @@ module Bridgetown
|
|
35
79
|
end
|
36
80
|
|
37
81
|
desc "help <command>", "Show detailed command usage information and exit"
|
38
|
-
def help(subcommand = nil)
|
82
|
+
def help(subcommand = nil) # rubocop:disable Metrics/MethodLength
|
39
83
|
if subcommand && respond_to?(subcommand)
|
40
84
|
klass = Kernel.const_get("Bridgetown::Commands::#{subcommand.capitalize}")
|
41
85
|
klass.start(["-h"])
|
@@ -47,6 +91,21 @@ module Bridgetown
|
|
47
91
|
puts " bridgetown <command> [options]"
|
48
92
|
puts ""
|
49
93
|
super
|
94
|
+
|
95
|
+
require "rake"
|
96
|
+
Rake::TaskManager.record_task_metadata = true
|
97
|
+
Rake.with_application do |rake|
|
98
|
+
rake.instance_variable_set(:@name, " bridgetown")
|
99
|
+
rake.standard_exception_handling do
|
100
|
+
rakefile, _location = rake.find_rakefile_location
|
101
|
+
return unless rakefile # rubocop:disable Lint/NonLocalExitFromIterator
|
102
|
+
|
103
|
+
rake.load_rakefile
|
104
|
+
rake.top_level
|
105
|
+
puts "Available Rake Tasks:"
|
106
|
+
self.class.display_rake_tasks(rake)
|
107
|
+
end
|
108
|
+
end
|
50
109
|
end
|
51
110
|
end
|
52
111
|
end
|
@@ -21,15 +21,26 @@ module Bridgetown
|
|
21
21
|
aliases: "-w",
|
22
22
|
desc: "Watch for changes and rebuild"
|
23
23
|
|
24
|
+
def self.print_startup_message
|
25
|
+
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
26
|
+
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
|
27
|
+
end
|
28
|
+
|
24
29
|
# Build your bridgetown site
|
25
30
|
# Continuously watch if `watch` is set to true in the config.
|
26
31
|
def build
|
27
32
|
Bridgetown.logger.adjust_verbosity(options)
|
28
33
|
|
29
|
-
|
30
|
-
|
34
|
+
unless caller_locations.find do |loc|
|
35
|
+
loc.to_s.include?("bridgetown-core/commands/start.rb")
|
36
|
+
end
|
37
|
+
self.class.print_startup_message
|
38
|
+
end
|
39
|
+
|
40
|
+
config_options = (
|
41
|
+
Bridgetown::Current.preloaded_configuration || configuration_with_overrides(options)
|
42
|
+
).merge(options)
|
31
43
|
|
32
|
-
config_options = Serve.loaded_config || configuration_with_overrides(options)
|
33
44
|
config_options["serving"] = false unless config_options["serving"]
|
34
45
|
@site = Bridgetown::Site.new(config_options)
|
35
46
|
|
@@ -64,13 +75,22 @@ module Bridgetown
|
|
64
75
|
Bridgetown.logger.info "Unpublished mode:",
|
65
76
|
"enabled. Processing documents marked unpublished"
|
66
77
|
end
|
67
|
-
incremental = config_options["incremental"]
|
68
|
-
Bridgetown.logger.info "Incremental build:",
|
69
|
-
(incremental ? "enabled" : "disabled. Enable with --incremental")
|
70
78
|
Bridgetown.logger.info "Generating…"
|
71
79
|
@site.process
|
72
80
|
Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
|
73
81
|
" #{(Time.now - t).ceil(2)} seconds."
|
82
|
+
if config_options[:using_puma]
|
83
|
+
require "socket"
|
84
|
+
external_ip = Socket.ip_address_list.find do |ai|
|
85
|
+
ai.ipv4? && !ai.ipv4_loopback?
|
86
|
+
end&.ip_address
|
87
|
+
scheme = config_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
88
|
+
port = config_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
89
|
+
Bridgetown.logger.info ""
|
90
|
+
Bridgetown.logger.info "Now serving at:", "#{scheme}://localhost:#{port}".magenta
|
91
|
+
Bridgetown.logger.info "", "#{scheme}://#{external_ip}:#{port}".magenta if external_ip
|
92
|
+
Bridgetown.logger.info ""
|
93
|
+
end
|
74
94
|
end
|
75
95
|
|
76
96
|
# Watch for file changes and rebuild the site.
|
@@ -33,18 +33,15 @@ module Bridgetown
|
|
33
33
|
klass.class_option :future,
|
34
34
|
type: :boolean,
|
35
35
|
desc: "Publishes posts with a future date"
|
36
|
-
klass.class_option :
|
37
|
-
|
38
|
-
desc: "
|
36
|
+
klass.class_option :url,
|
37
|
+
aliases: "-u",
|
38
|
+
desc: "Override the configured url for the website"
|
39
39
|
klass.class_option :base_path,
|
40
40
|
aliases: "-b",
|
41
41
|
desc: "Serve the website from the given base path"
|
42
42
|
klass.class_option :force_polling,
|
43
43
|
type: :boolean,
|
44
44
|
desc: "Force watch to use polling"
|
45
|
-
klass.class_option :lsi,
|
46
|
-
type: :boolean,
|
47
|
-
desc: "Use LSI for improved related posts"
|
48
45
|
klass.class_option :unpublished,
|
49
46
|
type: :boolean,
|
50
47
|
aliases: "-U",
|
@@ -63,10 +60,6 @@ module Bridgetown
|
|
63
60
|
aliases: "-V",
|
64
61
|
type: :boolean,
|
65
62
|
desc: "Print verbose output."
|
66
|
-
klass.class_option :incremental,
|
67
|
-
aliases: "-I",
|
68
|
-
type: :boolean,
|
69
|
-
desc: "Enable incremental rebuild."
|
70
63
|
klass.class_option :strict_front_matter,
|
71
64
|
type: :boolean,
|
72
65
|
desc: "Fail if errors are present in front matter"
|
@@ -11,7 +11,9 @@ module Bridgetown
|
|
11
11
|
def configuration_with_overrides(options)
|
12
12
|
return options if options.is_a?(Bridgetown::Configuration)
|
13
13
|
|
14
|
-
Bridgetown.configuration(options)
|
14
|
+
Bridgetown.configuration(options).tap do |new_config|
|
15
|
+
Bridgetown::Current.preloaded_configuration = new_config
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -71,7 +71,7 @@ module Bridgetown
|
|
71
71
|
|
72
72
|
def urls_only_differ_by_case(site)
|
73
73
|
urls_only_differ_by_case = false
|
74
|
-
urls = case_insensitive_urls(site.
|
74
|
+
urls = case_insensitive_urls(site.resources, site.dest)
|
75
75
|
urls.each_value do |real_urls|
|
76
76
|
next unless real_urls.uniq.size > 1
|
77
77
|
|
@@ -106,9 +106,9 @@ module Bridgetown
|
|
106
106
|
urls
|
107
107
|
end
|
108
108
|
|
109
|
-
def case_insensitive_urls(things,
|
109
|
+
def case_insensitive_urls(things, _destination)
|
110
110
|
things.each_with_object({}) do |thing, memo|
|
111
|
-
dest = thing.destination
|
111
|
+
dest = thing.destination.output_path
|
112
112
|
(memo[dest.downcase] ||= []) << dest
|
113
113
|
end
|
114
114
|
end
|
@@ -119,7 +119,7 @@ module Bridgetown
|
|
119
119
|
invoke(Configure, options[:configure].split(","), {}) if options[:configure]
|
120
120
|
|
121
121
|
logger = Bridgetown.logger
|
122
|
-
|
122
|
+
bt_start = "bin/bridgetown start"
|
123
123
|
logger.info ""
|
124
124
|
logger.info "Success!".green, "🎉 Your new Bridgetown site was" \
|
125
125
|
" generated in #{cli_path.cyan}."
|
@@ -128,12 +128,17 @@ module Bridgetown
|
|
128
128
|
logger.info "You'll probably also want to #{"yarn install".cyan}" \
|
129
129
|
" to load in your frontend assets."
|
130
130
|
else
|
131
|
-
logger.info "You can now #{"cd".cyan} and run #{
|
131
|
+
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan}" \
|
132
|
+
" to get started."
|
132
133
|
end
|
133
134
|
logger.info "Then check out our online documentation for" \
|
134
135
|
" next steps: #{DOCSURL.cyan}"
|
135
136
|
|
136
|
-
|
137
|
+
if @skipped_bundle
|
138
|
+
logger.info "Bundle install skipped.".yellow
|
139
|
+
logger.info "You will need to run #{"bundle binstub bridgetown-core".cyan} manually."
|
140
|
+
end
|
141
|
+
|
137
142
|
logger.info "Yarn install skipped.".yellow if @skipped_yarn
|
138
143
|
end
|
139
144
|
# rubocop:enable Metrics/CyclomaticComplexity
|
@@ -145,6 +150,7 @@ module Bridgetown
|
|
145
150
|
Bridgetown.with_unbundled_env do
|
146
151
|
inside(path) do
|
147
152
|
run "bundle install", abort_on_failure: true
|
153
|
+
run "bundle binstub bridgetown-core"
|
148
154
|
end
|
149
155
|
end
|
150
156
|
end
|
@@ -145,8 +145,7 @@ module Bridgetown
|
|
145
145
|
name = folder_name.dasherize
|
146
146
|
module_name = folder_name.camelize
|
147
147
|
|
148
|
-
|
149
|
-
run "git clone -b switch-to-minitest https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
148
|
+
run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
150
149
|
new_gemspec = "#{name}.gemspec"
|
151
150
|
|
152
151
|
inside name do # rubocop:todo Metrics/BlockLength
|
@@ -34,11 +34,7 @@ module Bridgetown
|
|
34
34
|
def self.banner
|
35
35
|
"bridgetown serve [options]"
|
36
36
|
end
|
37
|
-
summary "Serve your site locally using WEBrick"
|
38
|
-
|
39
|
-
class << self
|
40
|
-
attr_accessor :loaded_config
|
41
|
-
end
|
37
|
+
summary "DEPRECATED (Serve your site locally using WEBrick)"
|
42
38
|
|
43
39
|
DIRECTORY_INDEX = %w(
|
44
40
|
index.htm
|
@@ -52,6 +48,9 @@ module Bridgetown
|
|
52
48
|
).freeze
|
53
49
|
|
54
50
|
def serve
|
51
|
+
Bridgetown::Deprecator.deprecation_message "The serve command will be " \
|
52
|
+
"removed in favor of using Puma in the next major release of Bridgetown"
|
53
|
+
|
55
54
|
@mutex = Mutex.new
|
56
55
|
@run_cond = ConditionVariable.new
|
57
56
|
@running = false
|
@@ -63,10 +62,13 @@ module Bridgetown
|
|
63
62
|
options["serving"] = true
|
64
63
|
options["watch"] = true unless no_watch
|
65
64
|
|
66
|
-
|
67
|
-
|
65
|
+
config = Bridgetown::Current.preloaded_configuration ||
|
66
|
+
configuration_with_overrides(options)
|
68
67
|
if Bridgetown.environment == "development"
|
69
|
-
|
68
|
+
default_url(config).tap do |url|
|
69
|
+
options["url"] = url
|
70
|
+
config.url = url
|
71
|
+
end
|
70
72
|
end
|
71
73
|
|
72
74
|
invoke(Build, [], options)
|
@@ -76,11 +78,10 @@ module Bridgetown
|
|
76
78
|
protected
|
77
79
|
|
78
80
|
def start_server
|
79
|
-
|
80
|
-
destination = config["destination"]
|
81
|
+
destination = Bridgetown::Current.preloaded_configuration.destination
|
81
82
|
setup(destination)
|
82
83
|
|
83
|
-
start_up_webrick(
|
84
|
+
start_up_webrick(destination)
|
84
85
|
end
|
85
86
|
|
86
87
|
def setup(destination)
|
@@ -117,7 +118,8 @@ module Bridgetown
|
|
117
118
|
opts
|
118
119
|
end
|
119
120
|
|
120
|
-
def start_up_webrick(
|
121
|
+
def start_up_webrick(destination)
|
122
|
+
opts = Bridgetown::Current.preloaded_configuration
|
121
123
|
@server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
|
122
124
|
@server.mount(opts["base_path"].to_s, Servlet, destination, file_handler_opts)
|
123
125
|
|