bridgetown-core 0.21.4 → 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 +8 -8
- 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
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Utils
|
5
|
+
module Aux
|
6
|
+
def self.with_color(name, message)
|
7
|
+
return message unless !name.nil? && Bridgetown::Utils::Ansi::COLORS[name.to_sym]
|
8
|
+
|
9
|
+
Bridgetown::Utils::Ansi.send(name, message)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.running_pids
|
13
|
+
@running_pids ||= []
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.add_pid(pid)
|
17
|
+
running_pids << pid
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.run_process(name, color, cmd)
|
21
|
+
Thread.new do
|
22
|
+
rd, wr = IO.pipe("BINARY")
|
23
|
+
pid = Process.spawn(cmd, out: wr, err: wr, pgroup: true)
|
24
|
+
@mutex.synchronize do
|
25
|
+
add_pid pid
|
26
|
+
end
|
27
|
+
|
28
|
+
loop do
|
29
|
+
line = rd.gets
|
30
|
+
line.to_s.lines.map(&:chomp).each do |message|
|
31
|
+
output = +""
|
32
|
+
output << with_color(color, "[#{name}] ") if color
|
33
|
+
output << message
|
34
|
+
@mutex.synchronize do
|
35
|
+
$stdout.puts output
|
36
|
+
$stdout.flush
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.group(&block)
|
44
|
+
@mutex = Thread::Mutex.new
|
45
|
+
instance_exec(&block)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.kill_processes
|
49
|
+
Bridgetown.logger.info "Stopping auxiliary processes..."
|
50
|
+
running_pids.each do |pid|
|
51
|
+
Process.kill("SIGTERM", -Process.getpgid(pid))
|
52
|
+
rescue Errno::ESRCH, Errno::EPERM, Errno::ECHILD # rubocop:disable Lint/SuppressedException
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -3,10 +3,7 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
module Utils
|
5
5
|
module RubyExec
|
6
|
-
|
7
|
-
|
8
|
-
# TODO: Deprecate storing Ruby code in YAML, Rb, etc. and just use native Ruby Front Matter
|
9
|
-
def search_data_for_ruby_code(convertible, renderer) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
6
|
+
def self.search_data_for_ruby_code(convertible)
|
10
7
|
return if convertible.data.empty?
|
11
8
|
|
12
9
|
# Iterate using `keys` here so inline Ruby script can add new data keys
|
@@ -14,49 +11,10 @@ module Bridgetown
|
|
14
11
|
data_keys = convertible.data.keys
|
15
12
|
data_keys.each do |k|
|
16
13
|
v = convertible.data[k]
|
17
|
-
next unless v.is_a?(
|
18
|
-
|
19
|
-
if v.is_a?(Proc)
|
20
|
-
convertible.data[k] = convertible.instance_exec(&v)
|
21
|
-
elsif v.is_a?(Hash)
|
22
|
-
v.each do |nested_k, nested_v|
|
23
|
-
next unless nested_v.is_a?(Rb)
|
24
|
-
|
25
|
-
convertible.data[k][nested_k] = run(nested_v, convertible, renderer)
|
26
|
-
end
|
27
|
-
else
|
28
|
-
convertible.data[k] = run(v, convertible, renderer)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Sets up a new context in which to eval Ruby coming from front matter.
|
34
|
-
#
|
35
|
-
# ruby_code - a string of code
|
36
|
-
# convertible - the Document/Page/Layout with the Ruby front matter
|
37
|
-
# renderer - the Renderer instance that's processing the document (optional)
|
38
|
-
#
|
39
|
-
# Returns the transformed output of the code
|
40
|
-
def run(ruby_code, convertible, renderer)
|
41
|
-
return unless ruby_code.is_a?(Rb)
|
14
|
+
next unless v.is_a?(Proc)
|
42
15
|
|
43
|
-
|
44
|
-
obj = klass.new
|
45
|
-
|
46
|
-
if convertible.is_a?(Layout)
|
47
|
-
klass.attr_accessor :layout, :site, :data
|
48
|
-
obj.layout = convertible
|
49
|
-
else
|
50
|
-
klass.attr_accessor :document, :page, :renderer, :site, :data
|
51
|
-
obj.document = obj.page = convertible
|
52
|
-
obj.renderer = renderer
|
16
|
+
convertible.data[k] = convertible.instance_exec(&v)
|
53
17
|
end
|
54
|
-
obj.site = convertible.site
|
55
|
-
obj.data = convertible.data
|
56
|
-
|
57
|
-
# This is where the magic happens! DON'T BE EVIL!!! ;-)
|
58
|
-
output = obj.instance_eval(ruby_code)
|
59
|
-
output.is_a?(Hash) ? output.with_dot_access : output
|
60
18
|
end
|
61
19
|
end
|
62
20
|
end
|
@@ -3,20 +3,23 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
module Utils
|
5
5
|
module RubyFrontMatterDSL
|
6
|
-
def front_matter(&block)
|
7
|
-
RubyFrontMatter.new.tap { |fm| fm.instance_exec(&block) }
|
6
|
+
def front_matter(scope: nil, &block)
|
7
|
+
RubyFrontMatter.new(scope: scope).tap { |fm| fm.instance_exec(&block) }
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
class RubyFrontMatter
|
12
|
-
def initialize
|
12
|
+
def initialize(scope: nil)
|
13
13
|
@data = {}
|
14
|
+
@scope = scope
|
14
15
|
end
|
15
16
|
|
16
|
-
def method_missing(key, value) # rubocop:disable Style/MissingRespondToMissing
|
17
|
-
return super if respond_to?(key)
|
17
|
+
def method_missing(key, *value, &block) # rubocop:disable Metrics/CyclomaticComplexity, Style/MissingRespondToMissing
|
18
|
+
return super if respond_to?(key) || (value.length.zero? && block.nil? && !@data.key?(key))
|
18
19
|
|
19
|
-
|
20
|
+
return get(key) if value.length.zero? && block.nil? && @data.key?(key)
|
21
|
+
|
22
|
+
set(key, value[0], &block)
|
20
23
|
end
|
21
24
|
|
22
25
|
def each(&block)
|
@@ -27,7 +30,19 @@ module Bridgetown
|
|
27
30
|
@data[key]
|
28
31
|
end
|
29
32
|
|
30
|
-
def set(key, value)
|
33
|
+
def set(key, value = nil, &block)
|
34
|
+
# Handle nested data within a block
|
35
|
+
if block
|
36
|
+
value = self.class.new(scope: @scope).tap do |fm|
|
37
|
+
fm.instance_exec(&block)
|
38
|
+
end.to_h
|
39
|
+
end
|
40
|
+
|
41
|
+
# Execute lambda value within the resolver
|
42
|
+
if @scope && value.is_a?(Hash) && value[:from].is_a?(Proc)
|
43
|
+
value = @scope.instance_exec(&value[:from])
|
44
|
+
end
|
45
|
+
|
31
46
|
@data[key] = value
|
32
47
|
end
|
33
48
|
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Bridgetown
|
4
|
-
module Utils
|
4
|
+
module Utils # rubocop:todo Metrics/ModuleLength
|
5
5
|
extend self
|
6
6
|
autoload :Ansi, "bridgetown-core/utils/ansi"
|
7
|
+
autoload :Aux, "bridgetown-core/utils/aux"
|
7
8
|
autoload :RequireGems, "bridgetown-core/utils/require_gems"
|
8
9
|
autoload :RubyExec, "bridgetown-core/utils/ruby_exec"
|
10
|
+
autoload :RubyFrontMatter, "bridgetown-core/utils/ruby_front_matter"
|
9
11
|
autoload :RubyFrontMatterDSL, "bridgetown-core/utils/ruby_front_matter"
|
10
12
|
|
11
13
|
# Constants for use in #slugify
|
@@ -398,6 +400,39 @@ module Bridgetown
|
|
398
400
|
"master"
|
399
401
|
end
|
400
402
|
|
403
|
+
def live_reload_js(site) # rubocop:disable Metrics/MethodLength
|
404
|
+
return "" unless Bridgetown.env.development? && !site.config.skip_live_reload
|
405
|
+
|
406
|
+
code = <<~JAVASCRIPT
|
407
|
+
let first_mod = 0
|
408
|
+
let connection_errors = 0
|
409
|
+
const checkForReload = () => {
|
410
|
+
fetch("/_bridgetown/live_reload").then(response => {
|
411
|
+
if (response.ok) {
|
412
|
+
response.json().then(data => {
|
413
|
+
const last_mod = data.last_mod
|
414
|
+
if (first_mod === 0) {
|
415
|
+
first_mod = last_mod
|
416
|
+
} else if (last_mod > first_mod) {
|
417
|
+
location.reload()
|
418
|
+
}
|
419
|
+
setTimeout(() => checkForReload(), 700)
|
420
|
+
})
|
421
|
+
} else {
|
422
|
+
if (connection_errors < 20) setTimeout(() => checkForReload(), 6000)
|
423
|
+
connection_errors++
|
424
|
+
}
|
425
|
+
}).catch((err) => {
|
426
|
+
if (connection_errors < 20) setTimeout(() => checkForReload(), 6000)
|
427
|
+
connection_errors++
|
428
|
+
})
|
429
|
+
}
|
430
|
+
checkForReload()
|
431
|
+
JAVASCRIPT
|
432
|
+
|
433
|
+
%(<script type="module">#{code}</script>).html_safe
|
434
|
+
end
|
435
|
+
|
401
436
|
private
|
402
437
|
|
403
438
|
def merge_values(target, overwrite)
|
@@ -447,7 +482,7 @@ module Bridgetown
|
|
447
482
|
end
|
448
483
|
|
449
484
|
# Strip according to the mode
|
450
|
-
string.gsub(replaceable_char, "-")
|
485
|
+
string.to_s.gsub(replaceable_char, "-")
|
451
486
|
end
|
452
487
|
end
|
453
488
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "listen"
|
4
|
-
|
5
3
|
module Bridgetown
|
6
4
|
module Watcher
|
7
5
|
extend self
|
@@ -19,9 +17,9 @@ module Bridgetown
|
|
19
17
|
listener = build_listener(site, options)
|
20
18
|
listener.start
|
21
19
|
|
22
|
-
Bridgetown.logger.info "Auto-regeneration:", "enabled."
|
20
|
+
Bridgetown.logger.info "Auto-regeneration:", "enabled." unless options[:using_puma]
|
23
21
|
|
24
|
-
unless options[
|
22
|
+
unless options[:serving]
|
25
23
|
trap("INT") do
|
26
24
|
listener.stop
|
27
25
|
Bridgetown.logger.info "", "Halting auto-regeneration."
|
data/lib/bridgetown-core.rb
CHANGED
@@ -47,6 +47,7 @@ require "hash_with_dot_access"
|
|
47
47
|
require "addressable/uri"
|
48
48
|
require "liquid"
|
49
49
|
require "liquid-component"
|
50
|
+
require "listen"
|
50
51
|
require "kramdown"
|
51
52
|
require "colorator"
|
52
53
|
require "i18n"
|
@@ -66,53 +67,39 @@ end
|
|
66
67
|
class Rb < String; end
|
67
68
|
|
68
69
|
module Bridgetown
|
70
|
+
autoload :Cache, "bridgetown-core/cache"
|
71
|
+
autoload :Current, "bridgetown-core/current"
|
69
72
|
autoload :Cleaner, "bridgetown-core/cleaner"
|
70
73
|
autoload :Collection, "bridgetown-core/collection"
|
71
74
|
autoload :Component, "bridgetown-core/component"
|
72
75
|
autoload :Configuration, "bridgetown-core/configuration"
|
73
|
-
autoload :
|
76
|
+
autoload :DefaultsReader, "bridgetown-core/readers/defaults_reader"
|
74
77
|
autoload :Deprecator, "bridgetown-core/deprecator"
|
75
|
-
autoload :Document, "bridgetown-core/document"
|
76
78
|
autoload :EntryFilter, "bridgetown-core/entry_filter"
|
77
79
|
# TODO: we have too many errors! This is silly
|
78
80
|
autoload :Errors, "bridgetown-core/errors"
|
79
|
-
autoload :Excerpt, "bridgetown-core/excerpt"
|
80
81
|
autoload :FrontmatterDefaults, "bridgetown-core/frontmatter_defaults"
|
81
82
|
autoload :FrontMatterImporter, "bridgetown-core/concerns/front_matter_importer"
|
83
|
+
autoload :GeneratedPage, "bridgetown-core/generated_page"
|
82
84
|
autoload :Hooks, "bridgetown-core/hooks"
|
83
85
|
autoload :Layout, "bridgetown-core/layout"
|
84
86
|
autoload :LayoutPlaceable, "bridgetown-core/concerns/layout_placeable"
|
85
|
-
autoload :Cache, "bridgetown-core/cache"
|
86
|
-
autoload :Current, "bridgetown-core/current"
|
87
|
-
# TODO: remove this when legacy content engine is gone:
|
88
|
-
autoload :DataReader, "bridgetown-core/readers/data_reader"
|
89
|
-
autoload :DefaultsReader, "bridgetown-core/readers/defaults_reader"
|
90
87
|
autoload :LayoutReader, "bridgetown-core/readers/layout_reader"
|
91
|
-
|
92
|
-
autoload :
|
93
|
-
# TODO: remove this when legacy content engine is gone:
|
94
|
-
autoload :PageReader, "bridgetown-core/readers/page_reader"
|
95
|
-
autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
|
88
|
+
autoload :LiquidRenderable, "bridgetown-core/concerns/liquid_renderable"
|
89
|
+
autoload :LiquidRenderer, "bridgetown-core/liquid_renderer"
|
96
90
|
autoload :LogAdapter, "bridgetown-core/log_adapter"
|
97
|
-
autoload :
|
98
|
-
autoload :GeneratedPage, "bridgetown-core/page"
|
91
|
+
autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
|
99
92
|
autoload :PluginManager, "bridgetown-core/plugin_manager"
|
100
93
|
autoload :Publishable, "bridgetown-core/concerns/publishable"
|
101
94
|
autoload :Publisher, "bridgetown-core/publisher"
|
102
95
|
autoload :Reader, "bridgetown-core/reader"
|
103
|
-
# TODO: remove this when the incremental regenerator is gone:
|
104
|
-
autoload :Regenerator, "bridgetown-core/regenerator"
|
105
|
-
autoload :RelatedPosts, "bridgetown-core/related_posts"
|
106
96
|
autoload :Renderer, "bridgetown-core/renderer"
|
107
|
-
autoload :LiquidRenderable, "bridgetown-core/concerns/liquid_renderable"
|
108
|
-
autoload :LiquidRenderer, "bridgetown-core/liquid_renderer"
|
109
97
|
autoload :RubyTemplateView, "bridgetown-core/ruby_template_view"
|
110
98
|
autoload :LogWriter, "bridgetown-core/log_writer"
|
111
99
|
autoload :Site, "bridgetown-core/site"
|
112
100
|
autoload :StaticFile, "bridgetown-core/static_file"
|
113
101
|
autoload :URL, "bridgetown-core/url"
|
114
102
|
autoload :Utils, "bridgetown-core/utils"
|
115
|
-
autoload :Validatable, "bridgetown-core/concerns/validatable"
|
116
103
|
autoload :VERSION, "bridgetown-core/version"
|
117
104
|
autoload :Watcher, "bridgetown-core/watcher"
|
118
105
|
autoload :YAMLParser, "bridgetown-core/yaml_parser"
|
@@ -126,7 +113,6 @@ module Bridgetown
|
|
126
113
|
require "bridgetown-core/filters"
|
127
114
|
|
128
115
|
require "bridgetown-core/drops/drop"
|
129
|
-
require "bridgetown-core/drops/document_drop"
|
130
116
|
require "bridgetown-core/drops/resource_drop"
|
131
117
|
require_all "bridgetown-core/converters"
|
132
118
|
require_all "bridgetown-core/converters/markdown"
|
@@ -173,6 +159,12 @@ module Bridgetown
|
|
173
159
|
Bridgetown::Commands::Registrations.register(&block)
|
174
160
|
end
|
175
161
|
|
162
|
+
def load_tasks
|
163
|
+
require "bridgetown-core/commands/base"
|
164
|
+
Bridgetown::PluginManager.require_from_bundler
|
165
|
+
load File.expand_path("bridgetown-core/tasks/bridgetown_tasks.rake", __dir__)
|
166
|
+
end
|
167
|
+
|
176
168
|
# Determines the correct Bundler environment block method to use and passes
|
177
169
|
# the block on to it.
|
178
170
|
#
|
@@ -3,9 +3,9 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
3
3
|
|
4
4
|
# Hello! This is where you manage which Bridgetown version is used to run.
|
5
5
|
# When you want to use a different version, change it below, save the
|
6
|
-
# file and run `bundle install`. Run Bridgetown
|
6
|
+
# file and run `bundle install`. Run Bridgetown like so:
|
7
7
|
#
|
8
|
-
#
|
8
|
+
# bin/bridgetown start (or console, etc.)
|
9
9
|
#
|
10
10
|
# This will help ensure the proper Bridgetown version is running.
|
11
11
|
#
|
@@ -17,3 +17,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
17
17
|
# Happy Bridgetowning!
|
18
18
|
|
19
19
|
gem "bridgetown", "~> <%= Bridgetown::VERSION %>"
|
20
|
+
|
21
|
+
# Puma is a Rack-compatible server
|
22
|
+
# (you can optionally limit this to the "development" group)
|
23
|
+
gem "puma", "~> 5.2"
|
data/lib/site_template/README.md
CHANGED
@@ -18,9 +18,9 @@ Welcome to your new Bridgetown website! You can update this README file to provi
|
|
18
18
|
- [Ruby](https://www.ruby-lang.org/en/downloads/)
|
19
19
|
- `>= 2.5`
|
20
20
|
- [Bridgetown Gem](https://rubygems.org/gems/bridgetown)
|
21
|
-
- `gem install
|
21
|
+
- `gem install bridgetown -N`
|
22
22
|
- [Node](https://nodejs.org)
|
23
|
-
- `>=
|
23
|
+
- `>= 12`
|
24
24
|
- [Yarn](https://yarnpkg.com)
|
25
25
|
|
26
26
|
## Install
|
@@ -33,7 +33,7 @@ bundle install && yarn install
|
|
33
33
|
|
34
34
|
## Development
|
35
35
|
|
36
|
-
To start your site in development mode, run `
|
36
|
+
To start your site in development mode, run `bin/bridgetown start` and navigate to [localhost:4000](https://localhost:4000/)!
|
37
37
|
|
38
38
|
Use a [theme](https://github.com/topics/bridgetown-theme), add some [plugins](https://www.bridgetownrb.com/plugins/), and/or run some [automations](https://github.com/topics/bridgetown-automation) to get started quickly.
|
39
39
|
|
@@ -41,13 +41,13 @@ Use a [theme](https://github.com/topics/bridgetown-theme), add some [plugins](ht
|
|
41
41
|
|
42
42
|
```sh
|
43
43
|
# running locally
|
44
|
-
|
44
|
+
bin/bridgetown start
|
45
45
|
|
46
46
|
# build & deploy to production
|
47
|
-
|
47
|
+
bin/bridgetown deploy
|
48
48
|
|
49
49
|
# load the site up within a Ruby console (IRB)
|
50
|
-
|
50
|
+
bin/bridgetown console
|
51
51
|
```
|
52
52
|
|
53
53
|
> Learn more: [Bridgetown CLI Documentation](https://www.bridgetownrb.com/docs/command-line-usage)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "bridgetown"
|
2
|
+
|
3
|
+
Bridgetown.load_tasks
|
4
|
+
|
5
|
+
#
|
6
|
+
# Standard set of tasks, which you can customize if you wish:
|
7
|
+
#
|
8
|
+
desc "Build the Bridgetown site for deployment"
|
9
|
+
task :deploy => [:clean, "frontend:build"] do
|
10
|
+
Bridgetown::Commands::Build.start
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Build the site in a test environment"
|
14
|
+
task :test do
|
15
|
+
ENV["BRIDGETOWN_ENV"] = "test"
|
16
|
+
Bridgetown::Commands::Build.start
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Runs the clean command"
|
20
|
+
task :clean do
|
21
|
+
Bridgetown::Commands::Clean.start
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :frontend do
|
25
|
+
desc "Build the frontend with Webpack for deployment"
|
26
|
+
task :build do
|
27
|
+
sh "yarn run webpack-build"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Watch the frontend with Webpack during development"
|
31
|
+
task :dev do
|
32
|
+
sh "yarn run webpack-dev --color"
|
33
|
+
rescue Interrupt
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Add your own Rake tasks here! You can use `environment` as a prerequisite
|
39
|
+
# in order to write automations or other commands requiring a loaded site.
|
40
|
+
#
|
41
|
+
# task :my_task => :environment do
|
42
|
+
# puts site.root_dir
|
43
|
+
# automation do
|
44
|
+
# say_status :rake, "I'm a Rake tast =) #{site.config.url}"
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
# Run rake without specifying any command to execute a deploy build by default.
|
49
|
+
task default: :deploy
|
@@ -4,11 +4,10 @@
|
|
4
4
|
# which you are expected to set up once and rarely edit after that.
|
5
5
|
#
|
6
6
|
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
7
|
-
#
|
8
|
-
# server process.
|
7
|
+
# `bin/bridgetown start`. If you change this file, please restart the server process.
|
9
8
|
#
|
10
9
|
# For reloadable site metadata like title, SEO description, social media
|
11
|
-
# handles, etc., take a look at src/_data/site_metadata.yml
|
10
|
+
# handles, etc., take a look at `src/_data/site_metadata.yml`
|
12
11
|
#
|
13
12
|
# If you need help with YAML syntax, here are some quick references for you:
|
14
13
|
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Puma is a fast, concurrent web server for Ruby & Rack
|
2
|
+
#
|
3
|
+
# Learn more at: https://puma.io
|
4
|
+
#
|
5
|
+
port ENV.fetch("BRIDGETOWN_PORT") { 4000 }
|
6
|
+
|
7
|
+
# You can adjust the number of workers (separate processes) and threads
|
8
|
+
# (per process) based on your production system
|
9
|
+
#
|
10
|
+
if ENV["BRIDGETOWN_ENV"] == "production"
|
11
|
+
workers ENV.fetch("BRIDGETOWN_CONCURRENCY") { 4 }
|
12
|
+
end
|
13
|
+
|
14
|
+
max_threads_count = ENV.fetch("BRIDGETOWN_MAX_THREADS") { 5 }
|
15
|
+
min_threads_count = ENV.fetch("BRIDGETOWN_MIN_THREADS") { max_threads_count }
|
16
|
+
threads min_threads_count, max_threads_count
|
17
|
+
|
18
|
+
# Preload the application for maximum performance
|
19
|
+
#
|
20
|
+
preload_app!
|
21
|
+
|
22
|
+
# Use the Bridgetown logger format
|
23
|
+
#
|
24
|
+
require "bridgetown-core/rack/logger"
|
25
|
+
log_formatter do |msg|
|
26
|
+
Bridgetown::Rack::Logger.message_with_prefix msg
|
27
|
+
end
|
@@ -3,18 +3,10 @@
|
|
3
3
|
"version": "1.0.0",
|
4
4
|
"private": true,
|
5
5
|
"scripts": {
|
6
|
-
"build": "bundle exec bridgetown build",
|
7
|
-
"serve": "bundle exec bridgetown serve",
|
8
|
-
"clean": "bundle exec bridgetown clean",
|
9
6
|
"webpack-build": "webpack --mode production",
|
10
|
-
"webpack-dev": "webpack --mode development -w"
|
11
|
-
"deploy": "yarn clean && yarn webpack-build && yarn build",
|
12
|
-
"sync": "node sync.js",
|
13
|
-
"start": "node start.js"
|
7
|
+
"webpack-dev": "webpack --mode development -w"
|
14
8
|
},
|
15
9
|
"devDependencies": {
|
16
|
-
"browser-sync": "^2.26.7",
|
17
|
-
"concurrently": "^5.2.0",
|
18
10
|
"css-loader": "^4.3.0",
|
19
11
|
"esbuild": "^0.12.7",
|
20
12
|
"esbuild-loader": "^2.13.1",
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Roda is a simple Rack-based framework with a flexible architecture based
|
2
|
+
# on the concept of a routing tree. Bridgetown uses it for its development
|
3
|
+
# server, but you can also run it in production for fast, dynamic applications.
|
4
|
+
#
|
5
|
+
# Learn more at: http://roda.jeremyevans.net
|
6
|
+
|
7
|
+
# Uncomment to use the file-based routing for Bridgetown SSR:
|
8
|
+
# require "bridgetown-routes"
|
9
|
+
|
10
|
+
class RodaApp < Bridgetown::Rack::Roda
|
11
|
+
# Add additional Roda configuration here if needed
|
12
|
+
|
13
|
+
# Uncomment to use Bridgetown SSR:
|
14
|
+
# plugin :bridgetown_ssr
|
15
|
+
# plugin :bridgetown_routes
|
16
|
+
|
17
|
+
route do |r|
|
18
|
+
# Load all files in server/routes and src/_routes if "bridgetown-routes" is loaded
|
19
|
+
# (see server/routes/hello.rb.sample)
|
20
|
+
Bridgetown::Rack::Routes.start! self
|
21
|
+
end
|
22
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
<meta charset="utf-8" />
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
3
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>
|
4
|
+
<title>{% if page_title != "Index" %}{{ page_title | escape }} | {{ metadata.title | escape }}{% else %}{{ metadata.title | escape }}: {{ metadata.tagline | escape }}{% endif %}</title>
|
5
5
|
|
6
6
|
<meta name="description" content="{{ metadata.description }}" />
|
7
7
|
|
8
8
|
<link rel="stylesheet" href="{% webpack_path css %}" />
|
9
9
|
<script src="{% webpack_path js %}" defer></script>
|
10
|
+
{% live_reload_dev_js %}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
---
|
2
2
|
layout: page
|
3
3
|
title: About
|
4
|
-
permalink: /about/
|
5
4
|
---
|
6
5
|
|
7
6
|
This is the basic Bridgetown site template. You can find out more info about customizing your Bridgetown site, as well as basic Bridgetown usage documentation at [bridgetownrb.com](https://bridgetownrb.com/)
|
@@ -1,13 +1,12 @@
|
|
1
1
|
---
|
2
2
|
layout: page
|
3
3
|
title: Posts
|
4
|
-
permalink: /posts/
|
5
4
|
---
|
6
5
|
|
7
6
|
<ul>
|
8
|
-
{% for post in
|
7
|
+
{% for post in collections.posts.resources %}
|
9
8
|
<li>
|
10
|
-
<a href="{{ post.
|
9
|
+
<a href="{{ post.relative_url }}">{{ post.title }}</a>
|
11
10
|
</li>
|
12
11
|
{% endfor %}
|
13
12
|
</ul>
|