bridgetown-core 1.0.0.beta2 → 1.1.0.beta1
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 +6 -1
- data/lib/bridgetown-core/collection.rb +37 -20
- data/lib/bridgetown-core/commands/concerns/actions.rb +3 -2
- data/lib/bridgetown-core/commands/configure.rb +1 -1
- data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +20 -16
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +95 -12
- data/lib/bridgetown-core/commands/new.rb +10 -9
- data/lib/bridgetown-core/commands/plugins.rb +2 -0
- data/lib/bridgetown-core/commands/start.rb +3 -0
- data/lib/bridgetown-core/commands/webpack/update.rb +2 -2
- data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +11 -2
- data/lib/bridgetown-core/component.rb +13 -7
- data/lib/bridgetown-core/concerns/localizable.rb +20 -0
- data/lib/bridgetown-core/concerns/prioritizable.rb +44 -0
- data/lib/bridgetown-core/concerns/publishable.rb +11 -1
- data/lib/bridgetown-core/concerns/site/configurable.rb +2 -10
- data/lib/bridgetown-core/concerns/site/localizable.rb +5 -1
- data/lib/bridgetown-core/concerns/site/renderable.rb +27 -16
- data/lib/bridgetown-core/concerns/site/ssr.rb +3 -3
- data/lib/bridgetown-core/concerns/site/writable.rb +28 -0
- data/lib/bridgetown-core/concerns/transformable.rb +62 -0
- data/lib/bridgetown-core/configuration.rb +2 -0
- data/lib/bridgetown-core/configurations/bt-postcss/postcss.config.js +5 -3
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -1
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +33 -0
- data/lib/bridgetown-core/configurations/gh-pages.rb +16 -0
- data/lib/bridgetown-core/configurations/lit/esbuild-plugins.js +21 -0
- data/lib/bridgetown-core/configurations/lit/happy-days.lit.js +26 -0
- data/lib/bridgetown-core/configurations/lit/lit-components-entry.js +1 -0
- data/lib/bridgetown-core/configurations/lit/lit-ssr.config.js +6 -0
- data/lib/bridgetown-core/configurations/lit.rb +95 -0
- data/lib/bridgetown-core/configurations/open-props/variables.css.erb +11 -0
- data/lib/bridgetown-core/configurations/open-props.rb +21 -0
- data/lib/bridgetown-core/configurations/ruby2js/hello_world.js.rb +9 -0
- data/lib/bridgetown-core/configurations/ruby2js.rb +67 -0
- data/lib/bridgetown-core/configurations/shoelace.rb +50 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +16 -2
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/drops/generated_page_drop.rb +2 -1
- data/lib/bridgetown-core/drops/resource_drop.rb +2 -1
- data/lib/bridgetown-core/errors.rb +5 -5
- data/lib/bridgetown-core/filters/translation_filters.rb +11 -0
- data/lib/bridgetown-core/filters/url_filters.rb +37 -10
- data/lib/bridgetown-core/filters.rb +3 -0
- data/lib/bridgetown-core/frontmatter_defaults.rb +14 -8
- data/lib/bridgetown-core/generated_page.rb +82 -17
- data/lib/bridgetown-core/kramdown/parser/gfm.rb +36 -0
- data/lib/bridgetown-core/model/base.rb +1 -2
- data/lib/bridgetown-core/plugin.rb +6 -37
- data/lib/bridgetown-core/plugin_manager.rb +3 -2
- data/lib/bridgetown-core/rack/boot.rb +5 -0
- data/lib/bridgetown-core/rack/logger.rb +14 -4
- data/lib/bridgetown-core/rack/roda.rb +102 -10
- data/lib/bridgetown-core/rack/routes.rb +87 -6
- data/lib/bridgetown-core/resource/base.rb +4 -6
- data/lib/bridgetown-core/resource/destination.rb +18 -0
- data/lib/bridgetown-core/resource/permalink_processor.rb +6 -4
- data/lib/bridgetown-core/resource/relations.rb +1 -1
- data/lib/bridgetown-core/resource/transformer.rb +21 -85
- data/lib/bridgetown-core/utils/aux.rb +2 -1
- data/lib/bridgetown-core/utils/require_gems.rb +3 -6
- data/lib/bridgetown-core/utils.rb +25 -12
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +19 -6
- data/lib/bridgetown-core.rb +9 -3
- data/lib/site_template/Gemfile.erb +1 -1
- data/lib/site_template/README.md +2 -2
- data/lib/site_template/TEMPLATES/erb/_components/shared/navbar.erb +4 -4
- data/lib/site_template/TEMPLATES/liquid/_components/navbar.liquid +4 -4
- data/lib/site_template/TEMPLATES/serbea/_components/shared/navbar.serb +4 -4
- data/lib/site_template/bridgetown.config.yml +10 -3
- data/lib/site_template/frontend/javascript/index.js.erb +1 -0
- data/lib/site_template/frontend/styles/syntax-highlighting.css +77 -0
- data/lib/site_template/package.json.erb +18 -17
- data/lib/site_template/server/roda_app.rb +3 -6
- data/lib/site_template/src/404.html +2 -1
- data/lib/site_template/src/500.html +10 -0
- metadata +21 -4
- data/lib/bridgetown-core/publisher.rb +0 -29
- data/lib/bridgetown-core/renderer.rb +0 -169
@@ -21,7 +21,7 @@ run "npx tailwindcss init"
|
|
21
21
|
|
22
22
|
gsub_file "tailwind.config.js", "content: [],", <<~JS.strip
|
23
23
|
content: [
|
24
|
-
'./src/**/*.{html,md,liquid,erb,serb}',
|
24
|
+
'./src/**/*.{html,md,liquid,erb,serb,rb}',
|
25
25
|
'./frontend/javascript/**/*.js',
|
26
26
|
],
|
27
27
|
JS
|
@@ -38,6 +38,20 @@ end
|
|
38
38
|
|
39
39
|
create_file "frontend/styles/jit-refresh.css", "/* #{Time.now.to_i} */"
|
40
40
|
|
41
|
+
insert_into_file "Rakefile",
|
42
|
+
after: %r{ task :(build|dev) do\n} do
|
43
|
+
<<-JS
|
44
|
+
sh "touch frontend/styles/jit-refresh.css"
|
45
|
+
JS
|
46
|
+
end
|
47
|
+
|
48
|
+
append_to_file ".gitignore" do
|
49
|
+
<<~FILES
|
50
|
+
|
51
|
+
frontend/styles/jit-refresh.css
|
52
|
+
FILES
|
53
|
+
end
|
54
|
+
|
41
55
|
create_builder "tailwind_jit.rb" do
|
42
56
|
<<~RUBY
|
43
57
|
class Builders::TailwindJit < SiteBuilder
|
@@ -45,7 +59,7 @@ create_builder "tailwind_jit.rb" do
|
|
45
59
|
hook :site, :pre_reload do |_, paths|
|
46
60
|
# Don't trigger refresh if it's a frontend-only change
|
47
61
|
next if paths.length == 1 && paths.first.ends_with?("manifest.json")
|
48
|
-
|
62
|
+
|
49
63
|
# Save out a comment file to trigger Tailwind's JIT
|
50
64
|
refresh_file = site.in_root_dir("frontend", "styles", "jit-refresh.css")
|
51
65
|
File.write refresh_file, "/* \#{Time.now.to_i} */"
|
@@ -76,7 +76,7 @@ module Bridgetown
|
|
76
76
|
@config["syntax_highlighter"] ||= config["highlighter"] || "rouge"
|
77
77
|
@config["syntax_highlighter_opts"] ||= {}
|
78
78
|
@config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
|
79
|
-
|
79
|
+
require_relative "../../kramdown/parser/gfm" if @config["input"] == "GFM"
|
80
80
|
end
|
81
81
|
|
82
82
|
def convert(content)
|
@@ -15,9 +15,9 @@ module Bridgetown
|
|
15
15
|
InvalidURLError = Class.new(FatalException)
|
16
16
|
InvalidConfigurationError = Class.new(FatalException)
|
17
17
|
|
18
|
-
def self.print_build_error(exc, trace: false)
|
19
|
-
|
20
|
-
|
18
|
+
def self.print_build_error(exc, trace: false, logger: Bridgetown.logger)
|
19
|
+
logger.error "Exception raised:", exc.class.to_s.bold
|
20
|
+
logger.error exc.message.reset_ansi
|
21
21
|
|
22
22
|
trace_args = ["-t", "--trace"]
|
23
23
|
print_trace_msg = true
|
@@ -28,12 +28,12 @@ module Bridgetown
|
|
28
28
|
exc.backtrace[0..4]
|
29
29
|
end
|
30
30
|
traces.each_with_index do |backtrace_line, index|
|
31
|
-
|
31
|
+
logger.error "#{index + 1}:", backtrace_line.reset_ansi
|
32
32
|
end
|
33
33
|
|
34
34
|
return unless print_trace_msg
|
35
35
|
|
36
|
-
|
36
|
+
logger.warn "Backtrace:", "Use the --trace option for complete information."
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -7,9 +7,8 @@ module Bridgetown
|
|
7
7
|
|
8
8
|
# Produces an absolute URL based on site.url and site.base_path.
|
9
9
|
#
|
10
|
-
# input
|
11
|
-
#
|
12
|
-
# Returns the absolute URL as a String.
|
10
|
+
# @param input [String] the URL to make absolute.
|
11
|
+
# @return [String] the absolute URL as a String.
|
13
12
|
def absolute_url(input)
|
14
13
|
cache = (@context.registers[:cached_absolute_urls] ||= {})
|
15
14
|
cache[input] ||= compute_absolute_url(input)
|
@@ -18,19 +17,47 @@ module Bridgetown
|
|
18
17
|
# Produces a URL relative to the domain root based on site.base_path
|
19
18
|
# unless it is already an absolute url with an authority (host).
|
20
19
|
#
|
21
|
-
# input
|
22
|
-
#
|
23
|
-
# Returns a URL relative to the domain root as a String.
|
20
|
+
# @param input [String] the URL to make relative to the domain root
|
21
|
+
# @return [String] a URL relative to the domain root as a String.
|
24
22
|
def relative_url(input)
|
25
23
|
cache = (@context.registers[:cached_relative_urls] ||= {})
|
26
24
|
cache[input] ||= compute_relative_url(input)
|
27
25
|
end
|
28
26
|
|
29
|
-
#
|
27
|
+
# For string input, adds a prefix of the current site locale to a relative
|
28
|
+
# URL, unless it's a default locale and prefix_current_locale config is
|
29
|
+
# false. For a resources array input, return a filtered resources array
|
30
|
+
# based on the locale.
|
30
31
|
#
|
31
|
-
# input
|
32
|
+
# @param input [String, Array] the relative URL, or an array of resources
|
33
|
+
# @param use_locale [String] another locale to use beside the current one
|
34
|
+
# (must be in site's `available_locales` config)
|
35
|
+
# @return [String, Array] the prefixed relative URL, or filtered resources
|
36
|
+
def in_locale(input, use_locale = nil)
|
37
|
+
site = @context.registers[:site]
|
38
|
+
use_locale ||= site.locale
|
39
|
+
|
40
|
+
# If we're given a collection, filter down and return
|
41
|
+
if input.is_a?(Array)
|
42
|
+
return input.select do |res|
|
43
|
+
res.data[:locale].to_sym == use_locale.to_sym
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if !site.config.prefix_default_locale &&
|
48
|
+
use_locale.to_sym == site.config.default_locale
|
49
|
+
return input
|
50
|
+
end
|
51
|
+
|
52
|
+
return input unless site.config.available_locales.include?(use_locale.to_sym)
|
53
|
+
|
54
|
+
"#{use_locale}/#{input.to_s.delete_prefix("/")}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Strips trailing `/index.html` from URLs to create pretty permalinks
|
32
58
|
#
|
33
|
-
#
|
59
|
+
# @param input [String] the URL with a possible `/index.html`
|
60
|
+
# @return [String] a URL with the trailing `/index.html` removed
|
34
61
|
def strip_index(input)
|
35
62
|
return if input.nil? || input.to_s.empty?
|
36
63
|
|
@@ -42,7 +69,7 @@ module Bridgetown
|
|
42
69
|
# @param input [Object] value which responds to `to_s`
|
43
70
|
# @return [String]
|
44
71
|
def strip_extname(input)
|
45
|
-
Pathname.new(input.to_s).
|
72
|
+
Pathname.new(input.to_s).then do |path|
|
46
73
|
path.dirname + path.basename(".*")
|
47
74
|
end.to_s
|
48
75
|
end
|
@@ -9,10 +9,12 @@ module Bridgetown
|
|
9
9
|
|
10
10
|
def initialize(site)
|
11
11
|
@site = site
|
12
|
+
@defaults_cache = {}
|
12
13
|
end
|
13
14
|
|
14
15
|
def reset
|
15
16
|
@glob_cache = {}
|
17
|
+
@defaults_cache = {}
|
16
18
|
end
|
17
19
|
|
18
20
|
def ensure_time!(set)
|
@@ -29,16 +31,19 @@ module Bridgetown
|
|
29
31
|
# Collects a hash with all default values for a resource
|
30
32
|
#
|
31
33
|
# @param path [String] the relative path of the resource
|
32
|
-
# @param
|
34
|
+
# @param collection_name [Symbol] :posts, :pages, etc.
|
33
35
|
#
|
34
|
-
# @
|
35
|
-
def all(path,
|
36
|
-
|
36
|
+
# @return [Hash] all default values (an empty hash if there are none)
|
37
|
+
def all(path, collection_name)
|
38
|
+
if @defaults_cache.key?([path, collection_name])
|
39
|
+
return @defaults_cache[[path, collection_name]]
|
40
|
+
end
|
37
41
|
|
42
|
+
defaults = {}
|
38
43
|
merge_data_cascade_for_path(path, defaults)
|
39
44
|
|
40
45
|
old_scope = nil
|
41
|
-
matching_sets(path,
|
46
|
+
matching_sets(path, collection_name).each do |set|
|
42
47
|
if has_precedence?(old_scope, set["scope"])
|
43
48
|
defaults = Utils.deep_merge_hashes(defaults, set["values"])
|
44
49
|
old_scope = set["scope"]
|
@@ -46,7 +51,8 @@ module Bridgetown
|
|
46
51
|
defaults = Utils.deep_merge_hashes(set["values"], defaults)
|
47
52
|
end
|
48
53
|
end
|
49
|
-
|
54
|
+
|
55
|
+
@defaults_cache[[path, collection_name]] = defaults
|
50
56
|
end
|
51
57
|
|
52
58
|
private
|
@@ -123,7 +129,7 @@ module Bridgetown
|
|
123
129
|
# @param scope [Hash] the defaults set being asked about
|
124
130
|
# @param collection [Symbol] the collection of the resource being processed
|
125
131
|
#
|
126
|
-
# @
|
132
|
+
# @return [Boolean] whether either of the above conditions are satisfied
|
127
133
|
def applies_collection?(scope, collection)
|
128
134
|
!scope.key?("collection") || scope["collection"].eql?(collection.to_s)
|
129
135
|
end
|
@@ -132,7 +138,7 @@ module Bridgetown
|
|
132
138
|
#
|
133
139
|
# @param set [Hash] the default value hash as defined in bridgetown.config.yml
|
134
140
|
#
|
135
|
-
# @
|
141
|
+
# @return [Boolean] if the set is valid and can be used
|
136
142
|
def valid?(set)
|
137
143
|
set.is_a?(Hash) && set["values"].is_a?(Hash)
|
138
144
|
end
|
@@ -4,7 +4,9 @@ module Bridgetown
|
|
4
4
|
class GeneratedPage
|
5
5
|
include LayoutPlaceable
|
6
6
|
include LiquidRenderable
|
7
|
+
include Localizable
|
7
8
|
include Publishable
|
9
|
+
include Transformable
|
8
10
|
|
9
11
|
attr_writer :dir
|
10
12
|
attr_accessor :site, :paginator, :name, :ext, :basename, :data, :content, :output
|
@@ -12,7 +14,7 @@ module Bridgetown
|
|
12
14
|
alias_method :extname, :ext
|
13
15
|
|
14
16
|
# A set of extensions that are considered HTML or HTML-like so we
|
15
|
-
# should not alter them
|
17
|
+
# should not alter them
|
16
18
|
|
17
19
|
HTML_EXTENSIONS = %w(
|
18
20
|
.html
|
@@ -54,11 +56,11 @@ module Bridgetown
|
|
54
56
|
output || content || ""
|
55
57
|
end
|
56
58
|
|
57
|
-
# Accessor for data properties by Liquid
|
59
|
+
# Accessor for data properties by Liquid
|
58
60
|
#
|
59
|
-
# property
|
61
|
+
# @param property [String] name of the property to retrieve
|
60
62
|
#
|
61
|
-
#
|
63
|
+
# @return [Object]
|
62
64
|
def [](property)
|
63
65
|
data[property]
|
64
66
|
end
|
@@ -67,7 +69,7 @@ module Bridgetown
|
|
67
69
|
# upon generation. This is derived from the permalink or, if
|
68
70
|
# permalink is absent, will be '/'
|
69
71
|
#
|
70
|
-
#
|
72
|
+
# @return [String]
|
71
73
|
def dir
|
72
74
|
if url.end_with?("/")
|
73
75
|
url
|
@@ -78,6 +80,8 @@ module Bridgetown
|
|
78
80
|
end
|
79
81
|
|
80
82
|
# Liquid representation of current page
|
83
|
+
#
|
84
|
+
# @return [Bridgetown::Drops::GeneratedPageDrop]
|
81
85
|
def to_liquid
|
82
86
|
@liquid_drop ||= Drops::GeneratedPageDrop.new(self)
|
83
87
|
end
|
@@ -90,7 +94,7 @@ module Bridgetown
|
|
90
94
|
|
91
95
|
# The template of the permalink.
|
92
96
|
#
|
93
|
-
#
|
97
|
+
# @return [String]
|
94
98
|
def template
|
95
99
|
if !html?
|
96
100
|
"/:path/:basename:output_ext"
|
@@ -103,7 +107,7 @@ module Bridgetown
|
|
103
107
|
|
104
108
|
# The generated relative url of this page. e.g. /about.html.
|
105
109
|
#
|
106
|
-
#
|
110
|
+
# @return [String]
|
107
111
|
def url
|
108
112
|
@url ||= URL.new(
|
109
113
|
template: template,
|
@@ -123,6 +127,22 @@ module Bridgetown
|
|
123
127
|
}
|
124
128
|
end
|
125
129
|
|
130
|
+
# Layout associated with this resource
|
131
|
+
# This will output a warning if the layout can't be found.
|
132
|
+
#
|
133
|
+
# @return [Bridgetown::Layout]
|
134
|
+
def layout
|
135
|
+
return @layout if @layout
|
136
|
+
return if no_layout?
|
137
|
+
|
138
|
+
@layout = site.layouts[data.layout].tap do |layout|
|
139
|
+
unless layout
|
140
|
+
Bridgetown.logger.warn "Generated Page:", "Layout '#{data.layout}' " \
|
141
|
+
"requested via #{relative_path} does not exist."
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
126
146
|
# Overide this in subclasses for custom initialization behavior
|
127
147
|
def process
|
128
148
|
# no-op by default
|
@@ -139,21 +159,68 @@ module Bridgetown
|
|
139
159
|
@relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix("/")
|
140
160
|
end
|
141
161
|
|
142
|
-
# FIXME: spinning up a new Renderer object just to get an extension
|
143
|
-
# seems excessive
|
144
|
-
#
|
145
162
|
# The output extension of the page.
|
146
163
|
#
|
147
|
-
#
|
164
|
+
# @return [String]
|
148
165
|
def output_ext
|
149
|
-
@output_ext ||=
|
166
|
+
@output_ext ||= (permalink_ext || converter_output_ext)
|
167
|
+
end
|
168
|
+
|
169
|
+
def permalink_ext
|
170
|
+
page_permalink = permalink
|
171
|
+
if page_permalink &&
|
172
|
+
!page_permalink.end_with?("/")
|
173
|
+
permalink_ext = File.extname(page_permalink)
|
174
|
+
permalink_ext unless permalink_ext.empty?
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def converter_output_ext
|
179
|
+
if output_exts.size == 1
|
180
|
+
output_exts.last
|
181
|
+
else
|
182
|
+
output_exts[-2]
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def output_exts
|
187
|
+
@output_exts ||= converters.filter_map do |c|
|
188
|
+
c.output_ext(extname)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# @return [Array<Bridgetown::Converter>]
|
193
|
+
def converters
|
194
|
+
@converters ||= site.matched_converters_for_convertible(self)
|
195
|
+
end
|
196
|
+
|
197
|
+
def transform!
|
198
|
+
Bridgetown.logger.debug "Transforming:", relative_path
|
199
|
+
|
200
|
+
trigger_hooks :pre_render
|
201
|
+
self.content = transform_content(self)
|
202
|
+
place_in_layout? ? place_into_layouts : self.output = content.dup
|
203
|
+
trigger_hooks :post_render
|
204
|
+
|
205
|
+
self
|
206
|
+
end
|
207
|
+
|
208
|
+
def place_into_layouts
|
209
|
+
Bridgetown.logger.debug "Placing in Layouts:", relative_path
|
210
|
+
rendered_output = content.dup
|
211
|
+
|
212
|
+
site.validated_layouts_for(self, data.layout).each do |layout|
|
213
|
+
rendered_output = transform_with_layout(layout, rendered_output, self)
|
214
|
+
end
|
215
|
+
|
216
|
+
self.output = rendered_output
|
150
217
|
end
|
151
218
|
|
152
219
|
# Obtain destination path.
|
153
220
|
#
|
154
|
-
# dest
|
221
|
+
# @param dest [String] path to the destination dir
|
155
222
|
#
|
156
|
-
#
|
223
|
+
# @return [String]
|
157
224
|
def destination(dest)
|
158
225
|
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
159
226
|
path = File.join(path, "index") if url.end_with?("/")
|
@@ -163,9 +230,7 @@ module Bridgetown
|
|
163
230
|
|
164
231
|
# Write the generated page file to the destination directory.
|
165
232
|
#
|
166
|
-
# dest
|
167
|
-
#
|
168
|
-
# Returns nothing.
|
233
|
+
# @param dest [String] path to the destination dir
|
169
234
|
def write(dest)
|
170
235
|
path = destination(dest)
|
171
236
|
FileUtils.mkdir_p(File.dirname(path))
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
|
3
|
+
require "kramdown-parser-gfm"
|
4
|
+
|
5
|
+
module Kramdown
|
6
|
+
module Parser
|
7
|
+
class GFM
|
8
|
+
MARK_DELIMITER = %r{(==|::)+}.freeze
|
9
|
+
MARK_MATCH = %r{#{MARK_DELIMITER}(?!\s|=|:).*?[^\s=:]#{MARK_DELIMITER}}m.freeze
|
10
|
+
|
11
|
+
# Monkey-patch GFM initializer to add our new mark parser
|
12
|
+
alias_method :_old_initialize, :initialize
|
13
|
+
def initialize(source, options)
|
14
|
+
_old_initialize(source, options)
|
15
|
+
@span_parsers << :mark if @options[:mark_highlighting]
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_mark
|
19
|
+
line_number = @src.current_line_number
|
20
|
+
|
21
|
+
@src.pos += @src.matched_size
|
22
|
+
el = Element.new(:html_element, "mark", {}, category: :span, line: line_number)
|
23
|
+
@tree.children << el
|
24
|
+
|
25
|
+
env = save_env
|
26
|
+
reset_env(src: Kramdown::Utils::StringScanner.new(@src.matched[2..-3], line_number),
|
27
|
+
text_type: :text)
|
28
|
+
parse_spans(el)
|
29
|
+
restore_env(env)
|
30
|
+
|
31
|
+
el
|
32
|
+
end
|
33
|
+
define_parser(:mark, MARK_MATCH)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -95,8 +95,7 @@ module Bridgetown
|
|
95
95
|
|
96
96
|
# @return [Bridgetown::Resource::Base]
|
97
97
|
def as_resource_in_collection
|
98
|
-
collection.
|
99
|
-
collection.resources.last
|
98
|
+
collection.add_resource_from_model(self)
|
100
99
|
end
|
101
100
|
|
102
101
|
# @return [Bridgetown::Resource::Base]
|
@@ -3,55 +3,24 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
class Plugin
|
5
5
|
extend ActiveSupport::DescendantsTracker
|
6
|
+
include Bridgetown::Prioritizable
|
6
7
|
|
7
|
-
|
8
|
-
low: -10,
|
8
|
+
self.priorities = {
|
9
9
|
highest: 100,
|
10
|
-
lowest: -100,
|
11
|
-
normal: 0,
|
12
10
|
high: 10,
|
11
|
+
normal: 0,
|
12
|
+
low: -10,
|
13
|
+
lowest: -100,
|
13
14
|
}.freeze
|
14
15
|
|
15
16
|
SourceManifest = Struct.new(:origin, :components, :content, :layouts, keyword_init: true)
|
16
17
|
|
17
|
-
# Get or set the priority of this plugin. When called without an
|
18
|
-
# argument it returns the priority. When an argument is given, it will
|
19
|
-
# set the priority.
|
20
|
-
#
|
21
|
-
# priority - The Symbol priority (default: nil). Valid options are:
|
22
|
-
# :lowest, :low, :normal, :high, :highest
|
23
|
-
#
|
24
|
-
# Returns the Symbol priority.
|
25
|
-
def self.priority(priority = nil)
|
26
|
-
@priority ||= nil
|
27
|
-
@priority = priority if priority && PRIORITIES.key?(priority)
|
28
|
-
@priority || :normal
|
29
|
-
end
|
30
|
-
|
31
|
-
# Spaceship is priority [higher -> lower]
|
32
|
-
#
|
33
|
-
# other - The class to be compared.
|
34
|
-
#
|
35
|
-
# Returns -1, 0, 1.
|
36
|
-
def self.<=>(other)
|
37
|
-
PRIORITIES[other.priority] <=> PRIORITIES[priority]
|
38
|
-
end
|
39
|
-
|
40
|
-
# Spaceship is priority [higher -> lower]
|
41
|
-
#
|
42
|
-
# other - The class to be compared.
|
43
|
-
#
|
44
|
-
# Returns -1, 0, 1.
|
45
|
-
def <=>(other)
|
46
|
-
self.class <=> other.class
|
47
|
-
end
|
48
|
-
|
49
18
|
# Initialize a new plugin. This should be overridden by the subclass.
|
50
19
|
#
|
51
20
|
# config - The Hash of configuration options.
|
52
21
|
#
|
53
22
|
# Returns a new instance.
|
54
|
-
def initialize(config = {})
|
23
|
+
def initialize(config = {}) # rubocop:disable Style/RedundantInitialize
|
55
24
|
# no-op for default
|
56
25
|
end
|
57
26
|
end
|
@@ -40,7 +40,8 @@ module Bridgetown
|
|
40
40
|
@loaders_manager = Bridgetown::Utils::LoadersManager.new(site.config)
|
41
41
|
end
|
42
42
|
|
43
|
-
def self.require_from_bundler
|
43
|
+
def self.require_from_bundler(skip_yarn: false) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
44
|
+
# NOTE: investigate why this ENV var is really necessary
|
44
45
|
if !ENV["BRIDGETOWN_NO_BUNDLER_REQUIRE"] && File.file?("Gemfile")
|
45
46
|
require "bundler"
|
46
47
|
|
@@ -48,7 +49,7 @@ module Bridgetown
|
|
48
49
|
(dep.groups & [PLUGINS_GROUP]).any? && dep.should_include?
|
49
50
|
end
|
50
51
|
|
51
|
-
install_yarn_dependencies(required_gems)
|
52
|
+
install_yarn_dependencies(required_gems) unless skip_yarn
|
52
53
|
|
53
54
|
required_gems.each do |installed_gem|
|
54
55
|
add_registered_plugin installed_gem
|
@@ -19,6 +19,11 @@ module Bridgetown
|
|
19
19
|
attr_accessor :loaders_manager
|
20
20
|
end
|
21
21
|
|
22
|
+
# Start up the Roda Rack application and the Zeitwerk autoloaders. Ensure the
|
23
|
+
# Roda app is provided the preloaded Bridgetown site configuration. Handle
|
24
|
+
# any uncaught Roda errors.
|
25
|
+
#
|
26
|
+
# @param [Bridgetown::Rack::Roda] optional, defaults to the `RodaApp` constant
|
22
27
|
def self.boot(roda_app = nil)
|
23
28
|
self.loaders_manager =
|
24
29
|
Bridgetown::Utils::LoadersManager.new(Bridgetown::Current.preloaded_configuration)
|
@@ -4,19 +4,29 @@ require "logger"
|
|
4
4
|
|
5
5
|
module Bridgetown
|
6
6
|
module Rack
|
7
|
-
class Logger <
|
7
|
+
class Logger < Bridgetown::LogWriter
|
8
8
|
def self.message_with_prefix(msg)
|
9
|
-
return if msg.include?("/_bridgetown/live_reload")
|
9
|
+
# return if msg.include?("/_bridgetown/live_reload")
|
10
10
|
|
11
11
|
"\e[35m[Server]\e[0m #{msg}"
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
super
|
14
|
+
def enable_prefix
|
16
15
|
@formatter = proc do |_, _, _, msg|
|
17
16
|
self.class.message_with_prefix(msg)
|
18
17
|
end
|
19
18
|
end
|
19
|
+
|
20
|
+
def add(severity, message = nil, progname = nil)
|
21
|
+
return if progname&.include?("/_bridgetown/live_reload")
|
22
|
+
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(*_args)
|
27
|
+
super()
|
28
|
+
enable_prefix
|
29
|
+
end
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|