bridgetown-core 2.1.0.beta3 → 2.1.0
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/lib/bridgetown-core/collection.rb +3 -3
- data/lib/bridgetown-core/concerns/site/configurable.rb +1 -1
- data/lib/bridgetown-core/concerns/site/extensible.rb +1 -1
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +144 -2
- data/lib/bridgetown-core/configuration.rb +7 -2
- data/lib/bridgetown-core/hooks.rb +1 -1
- data/lib/bridgetown-core/static_file.rb +1 -1
- data/lib/bridgetown-core.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f37e7273caf13736dccb6a376882b50b2c36c4ead3c70456800f9e2ce2f83af
|
|
4
|
+
data.tar.gz: aff912422ccd046462db776b59ca3f6a5dd613d9e0635e8bc9815b8411ff56d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa2cba9af2d353e02e6a1bc725f6e86fdfd4c0ca5f8855643c41f26c7ed3f29fcd8e72c4638268560c5983643b056fdc5837dc1450ae8336148d4e5ace80979c
|
|
7
|
+
data.tar.gz: 54bbee47d175e53a34f104880ede10e9688eafbb436b6656b7f791ffef81aee343bf21c7deccede2b2eecafc6af5937d6ec82a8a51debe489585d9d99cb34078
|
|
@@ -150,7 +150,7 @@ module Bridgetown
|
|
|
150
150
|
alias_method :directory, :absolute_path
|
|
151
151
|
|
|
152
152
|
# The full path to the folder containing the collection, with
|
|
153
|
-
#
|
|
153
|
+
# optional subpaths.
|
|
154
154
|
#
|
|
155
155
|
# @param *files [Array<String>] any other path pieces relative to the
|
|
156
156
|
# folder to append to the path
|
|
@@ -190,7 +190,7 @@ module Bridgetown
|
|
|
190
190
|
|
|
191
191
|
# Produce a sanitized label name
|
|
192
192
|
# Label names may not contain anything but alphanumeric characters,
|
|
193
|
-
#
|
|
193
|
+
# underscores, and hyphens.
|
|
194
194
|
#
|
|
195
195
|
# @param label [String] the possibly-unsafe label
|
|
196
196
|
# @return [String] sanitized version of the label.
|
|
@@ -210,7 +210,7 @@ module Bridgetown
|
|
|
210
210
|
end
|
|
211
211
|
|
|
212
212
|
# Whether the collection's resources ought to be written as individual
|
|
213
|
-
#
|
|
213
|
+
# files in the output.
|
|
214
214
|
#
|
|
215
215
|
# @return [Boolean] true if the 'write' metadata is true, false otherwise.
|
|
216
216
|
def write?
|
|
@@ -45,7 +45,7 @@ class Bridgetown::Site
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Returns the current instance of {FrontMatter::Defaults} or
|
|
48
|
-
#
|
|
48
|
+
# creates a new instance {FrontMatter::Defaults} if it doesn't already exist.
|
|
49
49
|
#
|
|
50
50
|
# @return [FrontMatter::Defaults]
|
|
51
51
|
# Returns an instance of {FrontMatter::Defaults}
|
|
@@ -48,7 +48,7 @@ class Bridgetown::Site
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# Create an array of instances of the subclasses of the class
|
|
51
|
-
#
|
|
51
|
+
# passed in as argument.
|
|
52
52
|
#
|
|
53
53
|
# @param klass [Class] class which is the parent of the subclasses.
|
|
54
54
|
# @return [Array<Converter, Generator>] Returns an array of instances of
|
|
@@ -7,7 +7,18 @@ module Bridgetown
|
|
|
7
7
|
|
|
8
8
|
attr_reader :context
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# Initialize a Bridgetown plugin, optionally passing along configuration data. By default,
|
|
11
|
+
# requires the associated Ruby gem as well, but this can be switched off for local
|
|
12
|
+
# initializer files.
|
|
13
|
+
#
|
|
14
|
+
# @param name [Symbol]
|
|
15
|
+
# @param require_gem [Boolean] set `false` if you don't want the named gem to be required
|
|
16
|
+
# @param require_initializer [Boolean] set `false` if the named file in your `config` folder
|
|
17
|
+
# shouldn't get processed as an initializer
|
|
18
|
+
# @param kwargs [Hash] pass keyword arguments as configuration along to the plugin. This can
|
|
19
|
+
# also be accomplished via a block using "Ruby front matter" syntax
|
|
20
|
+
# @yieldreceiver [ConfigurationDSL]
|
|
21
|
+
# @return [void]
|
|
11
22
|
def init(name, require_gem: true, require_initializer: true, **kwargs, &block) # rubocop:todo Metrics
|
|
12
23
|
return if @scope.initializers.key?(name.to_sym) &&
|
|
13
24
|
@scope.initializers[name.to_sym].completed
|
|
@@ -35,18 +46,40 @@ module Bridgetown
|
|
|
35
46
|
initializer.completed = true
|
|
36
47
|
end
|
|
37
48
|
|
|
49
|
+
# Execute the provided block for configuration only if the current context matches the
|
|
50
|
+
# provided criteria.
|
|
51
|
+
#
|
|
52
|
+
# @param context [Symbol] supply one or more contexts for execution. Generally these are
|
|
53
|
+
# `:static`, `:console`, `:rake`, and `:server`
|
|
54
|
+
# @return [void]
|
|
38
55
|
def only(*context, &)
|
|
39
56
|
return unless context.any? { _1 == @context }
|
|
40
57
|
|
|
41
58
|
instance_exec(&)
|
|
42
59
|
end
|
|
43
60
|
|
|
61
|
+
# Do not execute the provided block for configuration if the current context matches the
|
|
62
|
+
# provided criteria.
|
|
63
|
+
#
|
|
64
|
+
# @param context [Symbol] supply one or more contexts for avoiding execution. Generally these
|
|
65
|
+
# are `:static`, `:console`, `:rake`, and `:server`
|
|
66
|
+
# @return [void]
|
|
44
67
|
def except(*context, &)
|
|
45
68
|
return if context.any? { _1 == @context }
|
|
46
69
|
|
|
47
70
|
instance_exec(&)
|
|
48
71
|
end
|
|
49
72
|
|
|
73
|
+
# Provides a wrapper around the `register_one` method of the `Hooks` class.
|
|
74
|
+
#
|
|
75
|
+
# @see Bridgetown::Hooks.register_one
|
|
76
|
+
# @param owner [Symbol] name of the owner (`:site`, `:resource`, etc.)
|
|
77
|
+
# @param event [Symbol] name of the event (`:pre_read`, `:post_render`, etc.)
|
|
78
|
+
# @param priority [Integer, Symbol] either `:low`, `:normal`, or `:high`, or an integer.
|
|
79
|
+
# Default is normal (20)
|
|
80
|
+
# @yield the block will be called when the event is triggered. Typically it receives at
|
|
81
|
+
# least one argument.
|
|
82
|
+
# @yieldparam obj the object which triggered the event hook
|
|
50
83
|
def hook(
|
|
51
84
|
owner,
|
|
52
85
|
event,
|
|
@@ -56,10 +89,20 @@ module Bridgetown
|
|
|
56
89
|
Bridgetown::Hooks.register_one(owner, event, priority:, reloadable: false, &)
|
|
57
90
|
end
|
|
58
91
|
|
|
92
|
+
# Used by plugins to supply a source manifest.
|
|
93
|
+
#
|
|
94
|
+
# @see SourceManifest.new
|
|
95
|
+
# @return [void]
|
|
59
96
|
def source_manifest(**)
|
|
60
97
|
@scope.source_manifests << SourceManifest.new(**)
|
|
61
98
|
end
|
|
62
99
|
|
|
100
|
+
# Used by plugins to register the provided Builder class, or alternatively
|
|
101
|
+
# register an "inline builder" by defining the class body in a block using the
|
|
102
|
+
# provided symbol as the class name.
|
|
103
|
+
#
|
|
104
|
+
# @param klass [Class<Bridgetown::Builder>, Symbol]
|
|
105
|
+
# @return [void]
|
|
63
106
|
def builder(klass = nil, &)
|
|
64
107
|
return klass.register if klass.is_a?(Class) && klass < Bridgetown::Builder
|
|
65
108
|
|
|
@@ -72,10 +115,18 @@ module Bridgetown
|
|
|
72
115
|
)
|
|
73
116
|
end
|
|
74
117
|
|
|
118
|
+
# Define an initializer block which is called when the Roda server is being configured.
|
|
119
|
+
#
|
|
120
|
+
# @yieldparam app [Class<Roda>]
|
|
121
|
+
# @return [void]
|
|
75
122
|
def roda(&block)
|
|
76
123
|
@scope.roda_initializers << block
|
|
77
124
|
end
|
|
78
125
|
|
|
126
|
+
# Set the TZ environment variable to use the timezone specified
|
|
127
|
+
#
|
|
128
|
+
# @param timezone [String] the IANA Time Zone
|
|
129
|
+
# @return [void]
|
|
79
130
|
def timezone(new_timezone)
|
|
80
131
|
@data[:timezone] = new_timezone
|
|
81
132
|
Bridgetown.set_timezone(new_timezone)
|
|
@@ -112,6 +163,8 @@ module Bridgetown
|
|
|
112
163
|
end
|
|
113
164
|
end
|
|
114
165
|
|
|
166
|
+
# Similar to `init` but it simply prints out a list of the configuration options accepted
|
|
167
|
+
# as keyword arguments by the initializer
|
|
115
168
|
def reflect(name, require_gem: true, require_initializer: true)
|
|
116
169
|
initializer = _setup_initializer(
|
|
117
170
|
name:, require_gem:, require_initializer:
|
|
@@ -130,9 +183,14 @@ module Bridgetown
|
|
|
130
183
|
initializer.block.parameters.each do |param|
|
|
131
184
|
next if param[0] == :opt
|
|
132
185
|
|
|
186
|
+
option = param[1].to_s
|
|
187
|
+
option = "** #{option}" if param[0] == :keyrest
|
|
188
|
+
|
|
133
189
|
Bridgetown.logger.info("",
|
|
134
|
-
"
|
|
190
|
+
"- #{option.cyan}#{" (required)" if param[0] == :keyreq}")
|
|
135
191
|
end
|
|
192
|
+
|
|
193
|
+
nil
|
|
136
194
|
end
|
|
137
195
|
|
|
138
196
|
# @return [Bridgetown::Configuration::Initializer]
|
|
@@ -156,6 +214,90 @@ module Bridgetown
|
|
|
156
214
|
def _run_builtins!
|
|
157
215
|
init :streamlined
|
|
158
216
|
end
|
|
217
|
+
|
|
218
|
+
### Document configuration options ###
|
|
219
|
+
# TODO: many more to follow!
|
|
220
|
+
|
|
221
|
+
# @!method url(url)
|
|
222
|
+
# Sets the base URL for absolute links. (This will be overridden with something like
|
|
223
|
+
# `localhost:4000` in development.)
|
|
224
|
+
# @param url [String]
|
|
225
|
+
|
|
226
|
+
# @!method source(path)
|
|
227
|
+
# Change the directory where Bridgetown will read content files
|
|
228
|
+
# @param path [String] - default: `src`
|
|
229
|
+
|
|
230
|
+
# @!method destination(path)
|
|
231
|
+
# Change the directory where Bridgetown will write files
|
|
232
|
+
# @param path [String] - default: `output`
|
|
233
|
+
|
|
234
|
+
# @!method template_engine(engine)
|
|
235
|
+
# Change the template engine Bridgetown uses by default to process content files
|
|
236
|
+
# @param engine [Symbol] - default: `:erb`, alternatives: `:serbea`, `:liquid`
|
|
237
|
+
|
|
238
|
+
# @!method permalink(style)
|
|
239
|
+
# Change the default permalink style or template used by pages & blog posts
|
|
240
|
+
# @param style [String] - default: `:pretty`, alternatives: `:pretty_ext`, `:simple`,
|
|
241
|
+
# `:simple_ext`
|
|
242
|
+
|
|
243
|
+
# @!method fast_refresh(bool)
|
|
244
|
+
# Control the behavior of Bridgetown's live reload functionality in development
|
|
245
|
+
# @param bool [Boolean] - default: `true`
|
|
246
|
+
|
|
247
|
+
# @!method exclude(files_list)
|
|
248
|
+
# Exclude source directories and/or files from the build conversion
|
|
249
|
+
# @param files_list [Array<String>]
|
|
250
|
+
|
|
251
|
+
# @!method include(files_list)
|
|
252
|
+
# Force inclusion of directories and/or files in the conversion (e.g. starting with
|
|
253
|
+
# underscores or dots)
|
|
254
|
+
# @param files_list [Array<String>]
|
|
255
|
+
|
|
256
|
+
# @!method keep_files(files_list)
|
|
257
|
+
# Files to keep when clobbering the site destination (aka not generated in typical
|
|
258
|
+
# Bridgetown builds)
|
|
259
|
+
# @param files_list [Array<String>]
|
|
260
|
+
|
|
261
|
+
# @!method autoload_paths
|
|
262
|
+
# Add paths to the Zeitwerk autoloader. Use a `config.defaults << "..."` syntax or a more
|
|
263
|
+
# advanced hash config
|
|
264
|
+
# @example Add a new path for autoloading and eager load on boot
|
|
265
|
+
# config.autoload_paths << {
|
|
266
|
+
# path: "loadme",
|
|
267
|
+
# eager: true
|
|
268
|
+
# }
|
|
269
|
+
|
|
270
|
+
# @!method additional_watch_paths(paths)
|
|
271
|
+
# Watch additional directories for reloads not normally covered by autoloader
|
|
272
|
+
# (relative to project root)
|
|
273
|
+
# @param paths [Array<String>]
|
|
274
|
+
|
|
275
|
+
# @!method timezone(zone)
|
|
276
|
+
# Set the time zone for site generation, using IANA Time Zone Database
|
|
277
|
+
# @param zone [String]
|
|
278
|
+
|
|
279
|
+
# @!method defaults
|
|
280
|
+
# Use a `config.defaults << {...}` syntax to add front matter defaults
|
|
281
|
+
# @example Set a default layout for a collection
|
|
282
|
+
# config.defaults << {
|
|
283
|
+
# scope: { collection: :docs },
|
|
284
|
+
# values: { layout: :default },
|
|
285
|
+
# }
|
|
286
|
+
|
|
287
|
+
# @!method pagination
|
|
288
|
+
# Enable and configure the settings for the paginator
|
|
289
|
+
# @example Basic setup
|
|
290
|
+
# pagination do
|
|
291
|
+
# enabled true
|
|
292
|
+
# end
|
|
293
|
+
|
|
294
|
+
# @!method base_path(url)
|
|
295
|
+
# Optionally host your site off a path, e.g. `/blog`
|
|
296
|
+
# @param url [String] - default: `/`
|
|
297
|
+
|
|
298
|
+
# @!method inflector
|
|
299
|
+
# Configure the inflector to add new inflection types, based on `Dry::Inflector`
|
|
300
|
+
# @return [Bridgetown::Foundation::Inflector]
|
|
159
301
|
end
|
|
160
302
|
end
|
|
161
303
|
end
|
|
@@ -148,6 +148,12 @@ module Bridgetown
|
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
+
def initializers_dsl(context:)
|
|
152
|
+
ConfigurationDSL.new(scope: self, data: self).tap do |dsl|
|
|
153
|
+
dsl.instance_variable_set(:@context, context)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
151
157
|
def run_initializers!(context:) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
152
158
|
initializers_file = File.join(root_dir, "config", "initializers.rb")
|
|
153
159
|
unless File.file?(initializers_file)
|
|
@@ -166,8 +172,7 @@ module Bridgetown
|
|
|
166
172
|
Bridgetown.logger.debug "", initializers_file
|
|
167
173
|
self.init_params = {}
|
|
168
174
|
cached_url = url&.include?("//localhost") ? url : nil
|
|
169
|
-
dsl =
|
|
170
|
-
dsl.instance_variable_set(:@context, context)
|
|
175
|
+
dsl = initializers_dsl(context:)
|
|
171
176
|
dsl.instance_exec(dsl, &init_init.block)
|
|
172
177
|
dsl._run_builtins!
|
|
173
178
|
self.url = cached_url if cached_url # restore local development URL if need be
|
|
@@ -68,7 +68,7 @@ module Bridgetown
|
|
|
68
68
|
# @yield the block will be called when the event is triggered. Typically it receives at
|
|
69
69
|
# least one argument.
|
|
70
70
|
# @yieldparam obj the object which triggered the event hook
|
|
71
|
-
# @return [Proc] the block that was
|
|
71
|
+
# @return [Proc] the block that was passed in
|
|
72
72
|
def self.register_one(owner, event, priority: DEFAULT_PRIORITY, reloadable: true, &block)
|
|
73
73
|
@registry[owner] ||= []
|
|
74
74
|
|
|
@@ -145,7 +145,7 @@ module Bridgetown
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
# Generates a relative path with the collection's directory removed when applicable
|
|
148
|
-
#
|
|
148
|
+
# and additionally removes any multiple periods in the string.
|
|
149
149
|
#
|
|
150
150
|
# NOTE: `String#gsub!` removes all trailing periods (in comparison to `String#chomp!`)
|
|
151
151
|
#
|
data/lib/bridgetown-core.rb
CHANGED
|
@@ -247,7 +247,8 @@ module Bridgetown
|
|
|
247
247
|
)
|
|
248
248
|
end
|
|
249
249
|
|
|
250
|
-
# @
|
|
250
|
+
# @yieldparam config [Bridgetown::Configuration::ConfigurationDSL]
|
|
251
|
+
# @yieldreceiver [Bridgetown::Configuration::ConfigurationDSL]
|
|
251
252
|
def configure(&)
|
|
252
253
|
initializer(:init, &)
|
|
253
254
|
end
|
|
@@ -300,7 +301,6 @@ module Bridgetown
|
|
|
300
301
|
# Set the TZ environment variable to use the timezone specified
|
|
301
302
|
#
|
|
302
303
|
# @param timezone [String] the IANA Time Zone
|
|
303
|
-
#
|
|
304
304
|
# @return [void]
|
|
305
305
|
# rubocop:disable Naming/AccessorMethodName
|
|
306
306
|
def set_timezone(timezone)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bridgetown-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bridgetown Team
|
|
@@ -71,14 +71,14 @@ dependencies:
|
|
|
71
71
|
requirements:
|
|
72
72
|
- - '='
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 2.1.0
|
|
74
|
+
version: 2.1.0
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - '='
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 2.1.0
|
|
81
|
+
version: 2.1.0
|
|
82
82
|
- !ruby/object:Gem::Dependency
|
|
83
83
|
name: csv
|
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|