bridgetown-core 1.1.0 → 1.2.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bridgetown +1 -3
  3. data/bridgetown-core.gemspec +7 -6
  4. data/lib/bridgetown-core/collection.rb +5 -2
  5. data/lib/bridgetown-core/commands/base.rb +1 -1
  6. data/lib/bridgetown-core/commands/build.rb +18 -5
  7. data/lib/bridgetown-core/commands/clean.rb +1 -1
  8. data/lib/bridgetown-core/commands/concerns/actions.rb +2 -4
  9. data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +7 -8
  10. data/lib/bridgetown-core/commands/console.rb +20 -1
  11. data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +5 -0
  12. data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +8 -7
  13. data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
  14. data/lib/bridgetown-core/commands/plugins.rb +46 -32
  15. data/lib/bridgetown-core/commands/serve.rb +1 -2
  16. data/lib/bridgetown-core/commands/start.rb +0 -8
  17. data/lib/bridgetown-core/component.rb +50 -0
  18. data/lib/bridgetown-core/concerns/site/configurable.rb +22 -18
  19. data/lib/bridgetown-core/concerns/site/localizable.rb +2 -6
  20. data/lib/bridgetown-core/concerns/site/processable.rb +0 -1
  21. data/lib/bridgetown-core/concerns/site/ssr.rb +0 -1
  22. data/lib/bridgetown-core/concerns/transformable.rb +5 -2
  23. data/lib/bridgetown-core/configuration/configuration_dsl.rb +146 -0
  24. data/lib/bridgetown-core/configuration.rb +90 -15
  25. data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +3 -1
  26. data/lib/bridgetown-core/configurations/lit/esbuild-plugins.js +5 -2
  27. data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
  28. data/lib/bridgetown-core/converter.rb +8 -0
  29. data/lib/bridgetown-core/converters/identity.rb +2 -0
  30. data/lib/bridgetown-core/converters/liquid_templates.rb +1 -0
  31. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
  32. data/lib/bridgetown-core/converters/markdown.rb +2 -0
  33. data/lib/bridgetown-core/current.rb +19 -5
  34. data/lib/bridgetown-core/deprecator.rb +4 -37
  35. data/lib/bridgetown-core/filters.rb +1 -3
  36. data/lib/bridgetown-core/generated_page.rb +5 -0
  37. data/lib/bridgetown-core/helpers.rb +119 -8
  38. data/lib/bridgetown-core/hooks.rb +1 -0
  39. data/lib/bridgetown-core/kramdown/parser/gfm.rb +1 -1
  40. data/lib/bridgetown-core/layout.rb +1 -1
  41. data/lib/bridgetown-core/model/base.rb +11 -12
  42. data/lib/bridgetown-core/model/builder_origin.rb +1 -1
  43. data/lib/bridgetown-core/model/origin.rb +5 -1
  44. data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
  45. data/lib/bridgetown-core/model/repo_origin.rb +7 -7
  46. data/lib/bridgetown-core/plugin.rb +2 -6
  47. data/lib/bridgetown-core/plugin_manager.rb +121 -42
  48. data/lib/bridgetown-core/rack/boot.rb +3 -7
  49. data/lib/bridgetown-core/rack/logger.rb +1 -0
  50. data/lib/bridgetown-core/rack/roda.rb +39 -45
  51. data/lib/bridgetown-core/rack/routes.rb +2 -6
  52. data/lib/bridgetown-core/rack/static_indexes.rb +1 -2
  53. data/lib/bridgetown-core/reader.rb +39 -50
  54. data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
  55. data/lib/bridgetown-core/resource/base.rb +17 -1
  56. data/lib/bridgetown-core/ruby_template_view.rb +12 -8
  57. data/lib/bridgetown-core/site.rb +10 -3
  58. data/lib/bridgetown-core/slot.rb +41 -0
  59. data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +23 -9
  60. data/lib/bridgetown-core/utils/ansi.rb +1 -1
  61. data/lib/bridgetown-core/utils/aux.rb +7 -6
  62. data/lib/bridgetown-core/utils/initializers.rb +45 -0
  63. data/lib/bridgetown-core/utils/loaders_manager.rb +2 -2
  64. data/lib/bridgetown-core/utils/require_gems.rb +11 -35
  65. data/lib/bridgetown-core/utils/ruby_front_matter.rb +2 -3
  66. data/lib/bridgetown-core/{converters/smartypants.rb → utils/smarty_pants_converter.rb} +5 -24
  67. data/lib/bridgetown-core/utils.rb +1 -0
  68. data/lib/bridgetown-core/version.rb +2 -2
  69. data/lib/bridgetown-core/watcher.rb +1 -8
  70. data/lib/bridgetown-core.rb +89 -6
  71. data/lib/roda/plugins/bridgetown_boot.rb +25 -0
  72. data/lib/roda/plugins/bridgetown_ssr.rb +23 -0
  73. data/lib/roda/plugins/initializers.rb +17 -0
  74. data/lib/site_template/.gitignore +1 -0
  75. data/lib/site_template/Gemfile.erb +1 -1
  76. data/lib/site_template/TEMPLATES/erb/_layouts/default.erb +2 -2
  77. data/lib/site_template/TEMPLATES/erb/_layouts/page.erb +1 -1
  78. data/lib/site_template/TEMPLATES/erb/_layouts/post.erb +1 -1
  79. data/lib/site_template/TEMPLATES/liquid/_layouts/default.liquid +2 -2
  80. data/lib/site_template/TEMPLATES/liquid/_layouts/page.liquid +1 -1
  81. data/lib/site_template/TEMPLATES/liquid/_layouts/post.liquid +1 -1
  82. data/lib/site_template/TEMPLATES/serbea/_layouts/default.serb +2 -2
  83. data/lib/site_template/TEMPLATES/serbea/_layouts/page.serb +1 -1
  84. data/lib/site_template/TEMPLATES/serbea/_layouts/post.serb +1 -1
  85. data/lib/site_template/config/initializers.rb +43 -0
  86. data/lib/site_template/package.json.erb +1 -1
  87. data/lib/site_template/server/roda_app.rb +2 -8
  88. metadata +17 -9
@@ -6,12 +6,15 @@ module Bridgetown
6
6
  # (requires a `converter` method to be present on the including class)
7
7
  #
8
8
  # @param document [Bridgetown::GeneratedPage, Bridgetown::Resource::Base]
9
+ # @param alternate_content [String, nil] Pass in content if you don't want to use document's
9
10
  # @return String
10
11
  # @yieldparam converter [Bridgetown::Converter]
11
12
  # @yieldparam index [Integer] index of the conversion step
12
13
  # @yieldparam output [String]
13
- def transform_content(document)
14
- converters.each_with_index.inject(document.content.to_s) do |content, (converter, index)|
14
+ def transform_content(document, alternate_content: nil)
15
+ converters.each_with_index.inject(
16
+ (alternate_content || document.content).to_s
17
+ ) do |content, (converter, index)|
15
18
  output = if converter.method(:convert).arity == 1
16
19
  converter.convert content
17
20
  else
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ class Configuration
5
+ class ConfigurationDSL < Bridgetown::Utils::RubyFrontMatter
6
+ attr_reader :context
7
+
8
+ # @yieldself [ConfigurationDSL]
9
+ def init(name, require_gem: true, require_initializer: true, **kwargs, &block) # rubocop:todo Metrics
10
+ return if @scope.initializers.key?(name.to_sym) &&
11
+ @scope.initializers[name.to_sym].completed
12
+
13
+ initializer = _setup_initializer(
14
+ name: name, require_gem: require_gem, require_initializer: require_initializer
15
+ )
16
+
17
+ return unless initializer.nil? || initializer.completed == false
18
+
19
+ set :init_params do
20
+ block ? set(name, &block) : set(name, kwargs)
21
+ end
22
+
23
+ if initializer.nil?
24
+ Bridgetown.logger.warn("Initializing:",
25
+ "The `#{name}' initializer could not be found")
26
+ return
27
+ end
28
+
29
+ Bridgetown.logger.debug "Initializing:", name
30
+ @scope.initializers[name.to_sym].block.(self, **@scope.init_params[name].symbolize_keys)
31
+ initializer.completed = true
32
+ end
33
+
34
+ def only(*context, &block)
35
+ return unless context.any? { _1 == @context }
36
+
37
+ instance_exec(&block)
38
+ end
39
+
40
+ def except(*context, &block)
41
+ return if context.any? { _1 == @context }
42
+
43
+ instance_exec(&block)
44
+ end
45
+
46
+ def hook(
47
+ owner,
48
+ event,
49
+ priority: Bridgetown::Hooks::DEFAULT_PRIORITY,
50
+ &block
51
+ )
52
+ Bridgetown::Hooks.register_one(owner, event, priority: priority, &block)
53
+ end
54
+
55
+ def source_manifest(**kwargs)
56
+ @scope.source_manifests << SourceManifest.new(**kwargs)
57
+ end
58
+
59
+ def builder(klass = nil, &block)
60
+ return klass.register if klass.is_a?(Class) && klass < Bridgetown::Builder
61
+
62
+ unless klass.is_a?(Symbol)
63
+ raise "You must supply a constant symbol to register an inline builder"
64
+ end
65
+
66
+ Object.const_set(
67
+ klass, Class.new(Bridgetown::Builder, &block).tap(&:register)
68
+ )
69
+ end
70
+
71
+ def roda(&block)
72
+ @scope.roda_initializers << block
73
+ end
74
+
75
+ def method_missing(key, *value, &block) # rubocop:disable Style/MissingRespondToMissing
76
+ return get(key) if value.length.zero? && block.nil?
77
+
78
+ set(key, value[0], &block)
79
+ end
80
+
81
+ def get(key)
82
+ unless @data.key?(key)
83
+ Bridgetown.logger.debug("Initializing:", "Uh oh, missing key `#{key}' in configuration")
84
+ end
85
+
86
+ super
87
+ end
88
+
89
+ def set(key, value = nil, &block)
90
+ # Handle nested data within a block
91
+ if block
92
+ value = self.class.new(scope: @scope).tap do |fm|
93
+ fm.instance_exec(&block)
94
+ end.to_h
95
+ end
96
+
97
+ key = key.to_s.delete_suffix("=") if key.to_s.ends_with?("=")
98
+
99
+ @data[key] = if @data[key].is_a?(Hash) && value.is_a?(Hash)
100
+ Bridgetown::Utils.deep_merge_hashes(@data[key], value)
101
+ else
102
+ value
103
+ end
104
+ end
105
+
106
+ def reflect(name, require_gem: true, require_initializer: true)
107
+ initializer = _setup_initializer(
108
+ name: name, require_gem: require_gem, require_initializer: require_initializer
109
+ )
110
+
111
+ if initializer.nil?
112
+ Bridgetown.logger.info("Reflection:",
113
+ "The `#{name}' initializer could not be found")
114
+ return
115
+ end
116
+
117
+ Bridgetown.logger.info(
118
+ "Reflection:",
119
+ "The #{name.to_s.yellow} initializer accepts the following options:"
120
+ )
121
+ initializer.block.parameters.each do |param|
122
+ next if param[0] == :opt
123
+
124
+ Bridgetown.logger.info("",
125
+ "* #{param[1].to_s.cyan}#{" (required)" if param[0] == :keyreq}")
126
+ end
127
+ end
128
+
129
+ # @return [Bridgetown::Configuration::Initializer]
130
+ def _setup_initializer(name:, require_gem:, require_initializer:)
131
+ Bridgetown::PluginManager.require_gem(name) if require_gem && !_in_require_denylist?(name)
132
+
133
+ if require_initializer
134
+ init_file_name = File.join(@scope.root_dir, "config", "#{name}.rb")
135
+ require(init_file_name) if File.exist?(init_file_name)
136
+ end
137
+
138
+ @scope.initializers[name.to_sym]
139
+ end
140
+
141
+ def _in_require_denylist?(name)
142
+ REQUIRE_DENYLIST.include?(name.to_sym)
143
+ end
144
+ end
145
+ end
146
+ end
@@ -1,20 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- # Holds the processed configuration loaded from the YAML config file.
5
- #
6
- # @todo refactor this whole object! Already had to fix obscure
7
- # bugs just making minor changes, and all the indirection is
8
- # quite hard to decipher. -JW
4
+ # The primary configuration object for a Bridgetown project
9
5
  class Configuration < HashWithDotAccess::Hash
10
- # Default options. Overridden by values in bridgetown.config.yml.
6
+ REQUIRE_DENYLIST = %i(parse_routes ssr) # rubocop:disable Style/MutableConstant
7
+
8
+ Initializer = Struct.new(:name, :block, :completed, keyword_init: true) do
9
+ def to_s
10
+ "#{name} (Initializer)"
11
+ end
12
+ end
13
+
14
+ SourceManifest = Struct.new(:origin, :components, :content, :layouts, keyword_init: true)
15
+
16
+ Preflight = Struct.new(:source_manifests, :initializers, keyword_init: true) do
17
+ def initialize(*)
18
+ super
19
+ self.source_manifests ||= Set.new
20
+ end
21
+ end
22
+
23
+ require_relative "configuration/configuration_dsl"
24
+
25
+ # Default options. Overridden by values in bridgetown.config.yml or initializers.
11
26
  # Strings rather than symbols are used for compatibility with YAML.
12
27
  DEFAULTS = {
13
28
  # Where things are
14
29
  "root_dir" => Dir.pwd,
15
30
  "plugins_dir" => "plugins",
16
- "source" => File.join(Dir.pwd, "src"),
17
- "destination" => File.join(Dir.pwd, "output"),
31
+ "source" => "src",
32
+ "destination" => "output",
18
33
  "collections_dir" => "",
19
34
  "cache_dir" => ".bridgetown-cache",
20
35
  "layouts_dir" => "_layouts",
@@ -87,12 +102,15 @@ module Bridgetown
87
102
  },
88
103
  }.each_with_object(Configuration.new) { |(k, v), hsh| hsh[k] = v.freeze }.freeze
89
104
 
90
- # The modern default config file name is bridgetown.config.EXT, but we also
91
- # need to check for _config.EXT as a backward-compatibility nod to our
92
- # progenitor
105
+ # TODO: Deprecated. Remove support for _config as well as toml in the next release.
93
106
  CONFIG_FILE_PREFIXES = %w(bridgetown.config _config).freeze
94
107
  CONFIG_FILE_EXTS = %w(yml yaml toml).freeze
95
108
 
109
+ # @return [Hash<Symbol, Initializer>]
110
+ attr_accessor :initializers
111
+
112
+ attr_writer :source_manifests, :roda_initializers
113
+
96
114
  class << self
97
115
  # Static: Produce a Configuration ready for use in a Site.
98
116
  # It takes the input, fills in the defaults where values do not exist.
@@ -101,7 +119,7 @@ module Bridgetown
101
119
  #
102
120
  # Returns a Configuration filled with defaults.
103
121
  def from(user_config, starting_defaults = DEFAULTS)
104
- Utils.deep_merge_hashes(starting_defaults.deep_dup, Configuration[user_config])
122
+ Utils.deep_merge_hashes(starting_defaults.deep_dup, Configuration.new(user_config))
105
123
  .merge_environment_specific_options!
106
124
  .setup_load_paths!
107
125
  .setup_locales
@@ -111,6 +129,43 @@ module Bridgetown
111
129
  end
112
130
  end
113
131
 
132
+ def run_initializers!(context:)
133
+ initializers_file = File.join(root_dir, "config", "initializers.rb")
134
+ return unless File.file?(initializers_file)
135
+
136
+ require initializers_file
137
+
138
+ return unless initializers # no initializers have been set up
139
+
140
+ init_init = initializers[:init]
141
+ return unless init_init && !init_init.completed
142
+
143
+ Bridgetown.logger.debug "Initializing:", "Running initializers with `#{context}' context in:"
144
+ Bridgetown.logger.debug "", initializers_file
145
+ self.init_params = {}
146
+ dsl = ConfigurationDSL.new(scope: self, data: self)
147
+ dsl.instance_variable_set(:@context, context)
148
+ dsl.instance_exec(dsl, &init_init.block)
149
+
150
+ self
151
+ end
152
+
153
+ # @return [Set<SourceManifest>]
154
+ def source_manifests
155
+ @source_manifests ||= Set.new
156
+ end
157
+
158
+ # @return [Array<Proc>]
159
+ def roda_initializers
160
+ @roda_initializers ||= []
161
+ end
162
+
163
+ def initialize_roda_app(app)
164
+ roda_initializers.each do |initializer|
165
+ initializer.(app)
166
+ end
167
+ end
168
+
114
169
  def get_config_value_with_override(config_key, override)
115
170
  override[config_key] || self[config_key] || DEFAULTS[config_key]
116
171
  end
@@ -143,16 +198,32 @@ module Bridgetown
143
198
  end
144
199
  alias_method :verbose?, :verbose
145
200
 
146
- def safe_load_file(filename)
201
+ def safe_load_file(filename) # rubocop:todo Metrics
147
202
  case File.extname(filename)
148
203
  when %r!\.toml!i
204
+ Deprecator.deprecation_message(
205
+ "TOML configurations will no longer be supported in the next version of Bridgetown." \
206
+ "Use initializers or a .yaml config instead."
207
+ )
149
208
  Bridgetown::Utils::RequireGems.require_with_graceful_fail("tomlrb") unless defined?(Tomlrb)
150
209
  Tomlrb.load_file(filename)
151
210
  when %r!\.ya?ml!i
211
+ if File.basename(filename, ".*") == "_config"
212
+ Deprecator.deprecation_message(
213
+ "YAML configurations named `_config.y(a)ml' will no longer be supported in the next " \
214
+ "version of Bridgetown. Rename to `bridgetown.config.yml' instead."
215
+ )
216
+ end
217
+ if File.extname(filename) == ".yaml"
218
+ Deprecator.deprecation_message(
219
+ "YAML configurations ending in `.yaml' will no longer be supported in the next " \
220
+ "version of Bridgetown. Rename to use `.yml' extension instead."
221
+ )
222
+ end
152
223
  YAMLParser.load_file(filename) || {}
153
224
  else
154
225
  raise ArgumentError,
155
- "No parser for '#{filename}' is available. Use a .y(a)ml or .toml file instead."
226
+ "No parser for '#{filename}' is available. Use a .y(a)ml file instead."
156
227
  end
157
228
  rescue Psych::DisallowedClass => e
158
229
  raise "Unable to parse `#{File.basename(filename)}'. #{e.message}"
@@ -252,7 +323,11 @@ module Bridgetown
252
323
  self
253
324
  end
254
325
 
255
- def setup_load_paths!
326
+ def setup_load_paths! # rubocop:todo Metrics
327
+ self[:root_dir] = File.expand_path(self[:root_dir])
328
+ self[:source] = File.expand_path(self[:source], self[:root_dir])
329
+ self[:destination] = File.expand_path(self[:destination], self[:root_dir])
330
+
256
331
  if self[:plugins_use_zeitwerk]
257
332
  autoload_paths.unshift({
258
333
  path: self[:plugins_dir],
@@ -24,7 +24,9 @@ jobs:
24
24
  - run: yarn install
25
25
 
26
26
  - name: Build
27
- run: bin/bridgetown deploy
27
+ env:
28
+ BRIDGETOWN_ENV: production
29
+ run: bin/bridgetown deploy
28
30
 
29
31
  - name: Deploy
30
32
  uses: peaceiris/actions-gh-pages@v3
@@ -5,14 +5,17 @@
5
5
  // This plugin will let you import `.lit.css` files as sidecar stylesheets.
6
6
  // Read https://edge.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
7
7
  const { litCssPlugin } = require("esbuild-plugin-lit-css")
8
- const postCssConfig = require("postcss-load-config").sync()
9
- const postCssProcessor = require("postcss")([...postCssConfig.plugins])
8
+ const postcssrc = require("postcss-load-config")
9
+ const postcss = require("postcss")
10
10
 
11
11
  module.exports = {
12
12
  plugins: [
13
13
  litCssPlugin({
14
14
  filter: /\.lit\.css$/,
15
15
  transform: async (css, { filePath }) => {
16
+ const postCssConfig = await postcssrc()
17
+ const postCssProcessor = postcss([...postCssConfig.plugins])
18
+
16
19
  const results = await postCssProcessor.process(css, { ...postCssConfig.options, from: filePath })
17
20
  return results.css
18
21
  }
@@ -38,7 +38,7 @@ create_file "test/helper.rb" do
38
38
  include Rails::Dom::Testing::Assertions
39
39
 
40
40
  def site
41
- @site ||= Bridgetown.sites.first
41
+ @site ||= Bridgetown::Current.site
42
42
  end
43
43
 
44
44
  def nokogiri(input)
@@ -14,6 +14,14 @@ module Bridgetown
14
14
  self.extname_list ||= []
15
15
  self.extname_list += extnames.map { |e| ".#{e.to_s.downcase}" }
16
16
  end
17
+
18
+ def supports_slots?
19
+ @support_slots == true
20
+ end
21
+
22
+ def support_slots(bool = true) # rubocop:disable Style/OptionalBooleanParameter
23
+ @support_slots = bool == true
24
+ end
17
25
  end
18
26
 
19
27
  # Initialize the converter.
@@ -7,6 +7,8 @@ module Bridgetown
7
7
  class Identity < Converter
8
8
  priority :lowest
9
9
 
10
+ support_slots
11
+
10
12
  # Public: Does the given extension match this converter's list of acceptable extensions?
11
13
  # Takes one argument: the file's extension (including the dot).
12
14
  #
@@ -89,6 +89,7 @@ module Bridgetown
89
89
  payload["paginator"] = document.respond_to?(:paginator) ? document.paginator.to_liquid : nil
90
90
  payload["layout"] = @layout ? @layout.to_liquid.merge({ data: @layout.data }) : {}
91
91
  payload["content"] = content
92
+ payload["data"] = payload["page"].data
92
93
  end
93
94
 
94
95
  def liquid_context
@@ -1,4 +1,4 @@
1
- # Frozen-string-literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Kramdown
4
4
  # A Kramdown::Document subclass meant to optimize memory usage from initializing
@@ -5,6 +5,8 @@ module Bridgetown
5
5
  # Markdown converter.
6
6
  # For more info on converters see https://bridgetownrb.com/docs/plugins/converters/
7
7
  class Markdown < Converter
8
+ support_slots
9
+
8
10
  def initialize(config = {})
9
11
  super
10
12
 
@@ -2,13 +2,27 @@
2
2
 
3
3
  module Bridgetown
4
4
  class Current < ActiveSupport::CurrentAttributes
5
- # @!method self.site
6
- # @return [Bridgetown::Site]
7
-
8
- attribute :site
9
-
10
5
  # @!method self.preloaded_configuration
11
6
  # @return [Bridgetown::Configuration]
12
7
  attribute :preloaded_configuration
8
+
9
+ # @return [Bridgetown::Site, nil]
10
+ def self.site
11
+ sites[:main]
12
+ end
13
+
14
+ def self.site=(new_site)
15
+ sites[:main] = new_site
16
+ end
17
+
18
+ # @!method self.sites
19
+ # @return [Hash<Symbol, Bridgetown::Site>]
20
+
21
+ attribute :sites
22
+
23
+ def initialize
24
+ super
25
+ @attributes[:sites] = {}
26
+ end
13
27
  end
14
28
  end
@@ -2,45 +2,12 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Deprecator
5
- extend self
6
-
7
- def process(args)
8
- arg_is_present? args, "--server", "The --server command has been replaced by the \
9
- 'serve' subcommand."
10
- arg_is_present? args, "--serve", "The --serve command has been replaced by the \
11
- 'serve' subcommand."
12
- arg_is_present? args, "--no-server", "To build Bridgetown without launching a server, \
13
- use the 'build' subcommand."
14
- arg_is_present? args, "--auto", "The switch '--auto' has been replaced with \
15
- '--watch'."
16
- arg_is_present? args, "--no-auto", "To disable auto-replication, simply leave off \
17
- the '--watch' switch."
18
- arg_is_present? args, "--url", "The 'url' setting can only be set in your \
19
- config files."
20
- no_subcommand(args)
21
- end
22
-
23
- def no_subcommand(args)
24
- unless args.empty? ||
25
- args.first !~ %r(!/^--/!) || %w(--help --version).include?(args.first)
26
- deprecation_message "Bridgetown now uses subcommands instead of just switches. \
27
- Run `bridgetown help` to find out more."
28
- abort
29
- end
30
- end
31
-
32
- def arg_is_present?(args, deprecated_argument, message)
33
- deprecation_message(message) if args.include?(deprecated_argument)
34
- end
35
-
36
- def deprecation_message(message)
5
+ def self.deprecation_message(message)
37
6
  Bridgetown.logger.warn "Deprecation:", message
38
- end
39
7
 
40
- def defaults_deprecate_type(old, current)
41
- Bridgetown.logger.warn "Defaults:", "The '#{old}' type has become '#{current}'."
42
- Bridgetown.logger.warn "Defaults:", "Please update your front-matter defaults to use \
43
- 'type: #{current}'."
8
+ caller_locations[0..1].each_with_index do |backtrace_line, index|
9
+ Bridgetown.logger.debug "#{index + 1}:", backtrace_line
10
+ end
44
11
  end
45
12
  end
46
13
  end
@@ -26,9 +26,7 @@ module Bridgetown
26
26
  #
27
27
  # Returns the smart-quotified String.
28
28
  def smartify(input)
29
- @context.registers[:site].find_converter_instance(
30
- Bridgetown::Converters::SmartyPants
31
- ).convert(input.to_s)
29
+ Utils::SmartyPantsConverter.new(@context.registers[:site].config).convert(input.to_s)
32
30
  end
33
31
 
34
32
  # Slugify a filename or title.
@@ -65,6 +65,11 @@ module Bridgetown
65
65
  data[property]
66
66
  end
67
67
 
68
+ # @return [Array<Bridgetown::Slot>]
69
+ def slots
70
+ @slots ||= []
71
+ end
72
+
68
73
  # The generated directory into which the page will be placed
69
74
  # upon generation. This is derived from the permalink or, if
70
75
  # permalink is absent, will be '/'