bridgetown-core 1.1.0.beta2 โ†’ 1.1.0.beta3

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/bridgetown-core.gemspec +0 -1
  3. data/lib/bridgetown-core/collection.rb +2 -2
  4. data/lib/bridgetown-core/commands/apply.rb +3 -3
  5. data/lib/bridgetown-core/commands/build.rb +6 -6
  6. data/lib/bridgetown-core/commands/concerns/build_options.rb +2 -2
  7. data/lib/bridgetown-core/commands/console.rb +5 -5
  8. data/lib/bridgetown-core/commands/doctor.rb +7 -7
  9. data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -6
  10. data/lib/bridgetown-core/commands/new.rb +10 -10
  11. data/lib/bridgetown-core/commands/plugins.rb +45 -9
  12. data/lib/bridgetown-core/commands/registrations.rb +2 -3
  13. data/lib/bridgetown-core/commands/serve.rb +2 -2
  14. data/lib/bridgetown-core/component.rb +1 -1
  15. data/lib/bridgetown-core/concerns/transformable.rb +2 -2
  16. data/lib/bridgetown-core/configuration.rb +2 -2
  17. data/lib/bridgetown-core/configurations/turbo/turbo_transitions.js +1 -1
  18. data/lib/bridgetown-core/converters/erb_templates.rb +7 -2
  19. data/lib/bridgetown-core/converters/serbea_templates.rb +1 -4
  20. data/lib/bridgetown-core/model/base.rb +2 -2
  21. data/lib/bridgetown-core/rack/boot.rb +2 -2
  22. data/lib/bridgetown-core/rack/roda.rb +13 -10
  23. data/lib/bridgetown-core/resource/base.rb +5 -0
  24. data/lib/bridgetown-core/ruby_template_view.rb +3 -3
  25. data/lib/bridgetown-core/static_file.rb +1 -1
  26. data/lib/bridgetown-core/tags/highlight.rb +1 -1
  27. data/lib/bridgetown-core/tags/post_url.rb +1 -1
  28. data/lib/bridgetown-core/url.rb +1 -1
  29. data/lib/bridgetown-core/version.rb +1 -1
  30. data/lib/bridgetown-core/watcher.rb +2 -2
  31. data/lib/site_template/Gemfile.erb +4 -0
  32. metadata +2 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 423677a019c8efddafcee904aa9c5aaa8bb9faed27e9ef7c33afc0bf42994b5a
4
- data.tar.gz: 0ac8e9e2f6b954dac8e43892ed9313e7068d4c5038fe8fe3186949f288818a87
3
+ metadata.gz: afc674e5aa40d66a2b9e4f24c0aad39108f47e70c8d4756cbfa86623ed2dc7e0
4
+ data.tar.gz: 4bf462c506c3fcdd09a4750bedae19cb2ee4ff429b57a6266dd56d62645d4926
5
5
  SHA512:
6
- metadata.gz: e43c335ccf732d3ff398b4e141d38ff77c8ef1a0d3d583b9c7f1a3632f55a4ef0441f09db48e8a80544e29edfda3ef7f7f52facd3f912ab3fd2524d7d7b1117e
7
- data.tar.gz: 5dac3b8ff53a144f61106debf2dcfd44a0c4c05e31951d1b81c48c5c815382ea2c256a1d5a155a0c5668dae4efd1f9293e9200f32596688b603cf0b34f48a234
6
+ metadata.gz: 5baaa3f133d0e1cbd5e7e972645f107361088d9d11b5bebb38374573d898b67a07b318b4d19e1e5731a696dafe88a3b2ded6ba1c068b869e5bad750200905417
7
+ data.tar.gz: 4a88c972c98f54ac8b98538fec81f907797cb423f6fa89907cab21a58c29d5961b5e6bf156a3d2846a6d2fd831656696fa9a2afd76d2c2a6f3f5b62663db2c8d
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
44
44
  s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
45
45
  s.add_runtime_dependency("liquid", "~> 5.0")
46
46
  s.add_runtime_dependency("listen", "~> 3.0")
47
- s.add_runtime_dependency("rack-indifferent", ">= 1.2.0")
48
47
  s.add_runtime_dependency("rake", ">= 13.0")
49
48
  s.add_runtime_dependency("roda", "~> 3.46")
50
49
  s.add_runtime_dependency("rouge", "~> 3.0")
@@ -343,8 +343,8 @@ module Bridgetown
343
343
  end
344
344
 
345
345
  def order_with_warning(sort_key, resource, order)
346
- Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in" \
347
- " #{resource.relative_path}"
346
+ Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in " \
347
+ "#{resource.relative_path}"
348
348
  order
349
349
  end
350
350
 
@@ -58,9 +58,9 @@ module Bridgetown
58
58
  automation_command = args.empty? ? "bridgetown.automation.rb" : args[0]
59
59
 
60
60
  if args.empty? && !File.exist?("bridgetown.automation.rb")
61
- raise ArgumentError, "You must specify a path or a URL," \
62
- " or add bridgetown.automation.rb to the" \
63
- " current folder."
61
+ raise ArgumentError, "You must specify a path or a URL, " \
62
+ "or add bridgetown.automation.rb to the " \
63
+ "current folder."
64
64
  end
65
65
 
66
66
  Bridgetown.with_unbundled_env do
@@ -22,8 +22,8 @@ module Bridgetown
22
22
  desc: "Watch for changes and rebuild"
23
23
 
24
24
  def self.print_startup_message
25
- Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
26
- " (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
25
+ Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
26
+ "(codename \"#{Bridgetown::CODE_NAME.yellow}\")"
27
27
  end
28
28
 
29
29
  # Build your bridgetown site
@@ -45,8 +45,8 @@ module Bridgetown
45
45
  @site = Bridgetown::Site.new(config_options)
46
46
 
47
47
  if config_options.fetch("skip_initial_build", false)
48
- Bridgetown.logger.warn "Build Warning:", "Skipping the initial build." \
49
- " This may result in an out-of-date site."
48
+ Bridgetown.logger.warn "Build Warning:", "Skipping the initial build. " \
49
+ "This may result in an out-of-date site."
50
50
  else
51
51
  build_site(config_options)
52
52
  end
@@ -77,8 +77,8 @@ module Bridgetown
77
77
  end
78
78
  Bridgetown.logger.info "Generatingโ€ฆ"
79
79
  @site.process
80
- Bridgetown.logger.info "Done! ๐ŸŽ‰", "#{"Completed".bold.green} in less than" \
81
- " #{(Time.now - t).ceil(2)} seconds."
80
+ Bridgetown.logger.info "Done! ๐ŸŽ‰", "#{"Completed".bold.green} in less than " \
81
+ "#{(Time.now - t).ceil(2)} seconds."
82
82
 
83
83
  return unless config_options[:using_puma]
84
84
 
@@ -21,8 +21,8 @@ module Bridgetown
21
21
  desc: "Destination directory (defaults to output)"
22
22
  klass.class_option :root_dir,
23
23
  aliases: "-r",
24
- desc: "The top-level root folder" \
25
- " where config files are located"
24
+ desc: "The top-level root folder " \
25
+ "where config files are located"
26
26
  klass.class_option :plugins_dir,
27
27
  aliases: "-p",
28
28
  type: :array,
@@ -64,9 +64,9 @@ module Bridgetown
64
64
  require "irb/ext/save-history"
65
65
  require "amazing_print" unless options[:"bypass-ap"]
66
66
 
67
- Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
68
- " (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
69
- " consoleโ€ฆ"
67
+ Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
68
+ "(codename \"#{Bridgetown::CODE_NAME.yellow}\") " \
69
+ "consoleโ€ฆ"
70
70
  Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
71
71
  site = Bridgetown::Site.new(configuration_with_overrides(options))
72
72
 
@@ -80,8 +80,8 @@ module Bridgetown
80
80
  IRB.conf[:MAIN_CONTEXT] = irb.context
81
81
  Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
82
82
  Bridgetown.logger.info "",
83
- "You can also access #{"collections".cyan} or perform a" \
84
- " #{"reload!".cyan}"
83
+ "You can also access #{"collections".cyan} or perform a " \
84
+ "#{"reload!".cyan}"
85
85
 
86
86
  trap("SIGINT") do
87
87
  irb.signal_handle
@@ -62,8 +62,8 @@ module Bridgetown
62
62
  next unless paths.size > 1
63
63
 
64
64
  conflicting_urls = true
65
- Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
66
- " for the following pages: #{paths.join(", ")}"
65
+ Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination " \
66
+ "for the following pages: #{paths.join(", ")}"
67
67
  end
68
68
  conflicting_urls
69
69
  end
@@ -77,8 +77,8 @@ module Bridgetown
77
77
  urls_only_differ_by_case = true
78
78
  Bridgetown.logger.warn(
79
79
  "Warning:",
80
- "The following URLs only differ by case. On a case-insensitive file system one of the" \
81
- " URLs will be overwritten by the other: #{real_urls.join(", ")}"
80
+ "The following URLs only differ by case. On a case-insensitive file system one of " \
81
+ "the URLs will be overwritten by the other: #{real_urls.join(", ")}"
82
82
  )
83
83
  end
84
84
  urls_only_differ_by_case
@@ -121,7 +121,7 @@ module Bridgetown
121
121
  def url_exists?(url)
122
122
  return true unless url.nil? || url.empty?
123
123
 
124
- Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
124
+ Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, " \
125
125
  "you may encounter problems with some plugins."
126
126
  false
127
127
  end
@@ -132,7 +132,7 @@ module Bridgetown
132
132
  # Addressable::URI#parse only raises a TypeError
133
133
  # https://git.io/vFfbx
134
134
  rescue TypeError
135
- Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
135
+ Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, " \
136
136
  "check the value of `url` in your config file."
137
137
  false
138
138
  end
@@ -140,7 +140,7 @@ module Bridgetown
140
140
  def url_absolute(url)
141
141
  return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
142
142
 
143
- Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
143
+ Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, " \
144
144
  "check the value of `url` in your config file."
145
145
  false
146
146
  end
@@ -2,11 +2,6 @@
2
2
 
3
3
  # rubocop:disable Layout/LineLength
4
4
 
5
- if package_json["devDependencies"].key?("sass")
6
- say "Unable to migrate, project uses Sass. Please migrate to PostCSS first before migrating to esbuild."
7
- return
8
- end
9
-
10
5
  remove_file "webpack.config.js"
11
6
  remove_file "config/webpack.defaults.js"
12
7
 
@@ -16,7 +11,7 @@ default_postcss_config = File.expand_path("../../../site_template/postcss.config
16
11
  template default_postcss_config, "postcss.config.js"
17
12
 
18
13
  unless Bridgetown.environment.test?
19
- 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@3.1.4)
20
15
  redundant_packages = %w(esbuild-loader webpack webpack-cli webpack-manifest-plugin webpack-merge css-loader file-loader mini-css-extract-plugin postcss-loader)
21
16
 
22
17
  say "Installing required packages"
@@ -68,8 +68,8 @@ module Bridgetown
68
68
  if preserve_source_location?(new_site_path, options)
69
69
  say_status :conflict, "#{new_site_path} exists and is not empty.", :red
70
70
  Bridgetown.logger.abort_with(
71
- "Ensure #{new_site_path} is empty or else try again with `--force` to proceed and" \
72
- " overwrite any files."
71
+ "Ensure #{new_site_path} is empty or else try again with `--force` to proceed and " \
72
+ "overwrite any files."
73
73
  )
74
74
  end
75
75
 
@@ -194,18 +194,18 @@ module Bridgetown
194
194
  logger = Bridgetown.logger
195
195
  bt_start = "bin/bridgetown start"
196
196
  logger.info ""
197
- logger.info "Success!".green, "๐ŸŽ‰ Your new Bridgetown site was" \
198
- " generated in #{cli_path.cyan}."
197
+ logger.info "Success!".green, "๐ŸŽ‰ Your new Bridgetown site was " \
198
+ "generated in #{cli_path.cyan}."
199
199
  if options["skip-yarn"]
200
200
  logger.info "You can now #{"cd".cyan} #{cli_path.cyan} to get started."
201
- logger.info "You'll probably also want to #{"yarn install".cyan}" \
202
- " to load in your frontend assets."
201
+ logger.info "You'll probably also want to #{"yarn install".cyan} " \
202
+ "to load in your frontend assets."
203
203
  else
204
- logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan}" \
205
- " to get started."
204
+ logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan} " \
205
+ "to get started."
206
206
  end
207
- logger.info "Then check out our online documentation for" \
208
- " next steps: #{DOCSURL.cyan}"
207
+ logger.info "Then check out our online documentation for " \
208
+ "next steps: #{DOCSURL.cyan}"
209
209
 
210
210
  if @skipped_bundle
211
211
  logger.info "Bundle install skipped.".yellow
@@ -13,6 +13,9 @@ module Bridgetown
13
13
  end
14
14
 
15
15
  desc "list", "List information about installed plugins"
16
+ option :verbose,
17
+ type: :boolean,
18
+ desc: "Print the source path of each plugin"
16
19
  def list
17
20
  site = Bridgetown::Site.new(configuration_with_overrides(options))
18
21
  site.reset
@@ -32,7 +35,7 @@ module Bridgetown
32
35
  end
33
36
  end
34
37
 
35
- Bridgetown.logger.info("Source Manifests:", "---") unless pm.class.source_manifests.empty?
38
+ Bridgetown.logger.info("Source Manifests:", "----") unless pm.class.source_manifests.empty?
36
39
 
37
40
  pm.class.source_manifests.each do |manifest|
38
41
  Bridgetown.logger.info("Origin:", (manifest.origin || "n/a").to_s.green)
@@ -40,20 +43,27 @@ module Bridgetown
40
43
  Bridgetown.logger.info("Content:", (manifest.content || "n/a").to_s.cyan)
41
44
  Bridgetown.logger.info("Layouts:", (manifest.layouts || "n/a").to_s.cyan)
42
45
 
43
- Bridgetown.logger.info("", "---")
46
+ Bridgetown.logger.info("", "----")
44
47
  end
45
48
 
46
49
  unless Bridgetown.autoload? :Builder
47
50
  builders = Bridgetown::Builder.descendants
48
51
  Bridgetown.logger.info("Builders:", builders.length.to_s.yellow.bold)
49
52
 
50
- builders.each do |builder|
51
- name = builder.respond_to?(:custom_name) ? builder.custom_name : builder.name
53
+ builders.sort.each do |builder|
54
+ name = plugin_name_for(builder)
52
55
  name_components = name.split("::")
53
56
  last_name = name_components.pop
54
57
  name_components.push last_name.magenta
55
58
  Bridgetown.logger.info("", name_components.join("::"))
59
+ next unless options[:verbose]
60
+
61
+ Bridgetown.logger.info(
62
+ "", "PATH: " + builder_path_for(builder)
63
+ )
64
+ Bridgetown.logger.info("")
56
65
  end
66
+ Bridgetown.logger.info("", "----")
57
67
  end
58
68
 
59
69
  Bridgetown.logger.info("Converters:", site.converters.length.to_s.yellow.bold)
@@ -64,8 +74,16 @@ module Bridgetown
64
74
  last_name = name_components.pop
65
75
  name_components.push last_name.magenta
66
76
  Bridgetown.logger.info("", name_components.join("::"))
77
+ next unless options[:verbose]
78
+
79
+ Bridgetown.logger.info(
80
+ "", "PATH: " + converter_path_for(converter)
81
+ )
82
+ Bridgetown.logger.info("")
67
83
  end
68
84
 
85
+ Bridgetown.logger.info("", "----")
86
+
69
87
  Bridgetown.logger.info("Generators:", site.generators.length.to_s.yellow.bold)
70
88
 
71
89
  site.generators.each do |generator|
@@ -74,6 +92,12 @@ module Bridgetown
74
92
  last_name = name_components.pop
75
93
  name_components.push last_name.magenta
76
94
  Bridgetown.logger.info("", name_components.join("::"))
95
+ next unless options[:verbose]
96
+
97
+ Bridgetown.logger.info(
98
+ "", "PATH: " + generator_path_for(generator)
99
+ )
100
+ Bridgetown.logger.info("")
77
101
  end
78
102
  end
79
103
 
@@ -196,11 +220,23 @@ module Bridgetown
196
220
  protected
197
221
 
198
222
  def plugin_name_for(plugin)
199
- if plugin.class.respond_to?(:custom_name)
200
- plugin.class.custom_name
201
- else
202
- plugin.class.name
203
- end
223
+ klass = plugin.is_a?(Class) ? plugin : plugin.class
224
+ klass.respond_to?(:custom_name) ? klass.custom_name : klass.name
225
+ end
226
+
227
+ def builder_path_for(plugin)
228
+ klass = plugin.is_a?(Class) ? plugin : plugin.class
229
+ klass.instance_method(:build).source_location[0]
230
+ end
231
+
232
+ def converter_path_for(plugin)
233
+ klass = plugin.is_a?(Class) ? plugin : plugin.class
234
+ klass.instance_method(:convert).source_location[0]
235
+ end
236
+
237
+ def generator_path_for(plugin)
238
+ klass = plugin.is_a?(Class) ? plugin : plugin.class
239
+ klass.instance_method(:generate).source_location[0]
204
240
  end
205
241
  end
206
242
  end
@@ -4,12 +4,11 @@ module Bridgetown
4
4
  module Commands
5
5
  module Registrations
6
6
  def self.registrations
7
- @registrations || []
7
+ @registrations ||= []
8
8
  end
9
9
 
10
10
  def self.register(&block)
11
- @registrations ||= []
12
- @registrations.push(block)
11
+ registrations << block
13
12
  end
14
13
  end
15
14
  end
@@ -178,8 +178,8 @@ module Bridgetown
178
178
 
179
179
  Process.detach(pid)
180
180
  Bridgetown.logger.info "Server detached with pid '#{pid}'.", \
181
- "Run `pkill -f bridgetown' or `kill -9 #{pid}'" \
182
- " to stop the server."
181
+ "Run `pkill -f bridgetown' or `kill -9 #{pid}' " \
182
+ "to stop the server."
183
183
  else
184
184
  t = Thread.new { server.start }
185
185
  trap("INT") { server.shutdown }
@@ -136,7 +136,7 @@ module Bridgetown
136
136
  end
137
137
  rescue StandardError => e
138
138
  Bridgetown.logger.error "Component error:",
139
- "#{self.class} encountered an error while "\
139
+ "#{self.class} encountered an error while " \
140
140
  "rendering `#{self.class.path_for_errors}'"
141
141
  raise e
142
142
  end
@@ -23,7 +23,7 @@ module Bridgetown
23
23
  output.html_safe
24
24
  rescue StandardError => e
25
25
  Bridgetown.logger.error "Conversion error:",
26
- "#{converter.class} encountered an error while "\
26
+ "#{converter.class} encountered an error while " \
27
27
  "converting `#{document.relative_path}'"
28
28
  raise e
29
29
  end
@@ -53,7 +53,7 @@ module Bridgetown
53
53
  layout_output
54
54
  rescue StandardError => e
55
55
  Bridgetown.logger.error "Conversion error:",
56
- "#{converter.class} encountered an error while "\
56
+ "#{converter.class} encountered an error while " \
57
57
  "converting `#{document.relative_path}'"
58
58
  raise e
59
59
  end
@@ -208,8 +208,8 @@ module Bridgetown
208
208
  config = Utils.deep_merge_hashes(self, new_config)
209
209
  end
210
210
  rescue ArgumentError => e
211
- Bridgetown.logger.warn "WARNING:", "Error reading configuration. Using defaults" \
212
- " (and options)."
211
+ Bridgetown.logger.warn "WARNING:", "Error reading configuration. Using defaults " \
212
+ "(and options)."
213
213
  warn e
214
214
  end
215
215
 
@@ -16,7 +16,7 @@ document.addEventListener("turbo:visit", () => {
16
16
  { opacity: 1, transform: "translateY(0px) scale(1)" },
17
17
  { opacity: 0, transform: `translateY(${movement}) scale(${scale})` }
18
18
  ],
19
- { duration: 300, easing: "cubic-bezier(0.45, 0, 0.55, 1)" }
19
+ { duration: 300, easing: "cubic-bezier(0.45, 0, 0.55, 1)", fill: "forwards" }
20
20
  );
21
21
 
22
22
  Promise.all(main.getAnimations().map(animation => animation.finished)).then(() => {
@@ -79,10 +79,15 @@ module Bridgetown
79
79
  Erubi.h(input)
80
80
  end
81
81
 
82
- def partial(partial_name, options = {})
82
+ def partial(partial_name = nil, **options, &block)
83
+ partial_name = options[:template] if partial_name.nil? && options[:template]
83
84
  options.merge!(options[:locals]) if options[:locals]
84
- options[:content] = yield if block_given?
85
+ options[:content] = capture(&block) if block
85
86
 
87
+ _render_partial partial_name, options
88
+ end
89
+
90
+ def _render_partial(partial_name, options)
86
91
  partial_path = _partial_path(partial_name, "erb")
87
92
  tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"] ||= Tilt::ErubiTemplate.new(
88
93
  partial_path,
@@ -7,10 +7,7 @@ module Bridgetown
7
7
  class SerbeaView < ERBView
8
8
  include Serbea::Helpers
9
9
 
10
- def partial(partial_name, options = {}, &block)
11
- options.merge!(options[:locals]) if options[:locals]
12
- options[:content] = capture(&block) if block
13
-
10
+ def _render_partial(partial_name, options)
14
11
  partial_path = _partial_path(partial_name, "serb")
15
12
  tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"] ||=
16
13
  Tilt::SerbeaTemplate.new(partial_path)
@@ -152,8 +152,8 @@ module Bridgetown
152
152
  return attributes[key]
153
153
  end
154
154
 
155
- Bridgetown.logger.warn "key `#{method_name}' not found in attributes for" \
156
- " #{attributes[:id].presence || "new #{self.class}"}"
155
+ Bridgetown.logger.warn "key `#{method_name}' not found in attributes for " \
156
+ "#{attributes[:id].presence || "new #{self.class}"}"
157
157
  nil
158
158
  end
159
159
 
@@ -33,8 +33,8 @@ module Bridgetown
33
33
  rescue Roda::RodaError => e
34
34
  if e.message.include?("sessions plugin :secret option")
35
35
  raise Bridgetown::Errors::InvalidConfigurationError,
36
- "The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret'" \
37
- " and put the key in a ENV var you can use to configure the session in `roda_app.rb'"
36
+ "The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret' " \
37
+ "and put the key in a ENV var you can use to configure the session in `roda_app.rb'"
38
38
  end
39
39
 
40
40
  raise e
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rack/indifferent"
4
-
5
3
  begin
6
4
  # If it's in the Gemfile's :bridgetown_plugins group it's already been required, but we'll try
7
5
  # again just to be on the safe side:
@@ -12,7 +10,16 @@ end
12
10
  class Roda
13
11
  module RodaPlugins
14
12
  module BridgetownSSR
13
+ module InstanceMethods
14
+ # Helper shorthand for Bridgetown::Current.site
15
+ # @return [Bridgetown::Site]
16
+ def bridgetown_site
17
+ Bridgetown::Current.site
18
+ end
19
+ end
20
+
15
21
  def self.configure(app, _opts = {}, &block)
22
+ app.include Bridgetown::Filters::URLFilters
16
23
  app.opts[:bridgetown_site] =
17
24
  Bridgetown::Site.start_ssr!(loaders_manager: Bridgetown::Rack.loaders_manager, &block)
18
25
  end
@@ -21,14 +28,6 @@ class Roda
21
28
  register_plugin :bridgetown_ssr, BridgetownSSR
22
29
 
23
30
  module BridgetownBoot
24
- module InstanceMethods
25
- # Helper shorthand for Bridgetown::Current.site
26
- # @return [Bridgetown::Site]
27
- def bridgetown_site
28
- Bridgetown::Current.site
29
- end
30
- end
31
-
32
31
  Roda::RodaRequest.alias_method :_previous_roda_cookies, :cookies
33
32
 
34
33
  module RequestMethods
@@ -53,10 +52,13 @@ end
53
52
  module Bridgetown
54
53
  module Rack
55
54
  class Roda < ::Roda
55
+ SiteContext = Struct.new(:registers) # for use by Liquid-esque URL helpers
56
+
56
57
  plugin :hooks
57
58
  plugin :common_logger, Bridgetown::Rack::Logger.new($stdout), method: :info
58
59
  plugin :json
59
60
  plugin :json_parser
61
+ plugin :indifferent_params
60
62
  plugin :cookies
61
63
  plugin :streaming
62
64
  plugin :bridgetown_boot
@@ -141,6 +143,7 @@ module Bridgetown
141
143
  if self.class.opts[:bridgetown_site]
142
144
  # The site had previously been initialized via the bridgetown_ssr plugin
143
145
  Bridgetown::Current.site ||= self.class.opts[:bridgetown_site]
146
+ @context ||= SiteContext.new({ site: self.class.opts[:bridgetown_site] })
144
147
  end
145
148
  Bridgetown::Current.preloaded_configuration ||=
146
149
  self.class.opts[:bridgetown_preloaded_config]
@@ -181,6 +181,11 @@ module Bridgetown
181
181
  model.origin.id
182
182
  end
183
183
 
184
+ # @return [String]
185
+ def output_ext
186
+ destination&.output_ext
187
+ end
188
+
184
189
  def date
185
190
  data["date"] ||= site.time
186
191
  end
@@ -22,16 +22,16 @@ module Bridgetown
22
22
  @site = page.site
23
23
  end
24
24
 
25
- def partial(_partial_name, _options = {})
25
+ def partial(_partial_name = nil, **_options)
26
26
  raise "Must be implemented in a subclass"
27
27
  end
28
28
 
29
- def render(item, options = {}, &block)
29
+ def render(item, **options, &block)
30
30
  if item.respond_to?(:render_in)
31
31
  result = item.render_in(self, &block)
32
32
  result&.html_safe
33
33
  else
34
- partial(item, options, &block)&.html_safe
34
+ partial(item, **options, &block)&.html_safe
35
35
  end
36
36
  end
37
37
 
@@ -108,7 +108,7 @@ module Bridgetown
108
108
  self.class.mtimes[path] = mtime
109
109
 
110
110
  FileUtils.mkdir_p(File.dirname(dest_path))
111
- FileUtils.rm(dest_path) if File.exist?(dest_path)
111
+ FileUtils.rm_rf(dest_path)
112
112
  Bridgetown.logger.debug "Saving file:", dest_path
113
113
  copy_file(dest_path)
114
114
 
@@ -88,7 +88,7 @@ module Bridgetown
88
88
  "class=\"language-#{@lang.to_s.tr("+", "-")}\"",
89
89
  "data-lang=\"#{@lang}\"",
90
90
  ].join(" ")
91
- "<figure class=\"highlight\"><pre><code #{code_attributes}>"\
91
+ "<figure class=\"highlight\"><pre><code #{code_attributes}>" \
92
92
  "#{code.chomp}</code></pre></figure>"
93
93
  end
94
94
  end
@@ -80,7 +80,7 @@ module Bridgetown
80
80
  next unless @post.deprecated_equality document
81
81
 
82
82
  Bridgetown::Deprecator.deprecation_message(
83
- "A call to "\
83
+ "A call to " \
84
84
  "'{% post_url #{@post.name} %}' did not match " \
85
85
  "a post using the new matching method of checking name " \
86
86
  "(path-date-slug) equality. Please make sure that you " \
@@ -100,7 +100,7 @@ module Bridgetown
100
100
  winner = pool.find { |key| @placeholders.key?(key) }
101
101
  if winner.nil?
102
102
  raise NoMethodError,
103
- "The URL template doesn't have #{pool.join(" or ")} keys. "\
103
+ "The URL template doesn't have #{pool.join(" or ")} keys. " \
104
104
  "Check your permalink template!"
105
105
  end
106
106
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.1.0.beta2"
4
+ VERSION = "1.1.0.beta3"
5
5
  CODE_NAME = "Belmont"
6
6
  end
@@ -99,8 +99,8 @@ module Bridgetown
99
99
 
100
100
  site.process
101
101
  end
102
- Bridgetown.logger.info "Done! ๐ŸŽ‰", "#{"Completed".bold.green} in less than" \
103
- " #{(Time.now - time).ceil(2)} seconds."
102
+ Bridgetown.logger.info "Done! ๐ŸŽ‰", "#{"Completed".bold.green} in less than " \
103
+ "#{(Time.now - time).ceil(2)} seconds."
104
104
  rescue StandardError => e
105
105
  Bridgetown::Errors.print_build_error(e, trace: options[:trace])
106
106
  end
@@ -24,6 +24,10 @@ gem "bridgetown", "~> <%= Bridgetown::VERSION %>"
24
24
  # Uncomment to add file-based dynamic routing to your project:
25
25
  # gem "bridgetown-routes", "~> <%= Bridgetown::VERSION %>", group: :bridgetown_plugins
26
26
 
27
+ # Uncomment to use the Inspectors API to manipulate the output
28
+ # of your HTML or XML resources:
29
+ # gem "nokogiri", "~> 1.13"
30
+
27
31
  # Puma is a Rack-compatible server used by Bridgetown
28
32
  # (you can optionally limit this to the "development" group)
29
33
  gem "puma", "~> 5.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.beta2
4
+ version: 1.1.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-02 00:00:00.000000000 Z
11
+ date: 2022-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -218,20 +218,6 @@ dependencies:
218
218
  - - "~>"
219
219
  - !ruby/object:Gem::Version
220
220
  version: '3.0'
221
- - !ruby/object:Gem::Dependency
222
- name: rack-indifferent
223
- requirement: !ruby/object:Gem::Requirement
224
- requirements:
225
- - - ">="
226
- - !ruby/object:Gem::Version
227
- version: 1.2.0
228
- type: :runtime
229
- prerelease: false
230
- version_requirements: !ruby/object:Gem::Requirement
231
- requirements:
232
- - - ">="
233
- - !ruby/object:Gem::Version
234
- version: 1.2.0
235
221
  - !ruby/object:Gem::Dependency
236
222
  name: rake
237
223
  requirement: !ruby/object:Gem::Requirement