bridgetown-core 2.0.0.beta2 → 2.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/bridgetown-core.gemspec +43 -42
- data/lib/bridgetown-core/cache.rb +3 -19
- data/lib/bridgetown-core/cleaner.rb +17 -19
- data/lib/bridgetown-core/collection.rb +6 -5
- data/lib/bridgetown-core/commands/base.rb +7 -0
- data/lib/bridgetown-core/commands/build.rb +35 -22
- data/lib/bridgetown-core/commands/concerns/actions.rb +4 -0
- data/lib/bridgetown-core/commands/console.rb +0 -1
- data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +7 -6
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +14 -13
- data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
- data/lib/bridgetown-core/commands/esbuild/update.rb +17 -3
- data/lib/bridgetown-core/commands/esbuild.rb +1 -1
- data/lib/bridgetown-core/commands/start.rb +12 -2
- data/lib/bridgetown-core/component.rb +1 -1
- data/lib/bridgetown-core/concerns/intuitive_expectations.rb +67 -0
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/concerns/publishable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/content.rb +4 -1
- data/lib/bridgetown-core/concerns/site/extensible.rb +6 -1
- data/lib/bridgetown-core/concerns/site/fast_refreshable.rb +33 -18
- data/lib/bridgetown-core/concerns/site/localizable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +3 -0
- data/lib/bridgetown-core/concerns/site/ssr.rb +1 -2
- data/lib/bridgetown-core/concerns/site/writable.rb +1 -0
- data/lib/bridgetown-core/concerns/viewable.rb +46 -0
- data/lib/bridgetown-core/configuration.rb +29 -23
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +5 -5
- data/lib/bridgetown-core/configurations/minitesting.rb +24 -64
- data/lib/bridgetown-core/converter.rb +2 -7
- data/lib/bridgetown-core/converters/erb_templates.rb +11 -7
- data/lib/bridgetown-core/converters/identity.rb +3 -11
- data/lib/bridgetown-core/converters/liquid_templates.rb +3 -5
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/markdown.rb +11 -14
- data/lib/bridgetown-core/converters/serbea_templates.rb +10 -8
- data/lib/bridgetown-core/drops/drop.rb +29 -42
- data/lib/bridgetown-core/drops/resource_drop.rb +3 -12
- data/lib/bridgetown-core/errors.rb +2 -8
- data/lib/bridgetown-core/filters/condition_helpers.rb +6 -9
- data/lib/bridgetown-core/filters/date_filters.rb +22 -35
- data/lib/bridgetown-core/filters/grouping_filters.rb +11 -11
- data/lib/bridgetown-core/filters.rb +53 -72
- data/lib/bridgetown-core/front_matter/defaults.rb +14 -19
- data/lib/bridgetown-core/generated_page.rb +6 -6
- data/lib/bridgetown-core/generators/prototype_generator.rb +0 -2
- data/lib/bridgetown-core/helpers.rb +2 -2
- data/lib/bridgetown-core/hooks.rb +0 -1
- data/lib/bridgetown-core/layout.rb +3 -4
- data/lib/bridgetown-core/liquid_extensions.rb +3 -5
- data/lib/bridgetown-core/log_adapter.rb +37 -56
- data/lib/bridgetown-core/plugin_manager.rb +7 -3
- data/lib/bridgetown-core/rack/boot.rb +7 -57
- data/lib/bridgetown-core/rack/default_config.ru +14 -0
- data/lib/bridgetown-core/rack/loader_hooks.rb +83 -0
- data/lib/bridgetown-core/rack/logger.rb +0 -2
- data/lib/bridgetown-core/rack/routes.rb +3 -2
- data/lib/bridgetown-core/resource/base.rb +8 -8
- data/lib/bridgetown-core/resource/permalink_processor.rb +1 -1
- data/lib/bridgetown-core/resource/relations.rb +3 -1
- data/lib/bridgetown-core/ruby_template_view.rb +0 -1
- data/lib/bridgetown-core/static_file.rb +15 -20
- data/lib/bridgetown-core/tags/class_map.rb +1 -1
- data/lib/bridgetown-core/tags/post_url.rb +2 -32
- data/lib/bridgetown-core/utils/initializers.rb +2 -2
- data/lib/bridgetown-core/utils/require_gems.rb +1 -3
- data/lib/bridgetown-core/utils.rb +41 -44
- data/lib/bridgetown-core/watcher.rb +2 -3
- data/lib/bridgetown-core.rb +29 -10
- data/lib/roda/plugins/bridgetown_server.rb +13 -25
- data/lib/roda/plugins/bridgetown_ssr.rb +21 -3
- data/lib/roda/plugins/flashier.rb +57 -0
- data/lib/roda/plugins/generic_index.html +127 -0
- data/lib/roda/plugins/ssg.rb +3 -2
- data/lib/site_template/config/initializers.rb +2 -0
- data/lib/site_template/package.json.erb +1 -0
- data/lib/site_template/postcss.config.js.erb +1 -1
- metadata +26 -7
- data/lib/bridgetown-core/commands/doctor.rb +0 -147
@@ -8,12 +8,11 @@ module Bridgetown
|
|
8
8
|
# (e.g. "27th Jan 2011") and US ("e.g. Jan 27th, 2011") formats.
|
9
9
|
# UK format is the default.
|
10
10
|
#
|
11
|
-
# date
|
12
|
-
# type
|
13
|
-
# style
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# Returns the formatting String.
|
11
|
+
# @param date [Time]
|
12
|
+
# @param type [String] if "ordinal" the returned String will be in ordinal format
|
13
|
+
# @param style [String] if "US" the returned String will be in US format.
|
14
|
+
# Otherwise it will be in UK format.
|
15
|
+
# @return [String]
|
17
16
|
def date_to_string(date, type = nil, style = nil)
|
18
17
|
stringify_date(date, "%b", type, style)
|
19
18
|
end
|
@@ -23,42 +22,29 @@ module Bridgetown
|
|
23
22
|
# (e.g. "27th January 2011") and US ("e.g. January 27th, 2011") formats.
|
24
23
|
# UK format is the default.
|
25
24
|
#
|
26
|
-
# date
|
27
|
-
# type
|
28
|
-
# style
|
29
|
-
#
|
30
|
-
#
|
31
|
-
# Returns the formatted String.
|
25
|
+
# @param date [Time]
|
26
|
+
# @param type [String] if "ordinal" the returned String will be in ordinal format
|
27
|
+
# @param style [String] if "US" the returned String will be in US format.
|
28
|
+
# Otherwise it will be in UK format.
|
29
|
+
# @return [String]
|
32
30
|
def date_to_long_string(date, type = nil, style = nil)
|
33
31
|
stringify_date(date, "%B", type, style)
|
34
32
|
end
|
35
33
|
|
36
|
-
# Format a date for use in XML.
|
37
|
-
#
|
38
|
-
# date - The Time to format.
|
39
|
-
#
|
40
|
-
# Examples
|
41
|
-
#
|
42
|
-
# date_to_xmlschema(Time.now)
|
43
|
-
# # => "2011-04-24T20:34:46+08:00"
|
34
|
+
# Format a date for use in XML, e.g. "2011-04-24T20:34:46+08:00"
|
44
35
|
#
|
45
|
-
#
|
36
|
+
# @param date [Time]
|
37
|
+
# @return [String]
|
46
38
|
def date_to_xmlschema(date)
|
47
39
|
return date if date.to_s.empty?
|
48
40
|
|
49
41
|
time(date).xmlschema
|
50
42
|
end
|
51
43
|
|
52
|
-
# Format a date according to RFC-822
|
44
|
+
# Format a date according to RFC-822, e.g. "Sun, 24 Apr 2011 12:34:46 +0000"
|
53
45
|
#
|
54
|
-
# date
|
55
|
-
#
|
56
|
-
# Examples
|
57
|
-
#
|
58
|
-
# date_to_rfc822(Time.now)
|
59
|
-
# # => "Sun, 24 Apr 2011 12:34:46 +0000"
|
60
|
-
#
|
61
|
-
# Returns the formatted String.
|
46
|
+
# @param date [Time]
|
47
|
+
# @return [String]
|
62
48
|
def date_to_rfc822(date)
|
63
49
|
return date if date.to_s.empty?
|
64
50
|
|
@@ -67,11 +53,12 @@ module Bridgetown
|
|
67
53
|
|
68
54
|
private
|
69
55
|
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
56
|
+
# @param date [Time]
|
57
|
+
# @param month_type [String] notations that evaluate to 'Month' via `Time#strftime`
|
58
|
+
# ("%b", "%B")
|
59
|
+
# @param type [String]
|
60
|
+
# @param style [String]
|
61
|
+
# @return [String]
|
75
62
|
def stringify_date(date, month_type, type = nil, style = nil)
|
76
63
|
return date if date.to_s.empty?
|
77
64
|
|
@@ -3,14 +3,15 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
module Filters
|
5
5
|
module GroupingFilters
|
6
|
-
# Group an array of items by a property
|
6
|
+
# Group an array of items by a property, returning an array of hashes
|
7
7
|
#
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# @example
|
9
|
+
# {"name" => "larry"
|
10
|
+
# "items" => [...] } # all the items where `property` == "larry"
|
10
11
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# @param input [Enumerable]
|
13
|
+
# @param property [String]
|
14
|
+
# @return [Array<Hash>]
|
14
15
|
def group_by(input, property)
|
15
16
|
if groupable?(input)
|
16
17
|
groups = input.group_by { |item| item_property(item, property).to_s }
|
@@ -22,11 +23,10 @@ module Bridgetown
|
|
22
23
|
|
23
24
|
# Group an array of items by an expression
|
24
25
|
#
|
25
|
-
# input
|
26
|
-
# variable
|
27
|
-
# expression
|
28
|
-
#
|
29
|
-
# Returns the filtered array of objects
|
26
|
+
# @param input [Enumerable]
|
27
|
+
# @param variable [String] variable to assign each item to in the expression
|
28
|
+
# @param expression [String] Liquid comparison expression
|
29
|
+
# @return [Array<Hash>]
|
30
30
|
def group_by_exp(input, variable, expression)
|
31
31
|
return input unless groupable?(input)
|
32
32
|
|
@@ -11,33 +11,30 @@ module Bridgetown
|
|
11
11
|
include TranslationFilters
|
12
12
|
include ConditionHelpers
|
13
13
|
|
14
|
-
# Convert a Markdown string into HTML output
|
14
|
+
# Convert a Markdown string into HTML output
|
15
15
|
#
|
16
|
-
# input
|
17
|
-
#
|
18
|
-
# Returns the HTML formatted String.
|
16
|
+
# @param input [String]
|
17
|
+
# @return [String] HTML formatted text
|
19
18
|
def markdownify(input)
|
20
19
|
@context.registers[:site].find_converter_instance(
|
21
20
|
Bridgetown::Converters::Markdown
|
22
21
|
).convert(input.to_s)
|
23
22
|
end
|
24
23
|
|
25
|
-
# Convert quotes into smart quotes
|
26
|
-
#
|
27
|
-
# input - The String to convert.
|
24
|
+
# Convert quotes into smart quotes
|
28
25
|
#
|
29
|
-
#
|
26
|
+
# @param input [String]
|
27
|
+
# @return [String] smart-quotified text
|
30
28
|
def smartify(input)
|
31
29
|
Utils::SmartyPantsConverter.new(@context.registers[:site].config).convert(input.to_s)
|
32
30
|
end
|
33
31
|
|
34
|
-
# Slugify a filename or title
|
35
|
-
#
|
36
|
-
# input - The filename or title to slugify.
|
37
|
-
# mode - how string is slugified
|
32
|
+
# Slugify a filename or title
|
38
33
|
#
|
39
|
-
#
|
40
|
-
#
|
34
|
+
# @param input [String] the filename or title to slugify
|
35
|
+
# @param mode [String] how string is slugified
|
36
|
+
# @see Utils.slugify
|
37
|
+
# @return [String] lowercase URL
|
41
38
|
def slugify(input, mode = nil)
|
42
39
|
mode = @context.registers[:site].config.slugify_mode if mode.nil?
|
43
40
|
Utils.slugify(input, mode:)
|
@@ -45,10 +42,9 @@ module Bridgetown
|
|
45
42
|
|
46
43
|
# Titleize a slug or identifier string.
|
47
44
|
#
|
48
|
-
# input
|
49
|
-
#
|
50
|
-
#
|
51
|
-
# See Utils.titleize_slug for more detail.
|
45
|
+
# @param input [String]
|
46
|
+
# @see Utils.titleize_slug for more detail
|
47
|
+
# @return [String] transformed string with spaces and capitalized words
|
52
48
|
def titleize(input)
|
53
49
|
Utils.titleize_slug(input)
|
54
50
|
end
|
@@ -56,13 +52,12 @@ module Bridgetown
|
|
56
52
|
# XML escape a string for use. Replaces any special characters with
|
57
53
|
# appropriate HTML entity replacements.
|
58
54
|
#
|
59
|
-
#
|
60
|
-
#
|
55
|
+
# @example
|
61
56
|
# xml_escape('foo "bar" <baz>')
|
62
57
|
# # => "foo "bar" <baz>"
|
63
58
|
#
|
64
|
-
# @param input [String]
|
65
|
-
# @return [String]
|
59
|
+
# @param input [String]
|
60
|
+
# @return [String]
|
66
61
|
def xml_escape(input)
|
67
62
|
Utils.xml_escape(input)
|
68
63
|
end
|
@@ -70,28 +65,24 @@ module Bridgetown
|
|
70
65
|
# CGI escape a string for use in a URL. Replaces any special characters
|
71
66
|
# with appropriate %XX replacements.
|
72
67
|
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
# Examples
|
76
|
-
#
|
68
|
+
# @example
|
77
69
|
# cgi_escape('foo,bar;baz?')
|
78
70
|
# # => "foo%2Cbar%3Bbaz%3F"
|
79
71
|
#
|
80
|
-
#
|
72
|
+
# @param input [String]
|
73
|
+
# @return [String]
|
81
74
|
def cgi_escape(input)
|
82
75
|
CGI.escape(input.to_s)
|
83
76
|
end
|
84
77
|
|
85
78
|
# URI escape a string.
|
86
79
|
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
# Examples
|
90
|
-
#
|
80
|
+
# @example
|
91
81
|
# uri_escape('foo, bar \\baz?')
|
92
82
|
# # => "foo,%20bar%20%5Cbaz?"
|
93
83
|
#
|
94
|
-
#
|
84
|
+
# @param input [String]
|
85
|
+
# @return [String]
|
95
86
|
def uri_escape(input)
|
96
87
|
Addressable::URI.normalize_component(input)
|
97
88
|
end
|
@@ -113,23 +104,22 @@ module Bridgetown
|
|
113
104
|
|
114
105
|
# Replace any whitespace in the input string with a single space
|
115
106
|
#
|
116
|
-
# input
|
117
|
-
#
|
118
|
-
# Returns the formatted String
|
107
|
+
# @param input [String]
|
108
|
+
# @return [String]
|
119
109
|
def normalize_whitespace(input)
|
120
110
|
input.to_s.gsub(%r!\s+!, " ").strip
|
121
111
|
end
|
122
112
|
|
123
113
|
# Count the number of words in the input string.
|
124
114
|
#
|
125
|
-
# input
|
126
|
-
#
|
127
|
-
# Returns the Integer word count.
|
115
|
+
# @param input [String]
|
116
|
+
# @return [Integer] word count
|
128
117
|
def number_of_words(input)
|
129
118
|
input.split.length
|
130
119
|
end
|
131
120
|
|
132
|
-
# Calculates the average reading time of the supplied content
|
121
|
+
# Calculates the average reading time of the supplied content
|
122
|
+
#
|
133
123
|
# @param input [String] the String of content to analyze.
|
134
124
|
# @return [Float] the number of minutes required to read the content.
|
135
125
|
def reading_time(input, round_to = 0)
|
@@ -138,17 +128,15 @@ module Bridgetown
|
|
138
128
|
end
|
139
129
|
|
140
130
|
# Join an array of things into a string by separating with commas and the
|
141
|
-
# word "and" for the last one
|
142
|
-
#
|
143
|
-
# array - The Array of Strings to join.
|
144
|
-
# connector - Word used to connect the last 2 items in the array
|
145
|
-
#
|
146
|
-
# Examples
|
131
|
+
# word "and" for the last one
|
147
132
|
#
|
133
|
+
# @example
|
148
134
|
# array_to_sentence_string(["apples", "oranges", "grapes"])
|
149
135
|
# # => "apples, oranges, and grapes"
|
150
136
|
#
|
151
|
-
#
|
137
|
+
# @param array [Array<String>]
|
138
|
+
# @param connector [String] word used to connect the last 2 items in the array
|
139
|
+
# @return [String]
|
152
140
|
def array_to_sentence_string(array, connector = "and")
|
153
141
|
case array.length
|
154
142
|
when 0
|
@@ -162,24 +150,20 @@ module Bridgetown
|
|
162
150
|
end
|
163
151
|
end
|
164
152
|
|
165
|
-
# Convert the input into
|
166
|
-
#
|
167
|
-
# input - The Array or Hash to be converted
|
153
|
+
# Convert the input into JSON string
|
168
154
|
#
|
169
|
-
#
|
155
|
+
# @param input [Array, Hash, String, Integer]
|
156
|
+
# @return [String] JSON string
|
170
157
|
def jsonify(input)
|
171
158
|
as_liquid(input).to_json
|
172
159
|
end
|
173
160
|
|
174
|
-
# Filter an array of objects
|
161
|
+
# Filter an array of objects or a hash (will use values)
|
175
162
|
#
|
176
|
-
# input
|
177
|
-
# property
|
178
|
-
# value
|
179
|
-
#
|
180
|
-
# their `#inspect` string object.
|
181
|
-
#
|
182
|
-
# Returns the filtered array of objects
|
163
|
+
# @param input [Array, Hash]
|
164
|
+
# @param property [String] the property within each object to filter by
|
165
|
+
# @param value [String] value for the search
|
166
|
+
# @return [Array] filtered array of objects
|
183
167
|
def where(input, property, value) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
184
168
|
return input if !property || value.is_a?(Array) || value.is_a?(Hash)
|
185
169
|
return input unless input.respond_to?(:select)
|
@@ -201,15 +185,14 @@ module Bridgetown
|
|
201
185
|
|
202
186
|
# Filters an array of objects against an expression
|
203
187
|
#
|
204
|
-
# input
|
205
|
-
# variable
|
206
|
-
# expression
|
207
|
-
#
|
208
|
-
# Returns the filtered array of objects
|
188
|
+
# @param input [Array, Hash]
|
189
|
+
# @param variable [String] the variable to assign each item to in the expression
|
190
|
+
# @param expression [String] a Liquid comparison expression passed in as a string
|
191
|
+
# @return [Array] filtered array of objects
|
209
192
|
def where_exp(input, variable, expression)
|
210
193
|
return input unless input.respond_to?(:select)
|
211
194
|
|
212
|
-
input = input.values if input.is_a?(Hash)
|
195
|
+
input = input.values if input.is_a?(Hash)
|
213
196
|
|
214
197
|
condition = parse_condition(expression)
|
215
198
|
@context.stack do
|
@@ -222,9 +205,8 @@ module Bridgetown
|
|
222
205
|
|
223
206
|
# Convert the input into integer
|
224
207
|
#
|
225
|
-
# input
|
226
|
-
#
|
227
|
-
# Returns the integer value
|
208
|
+
# @param input [String, Boolean] if boolean, 1 for true and 0 for false
|
209
|
+
# @return [Integer]
|
228
210
|
def to_integer(input)
|
229
211
|
return 1 if input == true
|
230
212
|
return 0 if input == false
|
@@ -234,11 +216,10 @@ module Bridgetown
|
|
234
216
|
|
235
217
|
# Sort an array of objects
|
236
218
|
#
|
237
|
-
# input
|
238
|
-
# property
|
239
|
-
# nils
|
240
|
-
#
|
241
|
-
# Returns the filtered array of objects
|
219
|
+
# @param input [Array]
|
220
|
+
# @param property [String] the property within each object to filter by
|
221
|
+
# @param nils [String] `first` | `last` (nils appear before or after non-nil values)
|
222
|
+
# @return [Array] sorted array of objects
|
242
223
|
def sort(input, property = nil, nils = "first")
|
243
224
|
raise ArgumentError, "Cannot sort a null object." if input.nil?
|
244
225
|
|
@@ -5,6 +5,8 @@ module Bridgetown
|
|
5
5
|
# This class handles custom defaults for front matter settings.
|
6
6
|
# It is exposed via the frontmatter_defaults method on the site class.
|
7
7
|
class Defaults
|
8
|
+
using Bridgetown::Refinements
|
9
|
+
|
8
10
|
# @return [Bridgetown::Site]
|
9
11
|
attr_reader :site
|
10
12
|
|
@@ -16,6 +18,7 @@ module Bridgetown
|
|
16
18
|
def reset
|
17
19
|
@glob_cache = {}
|
18
20
|
@defaults_cache = {}
|
21
|
+
@sets = nil
|
19
22
|
end
|
20
23
|
|
21
24
|
def ensure_time!(set)
|
@@ -33,7 +36,6 @@ module Bridgetown
|
|
33
36
|
#
|
34
37
|
# @param path [String] the relative path of the resource
|
35
38
|
# @param collection_name [Symbol] :posts, :pages, etc.
|
36
|
-
#
|
37
39
|
# @return [Hash] all default values (an empty hash if there are none)
|
38
40
|
def all(path, collection_name)
|
39
41
|
if @defaults_cache.key?([path, collection_name])
|
@@ -70,11 +72,10 @@ module Bridgetown
|
|
70
72
|
|
71
73
|
# Checks if a given default setting scope matches the given path and collection
|
72
74
|
#
|
73
|
-
# scope
|
74
|
-
# path
|
75
|
-
# collection
|
76
|
-
#
|
77
|
-
# Returns true if the scope applies to the given collection and path
|
75
|
+
# @param scope [Hash] the scope as defined in site configuration
|
76
|
+
# @param path [String] the path to check for
|
77
|
+
# @param collection [Symbol] the collection (:posts, :pages, etc.) to check for
|
78
|
+
# @return [Boolean] true if the scope applies to the given collection and path
|
78
79
|
def applies?(scope, path, collection)
|
79
80
|
applies_collection?(scope, collection) && applies_path?(scope, path)
|
80
81
|
end
|
@@ -129,7 +130,6 @@ module Bridgetown
|
|
129
130
|
#
|
130
131
|
# @param scope [Hash] the defaults set being asked about
|
131
132
|
# @param collection [Symbol] the collection of the resource being processed
|
132
|
-
#
|
133
133
|
# @return [Boolean] whether either of the above conditions are satisfied
|
134
134
|
def applies_collection?(scope, collection)
|
135
135
|
!scope.key?("collection") || scope["collection"].eql?(collection.to_s)
|
@@ -137,8 +137,7 @@ module Bridgetown
|
|
137
137
|
|
138
138
|
# Checks if a given set of default values is valid
|
139
139
|
#
|
140
|
-
# @param set [Hash] the default value hash as defined in
|
141
|
-
#
|
140
|
+
# @param set [Hash] the default value hash as defined in site configuration
|
142
141
|
# @return [Boolean] if the set is valid and can be used
|
143
142
|
def valid?(set)
|
144
143
|
set.is_a?(Hash) && set["values"].is_a?(Hash)
|
@@ -146,10 +145,9 @@ module Bridgetown
|
|
146
145
|
|
147
146
|
# Determines if a new scope has precedence over an old one
|
148
147
|
#
|
149
|
-
# old_scope
|
150
|
-
# new_scope
|
151
|
-
#
|
152
|
-
# Returns true if the new scope has precedence over the older
|
148
|
+
# @param old_scope [Hash] old scope hash, or nil if there's none
|
149
|
+
# @param new_scope [Hash] new scope hash
|
150
|
+
# @return [Boolean] true if the new scope has precedence over the older
|
153
151
|
# rubocop: disable Naming/PredicateName
|
154
152
|
def has_precedence?(old_scope, new_scope)
|
155
153
|
return true if old_scope.nil?
|
@@ -180,15 +178,12 @@ module Bridgetown
|
|
180
178
|
|
181
179
|
# Returns a list of valid sets
|
182
180
|
#
|
183
|
-
# This is not cached to allow plugins to modify the configuration
|
184
|
-
# and have their changes take effect
|
185
|
-
#
|
186
181
|
# @return [Array<Hash>]
|
187
182
|
def valid_sets
|
188
|
-
sets
|
189
|
-
return [] unless sets.is_a?(Array)
|
183
|
+
@sets ||= site.config["defaults"].map(&:as_dots)
|
184
|
+
return [] unless @sets.is_a?(Array)
|
190
185
|
|
191
|
-
sets.filter_map do |set|
|
186
|
+
@sets.filter_map do |set|
|
192
187
|
if valid?(set)
|
193
188
|
massage_scope!(set)
|
194
189
|
# TODO: is this trip really necessary?
|
@@ -25,13 +25,13 @@ module Bridgetown
|
|
25
25
|
.htm
|
26
26
|
).freeze
|
27
27
|
|
28
|
-
# Initialize a new GeneratedPage
|
28
|
+
# Initialize a new GeneratedPage
|
29
29
|
#
|
30
|
-
# site
|
31
|
-
# base
|
32
|
-
# dir
|
33
|
-
# name
|
34
|
-
# from_plugin
|
30
|
+
# @param site [Bridgetown::Site]
|
31
|
+
# @param base [String] path to the source
|
32
|
+
# @param dir [String] path between the source and the file
|
33
|
+
# @param name [String] filename of the file.
|
34
|
+
# @param from_plugin [Boolean] true if the Page file is located in a Gem-based plugin folder
|
35
35
|
# rubocop:disable Metrics/ParameterLists
|
36
36
|
def initialize(site, base, dir, name, from_plugin: false)
|
37
37
|
@site = site
|
@@ -76,7 +76,6 @@ module Bridgetown
|
|
76
76
|
# Check incoming prototype configuration and normalize options.
|
77
77
|
#
|
78
78
|
# @param prototype_page [Bridgetown::GeneratedPage, Bridgetown::Resource::Base]
|
79
|
-
#
|
80
79
|
# @return [String, nil]
|
81
80
|
def validate_search_term(prototype_page)
|
82
81
|
# @type [String]
|
@@ -108,7 +107,6 @@ module Bridgetown
|
|
108
107
|
# Provide a list of all relevent indexed values for the given term.
|
109
108
|
#
|
110
109
|
# @param search_term [String]
|
111
|
-
#
|
112
110
|
# @return [Array<String>]
|
113
111
|
def terms_matching_pages(search_term)
|
114
112
|
pages_list = site.collections[@configured_collection].resources
|
@@ -11,7 +11,7 @@ module Bridgetown
|
|
11
11
|
include ::Streamlined::Helpers
|
12
12
|
include Inclusive
|
13
13
|
|
14
|
-
# @return [Bridgetown::RubyTemplateView]
|
14
|
+
# @return [Bridgetown::RubyTemplateView, Bridgetown::Component]
|
15
15
|
attr_reader :view
|
16
16
|
|
17
17
|
# @return [Bridgetown::Site]
|
@@ -22,7 +22,7 @@ module Bridgetown
|
|
22
22
|
# @return [Bridgetown::Foundation::SafeTranslations]
|
23
23
|
packages def translate_package = [Bridgetown::Foundation::Packages::SafeTranslations]
|
24
24
|
|
25
|
-
# @param view [Bridgetown::RubyTemplateView]
|
25
|
+
# @param view [Bridgetown::RubyTemplateView, Bridgetown::Component]
|
26
26
|
# @param site [Bridgetown::Site]
|
27
27
|
def initialize(view = nil, site = nil)
|
28
28
|
@view = view
|
@@ -95,11 +95,10 @@ module Bridgetown
|
|
95
95
|
content || ""
|
96
96
|
end
|
97
97
|
|
98
|
-
# Accessor for data properties by Liquid
|
98
|
+
# Accessor for data properties by Liquid
|
99
99
|
#
|
100
|
-
# property
|
101
|
-
#
|
102
|
-
# Returns the String value or nil if the property isn't included.
|
100
|
+
# @param property [String] name of the property to retrieve
|
101
|
+
# @return [String, nil] value or nil if the property isn't included
|
103
102
|
def [](property)
|
104
103
|
data[property]
|
105
104
|
end
|
@@ -4,11 +4,9 @@ module Bridgetown
|
|
4
4
|
module LiquidExtensions
|
5
5
|
# Lookup a Liquid variable in the given context.
|
6
6
|
#
|
7
|
-
# context
|
8
|
-
# variable
|
9
|
-
#
|
10
|
-
# Returns the value of the variable in the context
|
11
|
-
# or the variable name if not found.
|
7
|
+
# @param context [Liquid::Context]
|
8
|
+
# @param variable [String] the variable name
|
9
|
+
# @return [Object] value of the variable in the context or the variable name if not found
|
12
10
|
def lookup_variable(context, variable)
|
13
11
|
lookup = context
|
14
12
|
|