bridgetown-core 0.21.2 → 1.0.0.alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +35 -0
- data/Rakefile +5 -5
- data/bin/bridgetown +2 -0
- data/bridgetown-core.gemspec +3 -0
- data/lib/bridgetown-core/cache.rb +3 -5
- data/lib/bridgetown-core/cleaner.rb +2 -10
- data/lib/bridgetown-core/collection.rb +62 -86
- data/lib/bridgetown-core/commands/base.rb +62 -2
- data/lib/bridgetown-core/commands/build.rb +33 -12
- data/lib/bridgetown-core/commands/concerns/actions.rb +2 -2
- 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/console.rb +3 -3
- data/lib/bridgetown-core/commands/doctor.rb +13 -11
- data/lib/bridgetown-core/commands/new.rb +14 -6
- data/lib/bridgetown-core/commands/plugins.rb +8 -11
- data/lib/bridgetown-core/commands/serve/servlet.rb +4 -4
- data/lib/bridgetown-core/commands/serve.rb +37 -37
- 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/commands/webpack.rb +1 -1
- data/lib/bridgetown-core/component.rb +1 -5
- data/lib/bridgetown-core/concerns/site/configurable.rb +1 -13
- data/lib/bridgetown-core/concerns/site/content.rb +17 -118
- data/lib/bridgetown-core/concerns/site/extensible.rb +3 -4
- data/lib/bridgetown-core/concerns/site/localizable.rb +3 -1
- data/lib/bridgetown-core/concerns/site/processable.rb +9 -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 +6 -9
- data/lib/bridgetown-core/configuration.rb +19 -48
- data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
- data/lib/bridgetown-core/configurations/turbo.rb +1 -1
- data/lib/bridgetown-core/converter.rb +1 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +3 -2
- data/lib/bridgetown-core/converters/liquid_templates.rb +3 -2
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/smartypants.rb +1 -0
- data/lib/bridgetown-core/current.rb +4 -0
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/drop.rb +4 -4
- 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/entry_filter.rb +1 -0
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/filters/url_filters.rb +2 -0
- data/lib/bridgetown-core/filters.rb +11 -12
- data/lib/bridgetown-core/frontmatter_defaults.rb +52 -90
- data/lib/bridgetown-core/{page.rb → generated_page.rb} +34 -60
- data/lib/bridgetown-core/generators/prototype_generator.rb +49 -61
- data/lib/bridgetown-core/helpers.rb +8 -3
- data/lib/bridgetown-core/hooks.rb +2 -2
- data/lib/bridgetown-core/layout.rb +15 -4
- data/lib/bridgetown-core/liquid_renderer.rb +1 -3
- data/lib/bridgetown-core/log_adapter.rb +1 -1
- data/lib/bridgetown-core/log_writer.rb +7 -1
- data/lib/bridgetown-core/model/base.rb +12 -4
- data/lib/bridgetown-core/model/builder_origin.rb +23 -11
- 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 +10 -10
- data/lib/bridgetown-core/publisher.rb +1 -1
- 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 +88 -0
- data/lib/bridgetown-core/rack/static_indexes.rb +30 -0
- data/lib/bridgetown-core/reader.rb +20 -47
- data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +8 -7
- data/lib/bridgetown-core/renderer.rb +2 -12
- data/lib/bridgetown-core/resource/base.rb +51 -27
- data/lib/bridgetown-core/resource/permalink_processor.rb +23 -12
- data/lib/bridgetown-core/resource/relations.rb +2 -3
- data/lib/bridgetown-core/resource/taxonomy_term.rb +1 -5
- data/lib/bridgetown-core/resource/transformer.rb +8 -6
- data/lib/bridgetown-core/ruby_template_view.rb +6 -8
- data/lib/bridgetown-core/site.rb +4 -8
- data/lib/bridgetown-core/static_file.rb +14 -21
- data/lib/bridgetown-core/tags/find.rb +6 -6
- data/lib/bridgetown-core/tags/highlight.rb +5 -5
- data/lib/bridgetown-core/tags/include.rb +22 -32
- 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 +9 -14
- data/lib/bridgetown-core/tags/render_content.rb +2 -2
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +54 -0
- data/lib/bridgetown-core/url.rb +5 -4
- 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 +60 -33
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +4 -6
- data/lib/bridgetown-core.rb +16 -23
- 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/frontend/javascript/index.js.erb +3 -3
- data/lib/site_template/package.json.erb +7 -12
- 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 +63 -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
|
@@ -32,8 +32,8 @@ module Bridgetown
|
|
|
32
32
|
require "amazing_print" unless options[:"bypass-ap"]
|
|
33
33
|
|
|
34
34
|
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
|
|
36
|
+
" console…"
|
|
37
37
|
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
|
38
38
|
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
|
39
39
|
|
|
@@ -54,7 +54,7 @@ module Bridgetown
|
|
|
54
54
|
IRB.conf[:IRB_RC]&.call(irb.context)
|
|
55
55
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
|
56
56
|
eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
|
|
57
|
-
Bridgetown.logger.info "Console:", "Now loaded as "
|
|
57
|
+
Bridgetown.logger.info "Console:", "Now loaded as #{"site".cyan} variable."
|
|
58
58
|
|
|
59
59
|
trap("SIGINT") do
|
|
60
60
|
irb.signal_handle
|
|
@@ -50,7 +50,7 @@ module Bridgetown
|
|
|
50
50
|
"Detected '_posts' directory outside custom `collections_dir`!"
|
|
51
51
|
Bridgetown.logger.warn "",
|
|
52
52
|
"Please move '#{posts_at_root}' into the custom directory at " \
|
|
53
|
-
|
|
53
|
+
"'#{site.in_source_dir(site.config["collections_dir"])}'"
|
|
54
54
|
false
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -64,21 +64,23 @@ module Bridgetown
|
|
|
64
64
|
|
|
65
65
|
conflicting_urls = true
|
|
66
66
|
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
|
67
|
-
|
|
67
|
+
" for the following pages: #{paths.join(", ")}"
|
|
68
68
|
end
|
|
69
69
|
conflicting_urls
|
|
70
70
|
end
|
|
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
|
|
|
78
78
|
urls_only_differ_by_case = true
|
|
79
|
-
Bridgetown.logger.warn
|
|
80
|
-
"
|
|
81
|
-
"
|
|
79
|
+
Bridgetown.logger.warn(
|
|
80
|
+
"Warning:",
|
|
81
|
+
"The following URLs only differ by case. On a case-insensitive file system one of the" \
|
|
82
|
+
" URLs will be overwritten by the other: #{real_urls.join(", ")}"
|
|
83
|
+
)
|
|
82
84
|
end
|
|
83
85
|
urls_only_differ_by_case
|
|
84
86
|
end
|
|
@@ -106,9 +108,9 @@ module Bridgetown
|
|
|
106
108
|
urls
|
|
107
109
|
end
|
|
108
110
|
|
|
109
|
-
def case_insensitive_urls(things,
|
|
111
|
+
def case_insensitive_urls(things, _destination)
|
|
110
112
|
things.each_with_object({}) do |thing, memo|
|
|
111
|
-
dest = thing.destination
|
|
113
|
+
dest = thing.destination.output_path
|
|
112
114
|
(memo[dest.downcase] ||= []) << dest
|
|
113
115
|
end
|
|
114
116
|
end
|
|
@@ -117,7 +119,7 @@ module Bridgetown
|
|
|
117
119
|
return true unless url.nil? || url.empty?
|
|
118
120
|
|
|
119
121
|
Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
|
|
120
|
-
|
|
122
|
+
"you may encounter problems with some plugins."
|
|
121
123
|
false
|
|
122
124
|
end
|
|
123
125
|
|
|
@@ -128,7 +130,7 @@ module Bridgetown
|
|
|
128
130
|
# https://git.io/vFfbx
|
|
129
131
|
rescue TypeError
|
|
130
132
|
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
|
|
131
|
-
|
|
133
|
+
"check the value of `url` in your config file."
|
|
132
134
|
false
|
|
133
135
|
end
|
|
134
136
|
|
|
@@ -136,7 +138,7 @@ module Bridgetown
|
|
|
136
138
|
return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
|
|
137
139
|
|
|
138
140
|
Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
|
|
139
|
-
|
|
141
|
+
"check the value of `url` in your config file."
|
|
140
142
|
false
|
|
141
143
|
end
|
|
142
144
|
end
|
|
@@ -59,8 +59,10 @@ module Bridgetown
|
|
|
59
59
|
|
|
60
60
|
if preserve_source_location?(new_site_path, options)
|
|
61
61
|
say_status :conflict, "#{new_site_path} exists and is not empty.", :red
|
|
62
|
-
Bridgetown.logger.abort_with
|
|
63
|
-
|
|
62
|
+
Bridgetown.logger.abort_with(
|
|
63
|
+
"Ensure #{new_site_path} is empty or else try again with `--force` to proceed and" \
|
|
64
|
+
" overwrite any files."
|
|
65
|
+
)
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
self.destination_root = self.class.created_site_dir = new_site_path
|
|
@@ -119,21 +121,26 @@ module Bridgetown
|
|
|
119
121
|
invoke(Configure, options[:configure].split(","), {}) if options[:configure]
|
|
120
122
|
|
|
121
123
|
logger = Bridgetown.logger
|
|
122
|
-
|
|
124
|
+
bt_start = "bin/bridgetown start"
|
|
123
125
|
logger.info ""
|
|
124
126
|
logger.info "Success!".green, "🎉 Your new Bridgetown site was" \
|
|
125
|
-
|
|
127
|
+
" generated in #{cli_path.cyan}."
|
|
126
128
|
if options["skip-yarn"]
|
|
127
129
|
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} to get started."
|
|
128
130
|
logger.info "You'll probably also want to #{"yarn install".cyan}" \
|
|
129
131
|
" to load in your frontend assets."
|
|
130
132
|
else
|
|
131
|
-
logger.info "You can now #{"cd".cyan} and run #{
|
|
133
|
+
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan}" \
|
|
134
|
+
" to get started."
|
|
132
135
|
end
|
|
133
136
|
logger.info "Then check out our online documentation for" \
|
|
134
137
|
" next steps: #{DOCSURL.cyan}"
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
if @skipped_bundle
|
|
140
|
+
logger.info "Bundle install skipped.".yellow
|
|
141
|
+
logger.info "You will need to run #{"bundle binstub bridgetown-core".cyan} manually."
|
|
142
|
+
end
|
|
143
|
+
|
|
137
144
|
logger.info "Yarn install skipped.".yellow if @skipped_yarn
|
|
138
145
|
end
|
|
139
146
|
# rubocop:enable Metrics/CyclomaticComplexity
|
|
@@ -145,6 +152,7 @@ module Bridgetown
|
|
|
145
152
|
Bridgetown.with_unbundled_env do
|
|
146
153
|
inside(path) do
|
|
147
154
|
run "bundle install", abort_on_failure: true
|
|
155
|
+
run "bundle binstub bridgetown-core"
|
|
148
156
|
end
|
|
149
157
|
end
|
|
150
158
|
end
|
|
@@ -112,12 +112,12 @@ module Bridgetown
|
|
|
112
112
|
source_manifest.origin.to_s == directive[0]
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
if manifest
|
|
115
|
+
if manifest.respond_to?(directive[1].downcase)
|
|
116
116
|
dir = manifest.send(directive[1].downcase)
|
|
117
117
|
Bridgetown.logger.info("Opening the #{dir.green} folder for" \
|
|
118
|
-
|
|
118
|
+
" #{manifest.origin.to_s.cyan}…")
|
|
119
119
|
Bridgetown.logger.info("Type #{"exit".yellow} when you're done to" \
|
|
120
|
-
|
|
120
|
+
" return to your site root.")
|
|
121
121
|
puts
|
|
122
122
|
|
|
123
123
|
Dir.chdir dir do
|
|
@@ -133,20 +133,18 @@ module Bridgetown
|
|
|
133
133
|
Bridgetown.logger.info("Done!", "You're back in #{Dir.pwd.green}")
|
|
134
134
|
else
|
|
135
135
|
Bridgetown.logger.warn("Oops!", "I wasn't able to find the" \
|
|
136
|
-
|
|
136
|
+
" #{directive[1]} folder for #{directive[0]}")
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
desc "new NAME", "Create a new plugin NAME (please-use-dashes) by" \
|
|
141
141
|
" cloning the sample plugin repo"
|
|
142
|
-
# rubocop:disable Layout/LineLength
|
|
143
142
|
def new(plugin_name)
|
|
144
143
|
folder_name = plugin_name.underscore
|
|
145
144
|
name = folder_name.dasherize
|
|
146
145
|
module_name = folder_name.camelize
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
run "git clone -b switch-to-minitest https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
|
147
|
+
run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
|
150
148
|
new_gemspec = "#{name}.gemspec"
|
|
151
149
|
|
|
152
150
|
inside name do # rubocop:todo Metrics/BlockLength
|
|
@@ -188,11 +186,10 @@ module Bridgetown
|
|
|
188
186
|
say ""
|
|
189
187
|
say_status "Done!", "Have fun writing your new #{name} plugin :)"
|
|
190
188
|
say_status "Remember:", "Don't forget to rename the SamplePlugin" \
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
" code identifiers and paths to your own" \
|
|
190
|
+
" indentifer, as well as update your README " \
|
|
191
|
+
" and CHANGELOG files as necessary."
|
|
194
192
|
end
|
|
195
|
-
# rubocop:enable Layout/LineLength
|
|
196
193
|
|
|
197
194
|
protected
|
|
198
195
|
|
|
@@ -8,7 +8,7 @@ module Bridgetown
|
|
|
8
8
|
class Servlet < WEBrick::HTTPServlet::FileHandler
|
|
9
9
|
DEFAULTS = {
|
|
10
10
|
"Cache-Control" => "private, max-age=0, proxy-revalidate, " \
|
|
11
|
-
|
|
11
|
+
"no-store, no-cache, must-revalidate",
|
|
12
12
|
}.freeze
|
|
13
13
|
|
|
14
14
|
def initialize(server, root, callbacks)
|
|
@@ -51,9 +51,9 @@ module Bridgetown
|
|
|
51
51
|
key = res.header.keys.grep(%r!content-type!i).first
|
|
52
52
|
typ = res.header[key]
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
return if %r!;\s*charset=!.match?(typ)
|
|
55
|
+
|
|
56
|
+
res.header[key] = "#{typ}; charset=#{@bridgetown_opts["encoding"]}"
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def set_defaults
|
|
@@ -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,10 @@ module Bridgetown
|
|
|
52
48
|
).freeze
|
|
53
49
|
|
|
54
50
|
def serve
|
|
51
|
+
Bridgetown::Deprecator.deprecation_message(
|
|
52
|
+
"WEBrick (serve) will be removed in favor of Puma (start) in the next Bridgetown release"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
55
|
@mutex = Mutex.new
|
|
56
56
|
@run_cond = ConditionVariable.new
|
|
57
57
|
@running = false
|
|
@@ -59,14 +59,16 @@ module Bridgetown
|
|
|
59
59
|
no_watch = options["watch"] == false
|
|
60
60
|
|
|
61
61
|
options = Thor::CoreExt::HashWithIndifferentAccess.new(self.options)
|
|
62
|
-
|
|
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,23 +78,22 @@ 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)
|
|
87
88
|
require_relative "serve/servlet"
|
|
88
89
|
|
|
89
90
|
FileUtils.mkdir_p(destination)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
return unless File.exist?(File.join(destination, "404.html"))
|
|
92
|
+
|
|
93
|
+
WEBrick::HTTPResponse.class_eval do
|
|
94
|
+
def create_error_page
|
|
95
|
+
@header["Content-Type"] = "text/html; charset=UTF-8"
|
|
96
|
+
@body = File.read(File.join(@config[:DocumentRoot], "404.html"))
|
|
96
97
|
end
|
|
97
98
|
end
|
|
98
99
|
end
|
|
@@ -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
|
|
|
@@ -209,34 +211,32 @@ module Bridgetown
|
|
|
209
211
|
begin
|
|
210
212
|
opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(read_file(src, key))
|
|
211
213
|
rescue StandardError
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
raise
|
|
216
|
-
end
|
|
214
|
+
raise unless defined?(OpenSSL::PKey::EC)
|
|
215
|
+
|
|
216
|
+
opts[:SSLPrivateKey] = OpenSSL::PKey::EC.new(read_file(src, key))
|
|
217
217
|
end
|
|
218
218
|
opts[:SSLEnable] = true
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
def start_callback(detached)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
return if detached
|
|
223
|
+
|
|
224
|
+
proc do
|
|
225
|
+
@mutex.synchronize do
|
|
226
|
+
@running = true
|
|
227
|
+
Bridgetown.logger.info("Server running…", "press ctrl-c to stop.")
|
|
228
|
+
@run_cond.broadcast
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
def stop_callback(detached)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
234
|
+
return if detached
|
|
235
|
+
|
|
236
|
+
proc do
|
|
237
|
+
@mutex.synchronize do
|
|
238
|
+
@running = false
|
|
239
|
+
@run_cond.broadcast
|
|
240
240
|
end
|
|
241
241
|
end
|
|
242
242
|
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bridgetown
|
|
4
|
+
module Commands
|
|
5
|
+
class Start < Thor::Group
|
|
6
|
+
extend BuildOptions
|
|
7
|
+
extend Summarizable
|
|
8
|
+
include ConfigurationOverridable
|
|
9
|
+
|
|
10
|
+
Registrations.register do
|
|
11
|
+
register(Start, "start", "start", Start.summary)
|
|
12
|
+
register(Start, "dev", "dev", "Alias of start")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class_option :bind, aliases: "-B", desc: "URI for Puma to bind to (start with tcp://)"
|
|
16
|
+
class_option :skip_frontend,
|
|
17
|
+
type: :boolean,
|
|
18
|
+
desc: "Don't load the frontend bundler (always true for production)"
|
|
19
|
+
class_option :skip_live_reload,
|
|
20
|
+
type: :boolean,
|
|
21
|
+
desc: "Don't use the live reload functionality (always true for production)"
|
|
22
|
+
|
|
23
|
+
def self.banner
|
|
24
|
+
"bridgetown start [options]"
|
|
25
|
+
end
|
|
26
|
+
summary "Start the Puma server, frontend bundler, and Bridgetown watcher"
|
|
27
|
+
|
|
28
|
+
def start # rubocop:todo Metrics/PerceivedComplexity
|
|
29
|
+
Bridgetown.logger.writer.enable_prefix
|
|
30
|
+
Bridgetown::Commands::Build.print_startup_message
|
|
31
|
+
sleep 0.25
|
|
32
|
+
|
|
33
|
+
unless Bundler.definition.specs.find { |s| s.name == "puma" }
|
|
34
|
+
raise "** No Rack-compatible server found **"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
options = Thor::CoreExt::HashWithIndifferentAccess.new(self.options)
|
|
38
|
+
options[:using_puma] = true
|
|
39
|
+
|
|
40
|
+
# Load Bridgetown configuration into thread memory
|
|
41
|
+
bt_options = configuration_with_overrides(options)
|
|
42
|
+
|
|
43
|
+
puma_pid =
|
|
44
|
+
Process.fork do
|
|
45
|
+
require "puma/cli"
|
|
46
|
+
|
|
47
|
+
Puma::Runner.class_eval do
|
|
48
|
+
def output_header(mode)
|
|
49
|
+
log "* Puma version: #{Puma::Const::PUMA_VERSION} (#{ruby_engine}) (\"#{Puma::Const::CODE_NAME}\")" # rubocop:disable Layout/LineLength
|
|
50
|
+
if mode == "cluster"
|
|
51
|
+
log "* Cluster Master PID: #{Process.pid}"
|
|
52
|
+
else
|
|
53
|
+
log "* PID: #{Process.pid}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
puma_args = []
|
|
59
|
+
if bt_options[:bind]
|
|
60
|
+
puma_args << "--bind"
|
|
61
|
+
puma_args << bt_options[:bind]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
cli = Puma::CLI.new puma_args
|
|
65
|
+
cli.run
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
begin
|
|
69
|
+
unless Bridgetown.env.production? || options[:skip_frontend]
|
|
70
|
+
require "rake"
|
|
71
|
+
Rake.with_application do |rake|
|
|
72
|
+
rake.load_rakefile
|
|
73
|
+
rake["frontend:watcher"].invoke(true)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Signal.trap("TERM") do
|
|
78
|
+
Process.kill "SIGINT", puma_pid
|
|
79
|
+
sleep 0.5 # let it breathe
|
|
80
|
+
exit 0 # this runs the ensure block below
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Process.setproctitle("bridgetown #{Bridgetown::VERSION} [#{File.basename(Dir.pwd)}]")
|
|
84
|
+
|
|
85
|
+
build_args = ["-w"] + ARGV.reject { |arg| arg == "start" }
|
|
86
|
+
if Bridgetown.env.development? && !options["url"]
|
|
87
|
+
scheme = bt_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
|
88
|
+
port = bt_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
|
89
|
+
build_args << "--url"
|
|
90
|
+
build_args << "#{scheme}://localhost:#{port}"
|
|
91
|
+
end
|
|
92
|
+
Bridgetown::Commands::Build.start(build_args)
|
|
93
|
+
rescue StandardError => e
|
|
94
|
+
Process.kill "SIGINT", puma_pid
|
|
95
|
+
sleep 0.5
|
|
96
|
+
raise e
|
|
97
|
+
ensure
|
|
98
|
+
# Shut down webpack, browsersync, etc. if they're running
|
|
99
|
+
Bridgetown::Utils::Aux.kill_processes
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
sleep 0.5 # finish cleaning up
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -66,7 +66,7 @@ module Bridgetown
|
|
|
66
66
|
|
|
67
67
|
longest_action = supported_actions.keys.max_by(&:size).size
|
|
68
68
|
supported_actions.each do |action, description|
|
|
69
|
-
say action.ljust(longest_action).to_s.bold.blue
|
|
69
|
+
say "#{action.ljust(longest_action).to_s.bold.blue}\t# #{description}"
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -97,9 +97,7 @@ module Bridgetown
|
|
|
97
97
|
#
|
|
98
98
|
# @return [String] or nil
|
|
99
99
|
def content
|
|
100
|
-
@_content ||=
|
|
101
|
-
view_context.capture(self, &@_content_block) if @_content_block
|
|
102
|
-
end
|
|
100
|
+
@_content ||= (view_context.capture(self, &@_content_block) if @_content_block)
|
|
103
101
|
end
|
|
104
102
|
|
|
105
103
|
# Provide a render helper for evaluation within the component context.
|
|
@@ -166,7 +164,6 @@ module Bridgetown
|
|
|
166
164
|
end
|
|
167
165
|
end
|
|
168
166
|
|
|
169
|
-
# rubocop:disable Style/MissingRespondToMissing
|
|
170
167
|
ruby2_keywords def method_missing(method, *args, &block)
|
|
171
168
|
if helpers.respond_to?(method.to_sym)
|
|
172
169
|
helpers.send method.to_sym, *args, &block
|
|
@@ -178,6 +175,5 @@ module Bridgetown
|
|
|
178
175
|
def respond_to_missing?(method, include_private = false)
|
|
179
176
|
helpers.respond_to?(method.to_sym, include_private) || super
|
|
180
177
|
end
|
|
181
|
-
# rubocop:enable Style/MissingRespondToMissing
|
|
182
178
|
end
|
|
183
179
|
end
|
|
@@ -62,18 +62,6 @@ class Bridgetown::Site
|
|
|
62
62
|
@frontmatter_defaults ||= Bridgetown::FrontmatterDefaults.new(self)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
# Whether to perform a full rebuild without incremental regeneration.
|
|
66
|
-
# If either `override["incremental"]` or `config["incremental"]` are true,
|
|
67
|
-
# fully rebuild the site. If not, incrementally build the site.
|
|
68
|
-
#
|
|
69
|
-
# @param [Hash] override
|
|
70
|
-
# An override hash to override the current config value
|
|
71
|
-
# @option override [Boolean] "incremental" Whether to incrementally build
|
|
72
|
-
# @return [Boolean] true for full rebuild, false for normal build
|
|
73
|
-
def incremental?(override = {})
|
|
74
|
-
override["incremental"] || config["incremental"]
|
|
75
|
-
end
|
|
76
|
-
|
|
77
65
|
# Returns the current instance of {Publisher} or creates a new instance of
|
|
78
66
|
# {Publisher} if one doesn't exist.
|
|
79
67
|
#
|
|
@@ -177,7 +165,7 @@ class Bridgetown::Site
|
|
|
177
165
|
dir.is_a?(Array) ? dir : [dir]
|
|
178
166
|
end
|
|
179
167
|
local_components_load_paths.map! do |dir|
|
|
180
|
-
if !!(dir =~ %r
|
|
168
|
+
if !!(dir =~ %r!^\.\.?/!)
|
|
181
169
|
# allow ./dir or ../../dir type options
|
|
182
170
|
File.expand_path(dir.to_s, root_dir)
|
|
183
171
|
else
|