bridgetown-core 1.1.0 → 1.2.0.beta1
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/bin/bridgetown +1 -3
- data/bridgetown-core.gemspec +7 -6
- data/lib/bridgetown-core/collection.rb +5 -2
- data/lib/bridgetown-core/commands/base.rb +1 -1
- data/lib/bridgetown-core/commands/build.rb +18 -5
- data/lib/bridgetown-core/commands/clean.rb +1 -1
- data/lib/bridgetown-core/commands/concerns/actions.rb +2 -4
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +7 -8
- data/lib/bridgetown-core/commands/console.rb +20 -1
- data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +5 -0
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +8 -7
- data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
- data/lib/bridgetown-core/commands/plugins.rb +46 -32
- data/lib/bridgetown-core/commands/serve.rb +1 -2
- data/lib/bridgetown-core/commands/start.rb +0 -8
- data/lib/bridgetown-core/component.rb +50 -0
- data/lib/bridgetown-core/concerns/site/configurable.rb +22 -18
- data/lib/bridgetown-core/concerns/site/localizable.rb +2 -6
- data/lib/bridgetown-core/concerns/site/processable.rb +0 -1
- data/lib/bridgetown-core/concerns/site/ssr.rb +0 -1
- data/lib/bridgetown-core/concerns/transformable.rb +5 -2
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +146 -0
- data/lib/bridgetown-core/configuration.rb +90 -15
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +3 -1
- data/lib/bridgetown-core/configurations/lit/esbuild-plugins.js +5 -2
- data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
- data/lib/bridgetown-core/converter.rb +8 -0
- data/lib/bridgetown-core/converters/identity.rb +2 -0
- data/lib/bridgetown-core/converters/liquid_templates.rb +1 -0
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/markdown.rb +2 -0
- data/lib/bridgetown-core/current.rb +19 -5
- data/lib/bridgetown-core/deprecator.rb +4 -37
- data/lib/bridgetown-core/filters.rb +1 -3
- data/lib/bridgetown-core/generated_page.rb +5 -0
- data/lib/bridgetown-core/helpers.rb +119 -8
- data/lib/bridgetown-core/hooks.rb +1 -0
- data/lib/bridgetown-core/kramdown/parser/gfm.rb +1 -1
- data/lib/bridgetown-core/layout.rb +1 -1
- data/lib/bridgetown-core/model/base.rb +11 -12
- data/lib/bridgetown-core/model/builder_origin.rb +1 -1
- data/lib/bridgetown-core/model/origin.rb +5 -1
- data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
- data/lib/bridgetown-core/model/repo_origin.rb +7 -7
- data/lib/bridgetown-core/plugin.rb +2 -6
- data/lib/bridgetown-core/plugin_manager.rb +120 -41
- data/lib/bridgetown-core/rack/boot.rb +3 -7
- data/lib/bridgetown-core/rack/logger.rb +1 -0
- data/lib/bridgetown-core/rack/roda.rb +39 -45
- data/lib/bridgetown-core/rack/routes.rb +2 -6
- data/lib/bridgetown-core/rack/static_indexes.rb +1 -2
- data/lib/bridgetown-core/reader.rb +39 -50
- data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
- data/lib/bridgetown-core/resource/base.rb +17 -1
- data/lib/bridgetown-core/ruby_template_view.rb +12 -8
- data/lib/bridgetown-core/site.rb +10 -3
- data/lib/bridgetown-core/slot.rb +41 -0
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +23 -9
- data/lib/bridgetown-core/utils/ansi.rb +1 -1
- data/lib/bridgetown-core/utils/aux.rb +7 -6
- data/lib/bridgetown-core/utils/initializers.rb +45 -0
- data/lib/bridgetown-core/utils/loaders_manager.rb +2 -2
- data/lib/bridgetown-core/utils/require_gems.rb +11 -35
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +2 -3
- data/lib/bridgetown-core/{converters/smartypants.rb → utils/smarty_pants_converter.rb} +5 -24
- data/lib/bridgetown-core/utils.rb +1 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +1 -8
- data/lib/bridgetown-core.rb +89 -6
- data/lib/roda/plugins/bridgetown_boot.rb +25 -0
- data/lib/roda/plugins/bridgetown_ssr.rb +23 -0
- data/lib/roda/plugins/initializers.rb +17 -0
- data/lib/site_template/.gitignore +1 -0
- data/lib/site_template/Gemfile.erb +1 -1
- data/lib/site_template/TEMPLATES/erb/_layouts/default.erb +2 -2
- data/lib/site_template/TEMPLATES/erb/_layouts/page.erb +1 -1
- data/lib/site_template/TEMPLATES/erb/_layouts/post.erb +1 -1
- data/lib/site_template/TEMPLATES/liquid/_layouts/default.liquid +2 -2
- data/lib/site_template/TEMPLATES/liquid/_layouts/page.liquid +1 -1
- data/lib/site_template/TEMPLATES/liquid/_layouts/post.liquid +1 -1
- data/lib/site_template/TEMPLATES/serbea/_layouts/default.serb +2 -2
- data/lib/site_template/TEMPLATES/serbea/_layouts/page.serb +1 -1
- data/lib/site_template/TEMPLATES/serbea/_layouts/post.serb +1 -1
- data/lib/site_template/config/initializers.rb +43 -0
- data/lib/site_template/package.json.erb +1 -1
- data/lib/site_template/server/roda_app.rb +2 -8
- metadata +17 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 151aa943c75bc92219b009a1024ba80346428dd86b2a55aa606d14e1fbe67fca
|
|
4
|
+
data.tar.gz: 922024f32b5785568c424894875694b5b0d2b3c417397ea2199227fdeccdfc46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 794136c89b55a6c4bca1a0c9c00b1e26570782d9c4d8ee24e5f0543f318ecbdfb645a257b635d8cf4e42cb2bed644c7507ddfc21a8820ff730c4da34fb1d9a3d
|
|
7
|
+
data.tar.gz: 4fa68e3690b005053452c75a55f044dca2310f83364c94eef1c22e3adc5b13e010ced5cbeb4008de5211079cc4ed2244079fcb341aadc3989bbe67c3f486221a
|
data/bin/bridgetown
CHANGED
|
@@ -13,8 +13,6 @@ require "active_support/core_ext/string/indent"
|
|
|
13
13
|
|
|
14
14
|
require "bridgetown"
|
|
15
15
|
|
|
16
|
-
Bridgetown::PluginManager.require_from_bundler
|
|
17
|
-
|
|
18
16
|
# Support NO_COLOR: https://no-color.org
|
|
19
17
|
# TODO: need to change behavior of Colorator gem
|
|
20
18
|
ENV["THOR_SHELL"] = "Basic" if ENV["NO_COLOR"]
|
|
@@ -31,7 +29,7 @@ elsif env_flag = ARGV.find { |arg| arg.start_with?("--environment=") } # rubocop
|
|
|
31
29
|
ENV["BRIDGETOWN_ENV"] = env_flag.split("=").last
|
|
32
30
|
end
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
Bridgetown.begin!
|
|
35
33
|
|
|
36
34
|
require "bridgetown-core/commands/base"
|
|
37
35
|
begin
|
data/bridgetown-core.gemspec
CHANGED
|
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.author = "Bridgetown Team"
|
|
10
10
|
s.email = "maintainers@bridgetownrb.com"
|
|
11
11
|
s.homepage = "https://www.bridgetownrb.com"
|
|
12
|
-
s.summary = "A
|
|
13
|
-
s.description = "Bridgetown is a
|
|
12
|
+
s.summary = "A next-generation, progressive site generator & fullstack framework, powered by Ruby"
|
|
13
|
+
s.description = "Bridgetown is a next-generation, progressive site generator & fullstack framework, powered by Ruby"
|
|
14
14
|
|
|
15
15
|
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
16
16
|
f.match(%r!^(benchmark|features|script|test)/!)
|
|
@@ -20,10 +20,11 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.require_paths = ["lib"]
|
|
21
21
|
|
|
22
22
|
s.metadata = {
|
|
23
|
-
"source_code_uri"
|
|
24
|
-
"bug_tracker_uri"
|
|
25
|
-
"changelog_uri"
|
|
26
|
-
"homepage_uri"
|
|
23
|
+
"source_code_uri" => "https://github.com/bridgetownrb/bridgetown",
|
|
24
|
+
"bug_tracker_uri" => "https://github.com/bridgetownrb/bridgetown/issues",
|
|
25
|
+
"changelog_uri" => "https://github.com/bridgetownrb/bridgetown/releases",
|
|
26
|
+
"homepage_uri" => s.homepage,
|
|
27
|
+
"rubygems_mfa_required" => "true",
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
@@ -270,10 +270,13 @@ module Bridgetown
|
|
|
270
270
|
|
|
271
271
|
# Read in resource from repo path
|
|
272
272
|
# @param full_path [String]
|
|
273
|
+
# @param manifest [Bridgetown::Configuration::SourceManifest]
|
|
273
274
|
def read_resource(full_path, manifest: nil)
|
|
274
275
|
model_relative_path = relative_model_path_for(full_path, manifest: manifest)
|
|
275
|
-
model = Bridgetown::Model::Base.find(
|
|
276
|
-
|
|
276
|
+
model = Bridgetown::Model::Base.find(
|
|
277
|
+
model_id_from_relative_path(model_relative_path, manifest: manifest),
|
|
278
|
+
site: site
|
|
279
|
+
)
|
|
277
280
|
|
|
278
281
|
if model_is_multi_locale?(model, model_relative_path)
|
|
279
282
|
site.config.available_locales.each do |locale|
|
|
@@ -87,7 +87,7 @@ module Bridgetown
|
|
|
87
87
|
klass.start(["-h"])
|
|
88
88
|
else
|
|
89
89
|
puts "Bridgetown v#{Bridgetown::VERSION.magenta} \"#{Bridgetown::CODE_NAME.yellow}\"" \
|
|
90
|
-
" is a
|
|
90
|
+
" is a next-generation, progressive site generator & fullstack framework, powered by Ruby"
|
|
91
91
|
puts ""
|
|
92
92
|
puts "Usage:"
|
|
93
93
|
puts " bridgetown <command> [options]"
|
|
@@ -32,16 +32,29 @@ module Bridgetown
|
|
|
32
32
|
Bridgetown.logger.adjust_verbosity(options)
|
|
33
33
|
|
|
34
34
|
unless caller_locations.find do |loc|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
loc.to_s.include?("bridgetown-core/commands/start.rb")
|
|
36
|
+
end
|
|
37
37
|
self.class.print_startup_message
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
# @type [Bridgetown::Configuration]
|
|
41
|
+
config_options = configuration_with_overrides(
|
|
42
|
+
options, Bridgetown::Current.preloaded_configuration
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
config_options.run_initializers! context: :static
|
|
43
46
|
|
|
44
47
|
config_options["serving"] = false unless config_options["serving"]
|
|
48
|
+
|
|
49
|
+
if !Bridgetown.env.production? &&
|
|
50
|
+
!config_options[:skip_frontend] && config_options["using_puma"]
|
|
51
|
+
require "rake"
|
|
52
|
+
Rake.with_application do |rake|
|
|
53
|
+
rake.load_rakefile
|
|
54
|
+
rake["frontend:watcher"].invoke(true)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
45
58
|
@site = Bridgetown::Site.new(config_options)
|
|
46
59
|
|
|
47
60
|
if config_options.fetch("skip_initial_build", false)
|
|
@@ -17,7 +17,7 @@ module Bridgetown
|
|
|
17
17
|
summary "Clean the site (removes site output and metadata file) without building"
|
|
18
18
|
|
|
19
19
|
def clean
|
|
20
|
-
config = configuration_with_overrides(options)
|
|
20
|
+
config = configuration_with_overrides(options, Bridgetown::Current.preloaded_configuration)
|
|
21
21
|
destination = config["destination"]
|
|
22
22
|
metadata_file = File.join(config["root_dir"], ".bridgetown-metadata")
|
|
23
23
|
cache_dir = File.join(config["root_dir"], config["cache_dir"])
|
|
@@ -64,10 +64,8 @@ module Bridgetown
|
|
|
64
64
|
say_status :add_yarn, gemname
|
|
65
65
|
|
|
66
66
|
Bundler.reset!
|
|
67
|
-
|
|
68
|
-
Bridgetown::PluginManager.install_yarn_dependencies(
|
|
69
|
-
available_gems.requested_specs, gemname
|
|
70
|
-
)
|
|
67
|
+
Bridgetown::PluginManager.load_determined_bundler_environment
|
|
68
|
+
Bridgetown::PluginManager.install_yarn_dependencies(name: gemname)
|
|
71
69
|
rescue SystemExit
|
|
72
70
|
say_status :add_yarn, "Package not added due to yarn error", :red
|
|
73
71
|
end
|
|
@@ -12,15 +12,14 @@ module Bridgetown
|
|
|
12
12
|
|
|
13
13
|
# Create a full Bridgetown configuration with the options passed in as overrides
|
|
14
14
|
#
|
|
15
|
-
# options
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
# @param options [Hash] the configuration overrides
|
|
16
|
+
# @param preloaded [Bridgetown::Configuration, Bridgetown::Configuration::Preflight]
|
|
17
|
+
# a preloaded config or preflight
|
|
18
|
+
# @return [Bridgetown::Configuration] a full Bridgetown configuration
|
|
19
|
+
def configuration_with_overrides(options, preloaded = nil)
|
|
20
|
+
return preloaded.merge!(options) if preloaded.is_a?(Bridgetown::Configuration)
|
|
20
21
|
|
|
21
|
-
Bridgetown.configuration(options)
|
|
22
|
-
Bridgetown::Current.preloaded_configuration = new_config
|
|
23
|
-
end
|
|
22
|
+
Bridgetown.configuration(options)
|
|
24
23
|
end
|
|
25
24
|
end
|
|
26
25
|
end
|
|
@@ -58,17 +58,36 @@ module Bridgetown
|
|
|
58
58
|
class_option :blank,
|
|
59
59
|
type: :boolean,
|
|
60
60
|
desc: "Skip reading content and running generators before opening console"
|
|
61
|
+
class_option :"server-config",
|
|
62
|
+
aliases: "-s",
|
|
63
|
+
type: :boolean,
|
|
64
|
+
desc: "Load server configurations"
|
|
65
|
+
class_option :verbose,
|
|
66
|
+
aliases: "-V",
|
|
67
|
+
type: :boolean,
|
|
68
|
+
desc: "Print verbose output."
|
|
61
69
|
|
|
62
70
|
def console
|
|
63
71
|
require "irb"
|
|
64
72
|
require "irb/ext/save-history"
|
|
65
73
|
require "amazing_print" unless options[:"bypass-ap"]
|
|
66
74
|
|
|
75
|
+
Bridgetown.logger.adjust_verbosity(options)
|
|
76
|
+
|
|
67
77
|
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
|
|
68
78
|
"(codename \"#{Bridgetown::CODE_NAME.yellow}\") " \
|
|
69
79
|
"console…"
|
|
70
80
|
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
|
71
|
-
|
|
81
|
+
|
|
82
|
+
config_options = configuration_with_overrides(options)
|
|
83
|
+
if options[:"server-config"]
|
|
84
|
+
require "puma"
|
|
85
|
+
require "bridgetown-core/rack/boot"
|
|
86
|
+
Bridgetown::Rack.boot
|
|
87
|
+
else
|
|
88
|
+
config_options.run_initializers! context: :console
|
|
89
|
+
end
|
|
90
|
+
site = Bridgetown::Site.new(config_options)
|
|
72
91
|
|
|
73
92
|
ConsoleMethods.site_reset(site) unless options[:blank]
|
|
74
93
|
|
|
@@ -26,6 +26,11 @@ const outputFolder = "output"
|
|
|
26
26
|
// ```
|
|
27
27
|
// const esbuildOptions = { publicPath: "/my_subfolder/_bridgetown/static" }
|
|
28
28
|
// ```
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef { import("esbuild").BuildOptions } BuildOptions
|
|
32
|
+
* @type {BuildOptions}
|
|
33
|
+
*/
|
|
29
34
|
const esbuildOptions = {}
|
|
30
35
|
|
|
31
36
|
build(outputFolder, esbuildOptions)
|
|
@@ -84,7 +84,7 @@ const importGlobPlugin = () => ({
|
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
// Plugin for PostCSS
|
|
87
|
-
const
|
|
87
|
+
const importPostCssPlugin = (options, configuration) => ({
|
|
88
88
|
name: "postcss",
|
|
89
89
|
async setup(build) {
|
|
90
90
|
// Process .css files with PostCSS
|
|
@@ -98,7 +98,7 @@ const postCssPlugin = (options, configuration) => ({
|
|
|
98
98
|
load: async filename => {
|
|
99
99
|
let contents = await readCache(filename, "utf-8")
|
|
100
100
|
const filedir = path.dirname(filename)
|
|
101
|
-
// We'll want to track any imports later when in watch mode:
|
|
101
|
+
// We'll want to track any imports later when in watch mode:
|
|
102
102
|
additionalFilePaths.push(filename)
|
|
103
103
|
|
|
104
104
|
// We need to transform `url(...)` in imported CSS so the filepaths are properly
|
|
@@ -231,9 +231,10 @@ const bridgetownPreset = (outputFolder) => ({
|
|
|
231
231
|
// We have an entrypoint!
|
|
232
232
|
manifest[stripPrefix(value.entryPoint)] = outputPath
|
|
233
233
|
entrypoints.push([outputPath, fileSize(key)])
|
|
234
|
-
} else if (key.match(/index(\.js)?\.[^-.]*\.css/) && inputs.find(item => item.match(
|
|
234
|
+
} else if (key.match(/index(\.js)?\.[^-.]*\.css/) && inputs.find(item => item.match(/frontend.*\.(s?css|sass)$/))) {
|
|
235
235
|
// Special treatment for index.css
|
|
236
|
-
|
|
236
|
+
const input = inputs.find(item => item.match(/frontend.*\.(s?css|sass)$/))
|
|
237
|
+
manifest[stripPrefix(input)] = outputPath
|
|
237
238
|
entrypoints.push([outputPath, fileSize(key)])
|
|
238
239
|
} else if (inputs.length > 0) {
|
|
239
240
|
// Naive implementation, we'll just grab the first input and hope it's accurate
|
|
@@ -257,12 +258,12 @@ const bridgetownPreset = (outputFolder) => ({
|
|
|
257
258
|
|
|
258
259
|
// Load the PostCSS config from postcss.config.js or whatever else is a supported location/format
|
|
259
260
|
const postcssrc = require("postcss-load-config")
|
|
260
|
-
const postCssConfig = postcssrc.sync()
|
|
261
261
|
|
|
262
|
-
module.exports = (outputFolder, esbuildOptions) => {
|
|
262
|
+
module.exports = async (outputFolder, esbuildOptions) => {
|
|
263
263
|
esbuildOptions.plugins = esbuildOptions.plugins || []
|
|
264
264
|
// Add the PostCSS & glob plugins to the top of the plugin stack
|
|
265
|
-
|
|
265
|
+
const postCssConfig = await postcssrc()
|
|
266
|
+
esbuildOptions.plugins.unshift(importPostCssPlugin(postCssConfig, esbuildOptions.postCssPluginConfig || {}))
|
|
266
267
|
if (esbuildOptions.postCssPluginConfig) delete esbuildOptions.postCssPluginConfig
|
|
267
268
|
esbuildOptions.plugins.unshift(importGlobPlugin())
|
|
268
269
|
// Add the Sass plugin
|
|
@@ -11,7 +11,7 @@ default_postcss_config = File.expand_path("../../../site_template/postcss.config
|
|
|
11
11
|
template default_postcss_config, "postcss.config.js"
|
|
12
12
|
|
|
13
13
|
unless Bridgetown.environment.test?
|
|
14
|
-
required_packages = %w(esbuild glob postcss postcss-flexbugs-fixes postcss-preset-env postcss-import postcss-load-config@
|
|
14
|
+
required_packages = %w(esbuild glob postcss postcss-flexbugs-fixes postcss-preset-env postcss-import postcss-load-config@4.0.1)
|
|
15
15
|
redundant_packages = %w(esbuild-loader webpack webpack-cli webpack-manifest-plugin webpack-merge css-loader file-loader mini-css-extract-plugin postcss-loader)
|
|
16
16
|
|
|
17
17
|
say "Installing required packages"
|
|
@@ -17,27 +17,48 @@ module Bridgetown
|
|
|
17
17
|
type: :boolean,
|
|
18
18
|
desc: "Print the source path of each plugin"
|
|
19
19
|
def list
|
|
20
|
-
|
|
20
|
+
config_options = configuration_with_overrides(options)
|
|
21
|
+
config_options.run_initializers! context: :static
|
|
22
|
+
site = Bridgetown::Site.new(config_options)
|
|
21
23
|
site.reset
|
|
22
24
|
Bridgetown::Hooks.trigger :site, :pre_read, site
|
|
23
25
|
|
|
26
|
+
plugins_list = config_options.initializers.values.sort_by(&:name)
|
|
27
|
+
|
|
24
28
|
pm = site.plugin_manager
|
|
25
29
|
|
|
26
|
-
plugins_list
|
|
30
|
+
plugins_list += pm.class.registered_plugins.reject do |plugin|
|
|
27
31
|
plugin.to_s.end_with? "site_builder.rb"
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
Bridgetown.logger.info("Registered Plugins:", plugins_list.length.to_s.yellow.bold)
|
|
31
35
|
|
|
32
36
|
plugins_list.each do |plugin|
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
plugin_desc = plugin.to_s
|
|
38
|
+
next if plugin_desc.ends_with?("site_builder.rb") || plugin_desc == "init (Initializer)"
|
|
39
|
+
|
|
40
|
+
if plugin.is_a?(Bridgetown::Configuration::Initializer)
|
|
41
|
+
Bridgetown.logger.info("", plugin_desc)
|
|
42
|
+
Bridgetown.logger.debug(
|
|
43
|
+
"", "PATH: " + plugin.block.source_location[0]
|
|
44
|
+
)
|
|
45
|
+
elsif plugin.is_a?(Bundler::StubSpecification) || plugin.is_a?(Gem::Specification)
|
|
46
|
+
Bridgetown.logger.info("", "#{plugin.name} (Rubygem)")
|
|
47
|
+
Bridgetown.logger.debug(
|
|
48
|
+
"", "PATH: " + plugin.full_gem_path
|
|
49
|
+
)
|
|
50
|
+
else
|
|
51
|
+
Bridgetown.logger.info("", plugin_desc.sub(site.in_root_dir("/"), ""))
|
|
35
52
|
end
|
|
53
|
+
|
|
54
|
+
Bridgetown.logger.debug("")
|
|
36
55
|
end
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
unless site.config.source_manifests.empty?
|
|
58
|
+
Bridgetown.logger.info("Source Manifests:", "----")
|
|
59
|
+
end
|
|
39
60
|
|
|
40
|
-
|
|
61
|
+
site.config.source_manifests.each do |manifest|
|
|
41
62
|
Bridgetown.logger.info("Origin:", (manifest.origin || "n/a").to_s.green)
|
|
42
63
|
Bridgetown.logger.info("Components:", (manifest.components || "n/a").to_s.cyan)
|
|
43
64
|
Bridgetown.logger.info("Content:", (manifest.content || "n/a").to_s.cyan)
|
|
@@ -56,12 +77,10 @@ module Bridgetown
|
|
|
56
77
|
last_name = name_components.pop
|
|
57
78
|
name_components.push last_name.magenta
|
|
58
79
|
Bridgetown.logger.info("", name_components.join("::"))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Bridgetown.logger.info(
|
|
80
|
+
Bridgetown.logger.debug(
|
|
62
81
|
"", "PATH: " + builder_path_for(builder)
|
|
63
82
|
)
|
|
64
|
-
Bridgetown.logger.
|
|
83
|
+
Bridgetown.logger.debug("")
|
|
65
84
|
end
|
|
66
85
|
Bridgetown.logger.info("", "----")
|
|
67
86
|
end
|
|
@@ -74,12 +93,10 @@ module Bridgetown
|
|
|
74
93
|
last_name = name_components.pop
|
|
75
94
|
name_components.push last_name.magenta
|
|
76
95
|
Bridgetown.logger.info("", name_components.join("::"))
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Bridgetown.logger.info(
|
|
96
|
+
Bridgetown.logger.debug(
|
|
80
97
|
"", "PATH: " + converter_path_for(converter)
|
|
81
98
|
)
|
|
82
|
-
Bridgetown.logger.
|
|
99
|
+
Bridgetown.logger.debug("")
|
|
83
100
|
end
|
|
84
101
|
|
|
85
102
|
Bridgetown.logger.info("", "----")
|
|
@@ -92,12 +109,10 @@ module Bridgetown
|
|
|
92
109
|
last_name = name_components.pop
|
|
93
110
|
name_components.push last_name.magenta
|
|
94
111
|
Bridgetown.logger.info("", name_components.join("::"))
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Bridgetown.logger.info(
|
|
112
|
+
Bridgetown.logger.debug(
|
|
98
113
|
"", "PATH: " + generator_path_for(generator)
|
|
99
114
|
)
|
|
100
|
-
Bridgetown.logger.
|
|
115
|
+
Bridgetown.logger.debug("")
|
|
101
116
|
end
|
|
102
117
|
end
|
|
103
118
|
|
|
@@ -122,9 +137,8 @@ module Bridgetown
|
|
|
122
137
|
# Now all the plugin's layouts will be in the site repo directly.
|
|
123
138
|
#
|
|
124
139
|
def cd(arg)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
pm = site.plugin_manager
|
|
140
|
+
config_options = configuration_with_overrides(options)
|
|
141
|
+
config_options.run_initializers! context: :static
|
|
128
142
|
|
|
129
143
|
directive = arg.split("/")
|
|
130
144
|
unless directive[1]
|
|
@@ -132,7 +146,7 @@ module Bridgetown
|
|
|
132
146
|
return
|
|
133
147
|
end
|
|
134
148
|
|
|
135
|
-
manifest =
|
|
149
|
+
manifest = config_options.source_manifests.find do |source_manifest|
|
|
136
150
|
source_manifest.origin.to_s == directive[0]
|
|
137
151
|
end
|
|
138
152
|
|
|
@@ -146,7 +160,7 @@ module Bridgetown
|
|
|
146
160
|
|
|
147
161
|
# rubocop: disable Style/RedundantCondition
|
|
148
162
|
Dir.chdir dir do
|
|
149
|
-
ENV["BRIDGETOWN_SITE"] =
|
|
163
|
+
ENV["BRIDGETOWN_SITE"] = config_options.root_dir
|
|
150
164
|
if ENV["SHELL"]
|
|
151
165
|
system(ENV["SHELL"])
|
|
152
166
|
else
|
|
@@ -163,14 +177,12 @@ module Bridgetown
|
|
|
163
177
|
end
|
|
164
178
|
end
|
|
165
179
|
|
|
166
|
-
desc "new NAME", "Create a new plugin NAME
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
folder_name = plugin_name.underscore
|
|
170
|
-
name = folder_name.dasherize
|
|
180
|
+
desc "new NAME", "Create a new plugin NAME by cloning the sample plugin repo"
|
|
181
|
+
def new(name)
|
|
182
|
+
folder_name = name.underscore
|
|
171
183
|
module_name = folder_name.camelize
|
|
172
184
|
|
|
173
|
-
run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
|
185
|
+
run "git clone -b v1.2-initializer https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
|
174
186
|
new_gemspec = "#{name}.gemspec"
|
|
175
187
|
|
|
176
188
|
inside name do # rubocop:todo Metrics/BlockLength
|
|
@@ -186,11 +198,11 @@ module Bridgetown
|
|
|
186
198
|
gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
|
187
199
|
gsub_file "package.json", "bridgetown-sample-plugin", name
|
|
188
200
|
|
|
189
|
-
FileUtils.mv "lib/
|
|
190
|
-
gsub_file "lib/#{name}.rb", "
|
|
201
|
+
FileUtils.mv "lib/sample_plugin.rb", "lib/#{folder_name}.rb"
|
|
202
|
+
gsub_file "lib/#{name}.rb", "sample_plugin", folder_name
|
|
191
203
|
gsub_file "lib/#{name}.rb", "SamplePlugin", module_name
|
|
192
204
|
|
|
193
|
-
FileUtils.mv "lib/
|
|
205
|
+
FileUtils.mv "lib/sample_plugin", "lib/#{folder_name}"
|
|
194
206
|
gsub_file "lib/#{name}/builder.rb", "SamplePlugin", module_name
|
|
195
207
|
gsub_file "lib/#{name}/version.rb", "SamplePlugin", module_name
|
|
196
208
|
|
|
@@ -206,6 +218,8 @@ module Bridgetown
|
|
|
206
218
|
gsub_file "content/#{folder_name}/example_page.md", "sample_plugin", folder_name
|
|
207
219
|
gsub_file "components/#{folder_name}/layout_help.liquid", "sample_plugin", folder_name
|
|
208
220
|
|
|
221
|
+
gsub_file "components/#{folder_name}/plugin_component.rb", "SamplePlugin", module_name
|
|
222
|
+
|
|
209
223
|
gsub_file "frontend/javascript/index.js", "bridgetown-sample-plugin", name
|
|
210
224
|
gsub_file "frontend/javascript/index.js", "SamplePlugin", module_name
|
|
211
225
|
end
|
|
@@ -62,8 +62,7 @@ module Bridgetown
|
|
|
62
62
|
options["serving"] = true
|
|
63
63
|
options["watch"] = true unless no_watch
|
|
64
64
|
|
|
65
|
-
config = Bridgetown::Current.preloaded_configuration
|
|
66
|
-
configuration_with_overrides(options)
|
|
65
|
+
config = configuration_with_overrides(options, Bridgetown::Current.preloaded_configuration)
|
|
67
66
|
if Bridgetown.environment == "development"
|
|
68
67
|
default_url(config).tap do |url|
|
|
69
68
|
options["url"] = url
|
|
@@ -77,14 +77,6 @@ module Bridgetown
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
begin
|
|
80
|
-
unless Bridgetown.env.production? || options[:skip_frontend]
|
|
81
|
-
require "rake"
|
|
82
|
-
Rake.with_application do |rake|
|
|
83
|
-
rake.load_rakefile
|
|
84
|
-
rake["frontend:watcher"].invoke(true)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
80
|
Signal.trap("TERM") do
|
|
89
81
|
Process.kill "SIGINT", puma_pid
|
|
90
82
|
sleep 0.5 # let it breathe
|
|
@@ -104,6 +104,56 @@ module Bridgetown
|
|
|
104
104
|
@_content ||= (view_context.capture(self, &@_content_block) if @_content_block)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
# @return [Array<Bridgetown::Slot>]
|
|
108
|
+
def slots
|
|
109
|
+
@slots ||= []
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Define a new component slot
|
|
113
|
+
#
|
|
114
|
+
# @param name [String, Symbol] name of the slot
|
|
115
|
+
# @param input [String] content if not supplying a block
|
|
116
|
+
# @param replace [Boolean] set to true to replace any previously defined slot with same name
|
|
117
|
+
# @return [void]
|
|
118
|
+
def slot(name, input = nil, replace: false, &block)
|
|
119
|
+
content = block.nil? ? input.to_s : view_context.capture(&block)
|
|
120
|
+
|
|
121
|
+
name = name.to_s
|
|
122
|
+
slots.reject! { _1.name == name } if replace
|
|
123
|
+
|
|
124
|
+
slots << Slot.new(name: name, content: content, context: self, transform: false)
|
|
125
|
+
|
|
126
|
+
nil
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Render out a component slot
|
|
130
|
+
#
|
|
131
|
+
# @param name [String, Symbol] name of the slot
|
|
132
|
+
# @param input [String] default content if slot isn't defined and no block provided
|
|
133
|
+
# @return [String]
|
|
134
|
+
def slotted(name, default_input = nil, &default_block)
|
|
135
|
+
content # ensure content block is processed
|
|
136
|
+
|
|
137
|
+
name = name.to_s
|
|
138
|
+
filtered_slots = slots.select do |slot|
|
|
139
|
+
slot.name == name
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
return filtered_slots.map(&:content).join.html_safe if filtered_slots.length.positive?
|
|
143
|
+
|
|
144
|
+
default_block.nil? ? default_input.to_s : capture(&default_block)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Check if a component slot has been defined
|
|
148
|
+
#
|
|
149
|
+
# @return [Boolean]
|
|
150
|
+
def slotted?(name)
|
|
151
|
+
name = name.to_s
|
|
152
|
+
slots.any? do |slot|
|
|
153
|
+
slot.name == name
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
107
157
|
# Provide a render helper for evaluation within the component context.
|
|
108
158
|
#
|
|
109
159
|
# @param item [Object] a component supporting `render_in` or a partial name
|
|
@@ -2,34 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
class Bridgetown::Site
|
|
4
4
|
module Configurable
|
|
5
|
-
# Set the site's configuration
|
|
6
|
-
# changing values in the configuration.
|
|
5
|
+
# Set the site's configuration object
|
|
7
6
|
#
|
|
8
7
|
# @param config [Configuration]
|
|
9
|
-
# An instance of {Configuration},
|
|
10
|
-
# containing the new configuration.
|
|
11
|
-
#
|
|
12
|
-
# @return [Configuration]
|
|
13
|
-
# The processed instance of {Configuration}
|
|
14
8
|
def config=(config)
|
|
15
|
-
@config = config
|
|
16
|
-
|
|
17
|
-
# Source and destination may not be changed after the site has been created.
|
|
18
|
-
@root_dir = File.expand_path(config["root_dir"]).freeze
|
|
19
|
-
@source = File.expand_path(config["source"]).freeze
|
|
20
|
-
@dest = File.expand_path(config["destination"]).freeze
|
|
9
|
+
@config = config
|
|
21
10
|
|
|
22
11
|
configure_cache
|
|
23
12
|
configure_component_paths
|
|
24
13
|
configure_file_read_opts
|
|
25
14
|
|
|
26
15
|
self.permalink_style = (config["permalink"] || "pretty").to_sym
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def root_dir
|
|
19
|
+
config["root_dir"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def source
|
|
23
|
+
config["source"]
|
|
24
|
+
end
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
def destination
|
|
27
|
+
config["destination"]
|
|
29
28
|
end
|
|
29
|
+
alias_method :dest, :destination
|
|
30
30
|
|
|
31
31
|
def uses_resource?
|
|
32
|
-
|
|
32
|
+
Bridgetown::Deprecator.deprecation_message(
|
|
33
|
+
"The Site#uses_resource? method will be removed in the next version"
|
|
34
|
+
)
|
|
35
|
+
true
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
# Returns a base path from which the site is served (aka `/cool-site`) or
|
|
@@ -98,11 +101,12 @@ class Bridgetown::Site
|
|
|
98
101
|
# {Bridgetown.sanitized_path} method.
|
|
99
102
|
#
|
|
100
103
|
# @return [Array<String>] Return an array of updated paths if multiple paths given.
|
|
101
|
-
def
|
|
102
|
-
paths.reduce(
|
|
104
|
+
def in_destination_dir(*paths)
|
|
105
|
+
paths.reduce(destination) do |base, path|
|
|
103
106
|
Bridgetown.sanitized_path(base, path)
|
|
104
107
|
end
|
|
105
108
|
end
|
|
109
|
+
alias_method :in_dest_dir, :in_destination_dir
|
|
106
110
|
|
|
107
111
|
# Prefix a path or paths with the {#cache_dir} directory.
|
|
108
112
|
#
|
|
@@ -155,7 +159,7 @@ class Bridgetown::Site
|
|
|
155
159
|
|
|
156
160
|
def configure_component_paths # rubocop:todo Metrics/AbcSize
|
|
157
161
|
# Loop through plugins paths first
|
|
158
|
-
plugin_components_load_paths =
|
|
162
|
+
plugin_components_load_paths = config.source_manifests
|
|
159
163
|
.filter_map(&:components)
|
|
160
164
|
|
|
161
165
|
local_components_load_paths = config["components_dir"].then do |dir|
|
|
@@ -7,14 +7,10 @@ class Bridgetown::Site
|
|
|
7
7
|
def locale
|
|
8
8
|
@locale ||= begin
|
|
9
9
|
locale = ENV.fetch("BRIDGETOWN_LOCALE", config[:default_locale]).to_sym
|
|
10
|
-
Dir["#{in_source_dir("_locales")}
|
|
11
|
-
I18n.load_path << locale_path
|
|
12
|
-
end
|
|
10
|
+
I18n.load_path += Dir["#{in_source_dir("_locales")}/**/*.{json,rb,yml}"]
|
|
13
11
|
I18n.available_locales = config[:available_locales]
|
|
14
12
|
I18n.default_locale = locale
|
|
15
|
-
I18n.fallbacks =
|
|
16
|
-
[available_locale, [available_locale, locale, :en].uniq]
|
|
17
|
-
end
|
|
13
|
+
I18n.fallbacks = [locale, :en].uniq
|
|
18
14
|
locale
|
|
19
15
|
end
|
|
20
16
|
end
|
|
@@ -14,7 +14,6 @@ class Bridgetown::Site
|
|
|
14
14
|
"Check your Rack app for threading issues"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
Bridgetown::PluginManager.require_from_bundler
|
|
18
17
|
site = new(Bridgetown::Current.preloaded_configuration, loaders_manager: loaders_manager)
|
|
19
18
|
site.enable_ssr
|
|
20
19
|
site.ssr_setup(&block)
|