bridgetown-core 1.0.0.alpha1 → 1.0.0.alpha2
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 +35 -0
- data/Rakefile +5 -5
- data/lib/bridgetown-core/cache.rb +3 -5
- data/lib/bridgetown-core/cleaner.rb +2 -2
- data/lib/bridgetown-core/collection.rb +4 -6
- data/lib/bridgetown-core/commands/base.rb +4 -3
- data/lib/bridgetown-core/commands/build.rb +20 -19
- data/lib/bridgetown-core/commands/concerns/actions.rb +2 -2
- data/lib/bridgetown-core/commands/console.rb +3 -3
- data/lib/bridgetown-core/commands/doctor.rb +10 -8
- data/lib/bridgetown-core/commands/new.rb +5 -3
- data/lib/bridgetown-core/commands/plugins.rb +7 -9
- data/lib/bridgetown-core/commands/serve/servlet.rb +4 -4
- data/lib/bridgetown-core/commands/serve.rb +25 -27
- data/lib/bridgetown-core/commands/webpack.rb +1 -1
- data/lib/bridgetown-core/component.rb +1 -5
- data/lib/bridgetown-core/concerns/site/configurable.rb +1 -1
- data/lib/bridgetown-core/concerns/site/content.rb +2 -2
- data/lib/bridgetown-core/concerns/site/extensible.rb +3 -4
- data/lib/bridgetown-core/concerns/site/localizable.rb +1 -1
- data/lib/bridgetown-core/concerns/site/ssr.rb +1 -1
- data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
- data/lib/bridgetown-core/configuration.rb +1 -1
- data/lib/bridgetown-core/converter.rb +1 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +1 -1
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/smartypants.rb +1 -0
- data/lib/bridgetown-core/drops/drop.rb +4 -4
- data/lib/bridgetown-core/entry_filter.rb +1 -0
- data/lib/bridgetown-core/filters/url_filters.rb +1 -1
- data/lib/bridgetown-core/filters.rb +11 -12
- data/lib/bridgetown-core/frontmatter_defaults.rb +5 -7
- data/lib/bridgetown-core/generated_page.rb +1 -3
- data/lib/bridgetown-core/generators/prototype_generator.rb +36 -37
- data/lib/bridgetown-core/helpers.rb +1 -1
- data/lib/bridgetown-core/hooks.rb +2 -2
- data/lib/bridgetown-core/liquid_renderer.rb +1 -3
- data/lib/bridgetown-core/log_adapter.rb +1 -1
- data/lib/bridgetown-core/log_writer.rb +1 -1
- data/lib/bridgetown-core/model/base.rb +2 -2
- data/lib/bridgetown-core/model/builder_origin.rb +1 -1
- data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
- data/lib/bridgetown-core/plugin_manager.rb +2 -2
- data/lib/bridgetown-core/publisher.rb +1 -1
- data/lib/bridgetown-core/rack/routes.rb +1 -5
- data/lib/bridgetown-core/rack/static_indexes.rb +2 -2
- data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
- data/lib/bridgetown-core/renderer.rb +1 -1
- data/lib/bridgetown-core/resource/base.rb +7 -7
- data/lib/bridgetown-core/resource/permalink_processor.rb +3 -2
- data/lib/bridgetown-core/resource/taxonomy_term.rb +1 -5
- data/lib/bridgetown-core/resource/transformer.rb +7 -5
- data/lib/bridgetown-core/ruby_template_view.rb +1 -3
- data/lib/bridgetown-core/static_file.rb +5 -7
- data/lib/bridgetown-core/tags/find.rb +6 -6
- data/lib/bridgetown-core/tags/highlight.rb +5 -5
- data/lib/bridgetown-core/tags/include.rb +22 -19
- data/lib/bridgetown-core/tags/post_url.rb +6 -6
- data/lib/bridgetown-core/tags/render_content.rb +2 -2
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +1 -1
- data/lib/bridgetown-core/url.rb +3 -3
- data/lib/bridgetown-core/utils.rb +7 -9
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +2 -2
- data/lib/bridgetown-core.rb +2 -1
- metadata +2 -1
@@ -28,7 +28,7 @@ module Bridgetown
|
|
28
28
|
# drop.
|
29
29
|
#
|
30
30
|
# Returns nothing
|
31
|
-
def initialize(obj)
|
31
|
+
def initialize(obj) # rubocop:disable Lint/MissingSuper
|
32
32
|
@obj = obj
|
33
33
|
end
|
34
34
|
|
@@ -69,11 +69,11 @@ module Bridgetown
|
|
69
69
|
if respond_to?(setter)
|
70
70
|
public_send(setter, val)
|
71
71
|
elsif respond_to?(key.to_s)
|
72
|
-
|
73
|
-
mutations[key] = val
|
74
|
-
else
|
72
|
+
unless self.class.mutable?
|
75
73
|
raise Errors::DropMutationException, "Key #{key} cannot be set in the drop."
|
76
74
|
end
|
75
|
+
|
76
|
+
mutations[key] = val
|
77
77
|
else
|
78
78
|
fallback_data[key] = val
|
79
79
|
end
|
@@ -104,7 +104,7 @@ module Bridgetown
|
|
104
104
|
def obfuscate_link(input, prefix = "mailto")
|
105
105
|
link = "<a href=\"#{prefix}:#{input}\">#{input}</a>"
|
106
106
|
script = "<script type=\"text/javascript\">document.currentScript.insertAdjacentHTML('"
|
107
|
-
script += "beforebegin', '#{rot47(link).gsub(%r!\\!, '\\\\\\')}'.replace(/[!-~]/g,"
|
107
|
+
script += "beforebegin', '#{rot47(link).gsub(%r!\\!, '\\\\\\')}'.replace(/[!-~]/g," # rubocop:disable Style/StringLiteralsInInterpolation
|
108
108
|
script += "function(c){{var j=c.charCodeAt(0);if((j>=33)&&(j<=126)){"
|
109
109
|
script += "return String.fromCharCode(33+((j+ 14)%94));}"
|
110
110
|
script += "else{return String.fromCharCode(j);}}}));</script>"
|
@@ -180,7 +180,7 @@ module Bridgetown
|
|
180
180
|
# their `#inspect` string object.
|
181
181
|
#
|
182
182
|
# Returns the filtered array of objects
|
183
|
-
def where(input, property, value)
|
183
|
+
def where(input, property, value) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
184
184
|
return input if !property || value.is_a?(Array) || value.is_a?(Hash)
|
185
185
|
return input unless input.respond_to?(:select)
|
186
186
|
|
@@ -194,11 +194,9 @@ module Bridgetown
|
|
194
194
|
@where_filter_cache[input_id][property] ||= {}
|
195
195
|
|
196
196
|
# stash or retrive results to return
|
197
|
-
@where_filter_cache[input_id][property][value] ||=
|
198
|
-
|
199
|
-
|
200
|
-
end.to_a
|
201
|
-
end
|
197
|
+
@where_filter_cache[input_id][property][value] ||= input.select do |object|
|
198
|
+
compare_property_vs_target(item_property(object, property), value)
|
199
|
+
end.to_a
|
202
200
|
end
|
203
201
|
|
204
202
|
# Filters an array of objects against an expression
|
@@ -247,13 +245,14 @@ module Bridgetown
|
|
247
245
|
if property.nil?
|
248
246
|
input.sort
|
249
247
|
else
|
250
|
-
|
248
|
+
case nils
|
249
|
+
when "first"
|
251
250
|
order = - 1
|
252
|
-
|
251
|
+
when "last"
|
253
252
|
order = + 1
|
254
253
|
else
|
255
254
|
raise ArgumentError, "Invalid nils order: " \
|
256
|
-
|
255
|
+
"'#{nils}' is not a valid nils order. It must be 'first' or 'last'."
|
257
256
|
end
|
258
257
|
|
259
258
|
sort_input(input, property, order)
|
@@ -327,7 +326,7 @@ module Bridgetown
|
|
327
326
|
# If the property doesn't exist, return the sort order respective of
|
328
327
|
# which item doesn't have the property.
|
329
328
|
# We also utilize the Schwartzian transform to make this more efficient.
|
330
|
-
def sort_input(input, property, order)
|
329
|
+
def sort_input(input, property, order) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
331
330
|
input.map { |item| [item_property(item, property), item] }
|
332
331
|
.sort! do |a_info, b_info|
|
333
332
|
a_property = a_info.first
|
@@ -413,7 +412,7 @@ module Bridgetown
|
|
413
412
|
case item
|
414
413
|
when Hash
|
415
414
|
pairs = item.map { |k, v| as_liquid([k, v]) }
|
416
|
-
Hash[pairs]
|
415
|
+
Hash[pairs] # rubocop:todo Style/HashConversion
|
417
416
|
when Array
|
418
417
|
item.map { |i| as_liquid(i) }
|
419
418
|
else
|
@@ -166,10 +166,8 @@ module Bridgetown
|
|
166
166
|
def matching_sets(path, collection)
|
167
167
|
@matched_set_cache ||= {}
|
168
168
|
@matched_set_cache[path] ||= {}
|
169
|
-
@matched_set_cache[path][collection] ||=
|
170
|
-
|
171
|
-
!set.key?("scope") || applies?(set["scope"], path, collection)
|
172
|
-
end
|
169
|
+
@matched_set_cache[path][collection] ||= valid_sets.select do |set|
|
170
|
+
!set.key?("scope") || applies?(set["scope"], path, collection)
|
173
171
|
end
|
174
172
|
end
|
175
173
|
|
@@ -200,9 +198,9 @@ module Bridgetown
|
|
200
198
|
def massage_scope!(set)
|
201
199
|
set["scope"] ||= {}
|
202
200
|
set["scope"]["path"] ||= ""
|
203
|
-
|
204
|
-
|
205
|
-
|
201
|
+
return unless set["scope"]["type"] && !set["scope"]["collection"]
|
202
|
+
|
203
|
+
set["scope"]["collection"] = set["scope"]["type"]
|
206
204
|
end
|
207
205
|
|
208
206
|
SANITIZATION_REGEX = %r!\A/|(?<=[^/])\z!.freeze
|
@@ -7,9 +7,7 @@ module Bridgetown
|
|
7
7
|
include Publishable
|
8
8
|
|
9
9
|
attr_writer :dir
|
10
|
-
attr_accessor :site, :paginator
|
11
|
-
attr_accessor :name, :ext, :basename
|
12
|
-
attr_accessor :data, :content, :output
|
10
|
+
attr_accessor :site, :paginator, :name, :ext, :basename, :data, :content, :output
|
13
11
|
|
14
12
|
alias_method :extname, :ext
|
15
13
|
|
@@ -44,31 +44,31 @@ module Bridgetown
|
|
44
44
|
page_list.include?(page)
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
ensure_pagination_enabled
|
47
|
+
return unless prototype_pages.length.positive?
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
ensure_pagination_enabled
|
50
|
+
|
51
|
+
page_list.reject! do |page|
|
52
|
+
prototype_pages.include? page
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
prototype_pages.each do |prototype_page|
|
56
|
+
search_term = validate_search_term(prototype_page)
|
57
|
+
next if search_term.nil?
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
end
|
59
|
+
terms_matching_pages(search_term).each do |term|
|
60
|
+
generate_new_page_from_prototype(prototype_page, search_term, term)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def ensure_pagination_enabled
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
return if @site.config.dig(:pagination, :enabled)
|
67
|
+
|
68
|
+
Bridgetown.logger.warn(
|
69
|
+
"Pagination:",
|
70
|
+
"Must be enabled for prototype pages to contain matches"
|
71
|
+
)
|
72
72
|
end
|
73
73
|
|
74
74
|
# Check incoming prototype configuration and normalize options.
|
@@ -125,7 +125,7 @@ module Bridgetown
|
|
125
125
|
# @param collection [Bridgetown::Collection]
|
126
126
|
# @param search_term [String]
|
127
127
|
# @param term [String]
|
128
|
-
def initialize(prototyped_page, collection, search_term, term)
|
128
|
+
def initialize(prototyped_page, collection, search_term, term) # rubocop:disable Lint/MissingSuper
|
129
129
|
@prototyped_page = prototyped_page
|
130
130
|
@site = prototyped_page.site
|
131
131
|
@url = ""
|
@@ -160,22 +160,21 @@ module Bridgetown
|
|
160
160
|
slugify_term(term)
|
161
161
|
end
|
162
162
|
|
163
|
-
# rubocop:todo Metrics/AbcSize
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
related_data = site.data[prototyped_page.data["prototype"]["data"]].dig(term)
|
168
|
-
if related_data
|
169
|
-
data["#{search_term}_data"] = related_data
|
170
|
-
data_label = related_data[prototyped_page.data["prototype"]["data_label"]]
|
171
|
-
data["title"] = data["title"].gsub(
|
172
|
-
":prototype-data-label", data_label
|
173
|
-
)
|
174
|
-
end
|
175
|
-
end
|
163
|
+
def process_title_data_placeholder(search_term, term) # rubocop:todo Metrics/AbcSize
|
164
|
+
unless prototyped_page.data["prototype"]["data"] &&
|
165
|
+
data["title"]&.include?(":prototype-data-label")
|
166
|
+
return
|
176
167
|
end
|
168
|
+
|
169
|
+
related_data = site.data[prototyped_page.data["prototype"]["data"]][term]
|
170
|
+
return unless related_data
|
171
|
+
|
172
|
+
data["#{search_term}_data"] = related_data
|
173
|
+
data_label = related_data[prototyped_page.data["prototype"]["data_label"]]
|
174
|
+
data["title"] = data["title"].gsub(
|
175
|
+
":prototype-data-label", data_label
|
176
|
+
)
|
177
177
|
end
|
178
|
-
# rubocop:enable Metrics/AbcSize
|
179
178
|
|
180
179
|
def process_title_simple_placeholders(term)
|
181
180
|
if data["title"]&.include?(":prototype-term-titleize")
|
@@ -184,11 +183,11 @@ module Bridgetown
|
|
184
183
|
)
|
185
184
|
end
|
186
185
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
186
|
+
return unless data["title"]&.include?(":prototype-term")
|
187
|
+
|
188
|
+
data["title"] = data["title"].gsub(
|
189
|
+
":prototype-term", term
|
190
|
+
)
|
192
191
|
end
|
193
192
|
|
194
193
|
def slugify_term(term)
|
@@ -56,7 +56,7 @@ module Bridgetown
|
|
56
56
|
# `url` or `relative_url`
|
57
57
|
# @return [String] the permalink URL for the file
|
58
58
|
def url_for(relative_path)
|
59
|
-
if relative_path.respond_to?(:relative_url)
|
59
|
+
if relative_path.respond_to?(:relative_url) # rubocop:disable Style/GuardClause
|
60
60
|
return safe(relative_path.relative_url) # new resource engine
|
61
61
|
elsif relative_path.respond_to?(:url)
|
62
62
|
return safe(relative_url(relative_path.url)) # old legacy engine
|
@@ -72,14 +72,14 @@ module Bridgetown
|
|
72
72
|
@registry[owner].delete_if { |item| item.block == block }
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.trigger(owner, event, *args)
|
75
|
+
def self.trigger(owner, event, *args) # rubocop:disable Metrics/CyclomaticComplexity
|
76
76
|
# proceed only if there are hooks to call
|
77
77
|
hooks = @registry[owner]&.select { |item| item.event == event }
|
78
78
|
return if hooks.nil? || hooks.empty?
|
79
79
|
|
80
80
|
prioritized_hooks(hooks).each do |hook|
|
81
81
|
if ENV["BRIDGETOWN_LOG_LEVEL"] == "debug"
|
82
|
-
hook_info = args[0]
|
82
|
+
hook_info = args[0].respond_to?(:url) ? args[0].relative_path : hook.block
|
83
83
|
Bridgetown.logger.debug("Triggering hook:", "#{owner}:#{event} for #{hook_info}")
|
84
84
|
end
|
85
85
|
hook.block.call(*args)
|
@@ -120,7 +120,7 @@ module Bridgetown
|
|
120
120
|
# colon -
|
121
121
|
#
|
122
122
|
# Returns the formatted topic statement
|
123
|
-
def formatted_topic(topic, colon = false)
|
123
|
+
def formatted_topic(topic, colon = false) # rubocop:disable Style/OptionalBooleanParameter
|
124
124
|
"#{topic}#{colon ? ": " : " "}".rjust(20)
|
125
125
|
end
|
126
126
|
|
@@ -122,7 +122,7 @@ module Bridgetown
|
|
122
122
|
attributes.key?(method_name) || method_name.to_s.end_with?("=") || super
|
123
123
|
end
|
124
124
|
|
125
|
-
def method_missing(method_name, *args)
|
125
|
+
def method_missing(method_name, *args)
|
126
126
|
return attributes[method_name] if attributes.key?(method_name)
|
127
127
|
|
128
128
|
key = method_name.to_s
|
@@ -134,7 +134,7 @@ module Bridgetown
|
|
134
134
|
end
|
135
135
|
|
136
136
|
Bridgetown.logger.warn "key `#{method_name}' not found in attributes for" \
|
137
|
-
" #{attributes[:id].presence ||
|
137
|
+
" #{attributes[:id].presence || "new #{self.class}"}"
|
138
138
|
nil
|
139
139
|
end
|
140
140
|
|
@@ -14,7 +14,7 @@ module Bridgetown
|
|
14
14
|
manifest_origin = Addressable::URI.unescape(url.path.delete_prefix("/")).split("/").first
|
15
15
|
Bridgetown::PluginManager.source_manifests.find do |manifest|
|
16
16
|
manifest.origin.to_s == manifest_origin
|
17
|
-
end.tap do |manifest|
|
17
|
+
end.tap do |manifest|
|
18
18
|
raise "Unable to locate a source manifest for #{manifest_origin}" unless manifest
|
19
19
|
end
|
20
20
|
end
|
@@ -104,7 +104,7 @@ module Bridgetown
|
|
104
104
|
|
105
105
|
# check matching version number is see if it's already installed
|
106
106
|
if package_json["dependencies"]
|
107
|
-
current_version = package_json["dependencies"]
|
107
|
+
current_version = package_json["dependencies"][yarn_dependency.first]
|
108
108
|
package_requires_updating?(current_version, yarn_dependency.last)
|
109
109
|
else
|
110
110
|
true
|
@@ -112,7 +112,7 @@ module Bridgetown
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def self.package_requires_updating?(current_version, dep_version)
|
115
|
-
current_version.nil? || current_version != dep_version && !current_version.include?("/")
|
115
|
+
current_version.nil? || (current_version != dep_version && !current_version.include?("/"))
|
116
116
|
end
|
117
117
|
|
118
118
|
# Require all .rb files
|
@@ -15,7 +15,7 @@ module Bridgetown
|
|
15
15
|
return false unless thing.respond_to?(:date)
|
16
16
|
|
17
17
|
future_allowed =
|
18
|
-
thing.respond_to?(:collection) && thing.collection.metadata.future || @site.config.future
|
18
|
+
(thing.respond_to?(:collection) && thing.collection.metadata.future) || @site.config.future
|
19
19
|
thing_time = thing.date.is_a?(Date) ? thing.date.to_time.to_i : thing.date.to_i
|
20
20
|
!future_allowed && thing_time > @site.time.to_i
|
21
21
|
end
|
@@ -4,7 +4,7 @@ module Bridgetown
|
|
4
4
|
module Rack
|
5
5
|
class Routes
|
6
6
|
class << self
|
7
|
-
attr_accessor :tracked_subclasses
|
7
|
+
attr_accessor :tracked_subclasses, :router_block
|
8
8
|
|
9
9
|
def inherited(base)
|
10
10
|
Bridgetown::Rack::Routes.track_subclass base
|
@@ -24,8 +24,6 @@ module Bridgetown
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
attr_accessor :router_block
|
28
|
-
|
29
27
|
def route(&block)
|
30
28
|
self.router_block = block
|
31
29
|
end
|
@@ -74,7 +72,6 @@ module Bridgetown
|
|
74
72
|
instance_exec(@_roda_app.request, &self.class.router_block)
|
75
73
|
end
|
76
74
|
|
77
|
-
# rubocop:disable Style/MissingRespondToMissing
|
78
75
|
ruby2_keywords def method_missing(method_name, *args, &block)
|
79
76
|
if @_roda_app.respond_to?(method_name.to_sym)
|
80
77
|
@_roda_app.send method_name.to_sym, *args, &block
|
@@ -86,7 +83,6 @@ module Bridgetown
|
|
86
83
|
def respond_to_missing?(method_name, include_private = false)
|
87
84
|
@_roda_app.respond_to?(method_name.to_sym, include_private) || super
|
88
85
|
end
|
89
|
-
# rubocop:enable Style/MissingRespondToMissing
|
90
86
|
end
|
91
87
|
end
|
92
88
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require "roda/plugins/public"
|
4
4
|
|
5
5
|
Roda::RodaPlugins::Public::RequestMethods.module_eval do
|
6
|
-
SPLIT = Regexp.union(*[File::SEPARATOR, File::ALT_SEPARATOR].compact)
|
7
|
-
def public_path_segments(path) # rubocop:disable Metrics/CyclomaticComplexity
|
6
|
+
SPLIT = Regexp.union(*[File::SEPARATOR, File::ALT_SEPARATOR].compact) # rubocop:disable Lint/ConstantDefinitionInBlock
|
7
|
+
def public_path_segments(path) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
8
8
|
segments = []
|
9
9
|
|
10
10
|
path.split(SPLIT).each do |seg|
|
@@ -119,7 +119,7 @@ module Bridgetown
|
|
119
119
|
!(document.is_a? Bridgetown::Excerpt)
|
120
120
|
|
121
121
|
Bridgetown.logger.warn "Build Warning:", "Layout '#{document.data["layout"]}' requested " \
|
122
|
-
|
122
|
+
"in #{document.relative_path} does not exist."
|
123
123
|
end
|
124
124
|
|
125
125
|
# Render layout content into document.output
|
@@ -53,7 +53,7 @@ module Bridgetown
|
|
53
53
|
@layout = site.layouts[data.layout].tap do |layout|
|
54
54
|
unless layout
|
55
55
|
Bridgetown.logger.warn "Resource:", "Layout '#{data.layout}' " \
|
56
|
-
|
56
|
+
"requested via #{relative_path} does not exist."
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -267,7 +267,7 @@ module Bridgetown
|
|
267
267
|
# Comparison is a comparison between the 2 dates or paths of the resources.
|
268
268
|
#
|
269
269
|
# @return [Integer] -1, 0, or +1
|
270
|
-
def <=>(other) # rubocop:todo Metrics/AbcSize
|
270
|
+
def <=>(other) # rubocop:todo Metrics/AbcSize
|
271
271
|
return nil unless other.respond_to?(:data)
|
272
272
|
|
273
273
|
cmp = if data.date.respond_to?(:to_datetime) && other.data.date.respond_to?(:to_datetime)
|
@@ -293,7 +293,7 @@ module Bridgetown
|
|
293
293
|
|
294
294
|
private
|
295
295
|
|
296
|
-
def ensure_default_data
|
296
|
+
def ensure_default_data # rubocop:todo Metrics/AbcSize
|
297
297
|
determine_locale
|
298
298
|
|
299
299
|
slug = if matches = relative_path.to_s.match(DATE_FILENAME_MATCHER) # rubocop:disable Lint/AssignmentInCondition
|
@@ -337,14 +337,14 @@ module Bridgetown
|
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
340
|
-
def determine_locale
|
340
|
+
def determine_locale # rubocop:todo Metrics/AbcSize
|
341
341
|
unless data.locale
|
342
342
|
data.locale = locale_from_alt_data_or_filename.presence || site.config.default_locale
|
343
343
|
end
|
344
344
|
|
345
|
-
|
346
|
-
|
347
|
-
|
345
|
+
return unless data.locale_overrides.is_a?(Hash) && data.locale_overrides&.key?(data.locale)
|
346
|
+
|
347
|
+
data.merge!(data.locale_overrides[data.locale])
|
348
348
|
end
|
349
349
|
|
350
350
|
# Look for alternative front matter or look at the filename pattern: slug.locale.ext
|
@@ -46,9 +46,10 @@ module Bridgetown
|
|
46
46
|
segment = segment.to_sym
|
47
47
|
if self.class.placeholder_processors[segment]
|
48
48
|
segment_value = self.class.placeholder_processors[segment].(resource)
|
49
|
-
|
49
|
+
case segment_value
|
50
|
+
when Hash
|
50
51
|
segment_value[:raw_value]
|
51
|
-
|
52
|
+
when Array
|
52
53
|
segment_value.map do |subsegment|
|
53
54
|
Utils.slugify(subsegment, mode: slugify_mode)
|
54
55
|
end.join("/")
|
@@ -103,10 +103,12 @@ module Bridgetown
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def warn_on_missing_layout(layout, layout_name)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
return unless layout.nil? && layout_name
|
107
|
+
|
108
|
+
Bridgetown.logger.warn(
|
109
|
+
"Build Warning:",
|
110
|
+
"Layout '#{layout_name}' requested via #{resource.relative_path} does not exist."
|
111
|
+
)
|
110
112
|
end
|
111
113
|
|
112
114
|
### Transformation Actions
|
@@ -152,7 +154,7 @@ module Bridgetown
|
|
152
154
|
layout_input = layout.content.dup
|
153
155
|
|
154
156
|
layout_converters.inject(layout_input) do |content, converter|
|
155
|
-
next(content) unless [2, -2].include?(converter.method(:convert).arity)
|
157
|
+
next(content) unless [2, -2].include?(converter.method(:convert).arity) # rubocop:disable Performance/CollectionLiteralInLoop
|
156
158
|
|
157
159
|
layout.current_document = resource
|
158
160
|
layout.current_document_output = output
|
@@ -61,7 +61,6 @@ module Bridgetown
|
|
61
61
|
@helpers ||= Helpers.new(self, site)
|
62
62
|
end
|
63
63
|
|
64
|
-
# rubocop:disable Style/MissingRespondToMissing
|
65
64
|
ruby2_keywords def method_missing(method_name, *args, &block)
|
66
65
|
if helpers.respond_to?(method_name.to_sym)
|
67
66
|
helpers.send method_name.to_sym, *args, &block
|
@@ -73,7 +72,6 @@ module Bridgetown
|
|
73
72
|
def respond_to_missing?(method_name, include_private = false)
|
74
73
|
helpers.respond_to?(method_name.to_sym, include_private) || super
|
75
74
|
end
|
76
|
-
# rubocop:enable Style/MissingRespondToMissing
|
77
75
|
|
78
76
|
private
|
79
77
|
|
@@ -84,7 +82,7 @@ module Bridgetown
|
|
84
82
|
["{% render \"#{component}\""]
|
85
83
|
end
|
86
84
|
unless options.empty?
|
87
|
-
render_statement << ",
|
85
|
+
render_statement << ", #{options.keys.map { |k| "#{k}: #{k}" }.join(", ")}"
|
88
86
|
end
|
89
87
|
render_statement << " %}"
|
90
88
|
if options[:_block_content]
|
@@ -36,7 +36,7 @@ module Bridgetown
|
|
36
36
|
@extname = File.extname(@name)
|
37
37
|
@data = @site.frontmatter_defaults.all(relative_path, type).with_dot_access
|
38
38
|
data.permalink ||= if collection && !collection.builtin?
|
39
|
-
collection.default_permalink.chomp("/").chomp(".*")
|
39
|
+
"#{collection.default_permalink.chomp("/").chomp(".*")}.*"
|
40
40
|
else
|
41
41
|
"/:path.*"
|
42
42
|
end
|
@@ -44,9 +44,7 @@ module Bridgetown
|
|
44
44
|
|
45
45
|
# Returns source file path.
|
46
46
|
def path
|
47
|
-
@path ||=
|
48
|
-
File.join(*[@base, @dir, @name].compact)
|
49
|
-
end
|
47
|
+
@path ||= File.join(*[@base, @dir, @name].compact)
|
50
48
|
end
|
51
49
|
|
52
50
|
# Obtain destination path.
|
@@ -207,9 +205,9 @@ module Bridgetown
|
|
207
205
|
def copy_file(dest_path)
|
208
206
|
FileUtils.copy_entry(path, dest_path)
|
209
207
|
|
210
|
-
|
211
|
-
|
212
|
-
|
208
|
+
return if File.symlink?(dest_path)
|
209
|
+
|
210
|
+
File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path)
|
213
211
|
end
|
214
212
|
end
|
215
213
|
end
|