bridgetown-core 0.15.0.beta2 → 0.15.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bridgetown-core/commands/concerns/actions.rb +28 -12
- data/lib/bridgetown-core/concerns/convertible.rb +1 -4
- data/lib/bridgetown-core/concerns/site/renderable.rb +1 -2
- data/lib/bridgetown-core/excerpt.rb +4 -1
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
- data/lib/bridgetown-core/plugin_manager.rb +26 -13
- data/lib/bridgetown-core/renderer.rb +3 -3
- data/lib/bridgetown-core/tags/render_content.rb +4 -2
- data/lib/bridgetown-core/utils.rb +44 -0
- data/lib/bridgetown-core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0731d836363a7cc613e8a42a833fb1d45e50f293558cd78238d9b214b73e2d99
|
4
|
+
data.tar.gz: 2597ac785d145bcd26083d08e803d4f0937165d8150bfb05eea5b9ba90ad6e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bead893392ffe25b85bcef0419201fa5a8752793f9b8812ac26e512ab35e2638d888ec02c64c672e7930c509afbe0fffa2c98b40316351028951469e63c9310
|
7
|
+
data.tar.gz: e8083bd29fb64deef6f0fe17b028cb1aa373944cfcb15fe0ce686b03f6db6e12bcdbcb25842e4a508b2979facb9655cfe358fac685f7c2af4c44e2a6edb65c1c
|
@@ -77,27 +77,43 @@ module Bridgetown
|
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
+
def determine_remote_filename(arg)
|
81
|
+
if arg.end_with?(".rb")
|
82
|
+
arg.split("/").yield_self do |segments|
|
83
|
+
arg.sub!(%r!/#{segments.last}$!, "")
|
84
|
+
segments.last
|
85
|
+
end
|
86
|
+
else
|
87
|
+
"bridgetown.automation.rb"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
80
91
|
# TODO: option to download and confirm remote automation?
|
81
92
|
def transform_automation_url(arg)
|
82
93
|
return arg unless arg.start_with?("http")
|
83
94
|
|
84
|
-
remote_file =
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
95
|
+
remote_file = determine_remote_filename(arg)
|
96
|
+
|
97
|
+
github_regex = %r!https://github\.com!
|
98
|
+
github_tree_regex = %r!#{github_regex}/.*/.*/tree/.*/?!
|
99
|
+
|
100
|
+
github_match = github_regex.match(arg)
|
101
|
+
github_tree_match = github_tree_regex.match(arg)
|
92
102
|
|
93
103
|
if arg.start_with?("https://gist.github.com")
|
94
104
|
return arg.sub(
|
95
105
|
"https://gist.github.com", "https://gist.githubusercontent.com"
|
96
106
|
) + "/raw/#{remote_file}"
|
97
|
-
elsif
|
98
|
-
|
99
|
-
|
100
|
-
|
107
|
+
elsif github_match
|
108
|
+
new_url = arg.sub(github_regex, "https://raw.githubusercontent.com")
|
109
|
+
|
110
|
+
if github_tree_match
|
111
|
+
new_url = new_url.sub("/tree/", "/")
|
112
|
+
else
|
113
|
+
new_url += "/master"
|
114
|
+
end
|
115
|
+
|
116
|
+
return "#{new_url}/#{remote_file}"
|
101
117
|
end
|
102
118
|
|
103
119
|
arg + "/#{remote_file}"
|
@@ -188,13 +188,10 @@ module Bridgetown
|
|
188
188
|
#
|
189
189
|
# Returns nothing.
|
190
190
|
def do_layout(payload, layouts)
|
191
|
-
|
191
|
+
_renderer.tap do |renderer|
|
192
192
|
renderer.layouts = layouts
|
193
193
|
renderer.payload = payload
|
194
194
|
end.run
|
195
|
-
|
196
|
-
Bridgetown.logger.debug "Post-Render Hooks:", relative_path
|
197
|
-
Bridgetown::Hooks.trigger hook_owner, :post_render, self
|
198
195
|
ensure
|
199
196
|
@_renderer = nil # this will allow the modifications above to disappear
|
200
197
|
end
|
@@ -43,8 +43,7 @@ module Bridgetown
|
|
43
43
|
def render_regenerated(document, payload)
|
44
44
|
return unless regenerator.regenerate?(document)
|
45
45
|
|
46
|
-
|
47
|
-
document.trigger_hooks(:post_render)
|
46
|
+
Bridgetown::Renderer.new(self, document, payload).run
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -10,11 +10,8 @@ module Bridgetown
|
|
10
10
|
|
11
11
|
def parse(content)
|
12
12
|
measure_time do
|
13
|
-
# Remove extraneous indentation for rendercontent tags
|
14
|
-
processed_content = content.gsub(%r!^[ \t]+{%-? rendercontent!, "{% rendercontent")
|
15
|
-
|
16
13
|
@renderer.cache[@filename] ||= Liquid::Template.parse(
|
17
|
-
|
14
|
+
content, line_numbers: true
|
18
15
|
)
|
19
16
|
end
|
20
17
|
@template = @renderer.cache[@filename]
|
@@ -67,30 +67,43 @@ module Bridgetown
|
|
67
67
|
# If that exact package hasn't been installed, execute yarn add
|
68
68
|
#
|
69
69
|
# Returns nothing.
|
70
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
71
70
|
def self.install_yarn_dependencies(required_gems)
|
72
71
|
return unless File.exist?("package.json")
|
73
72
|
|
74
73
|
package_json = JSON.parse(File.read("package.json"))
|
75
74
|
|
76
75
|
required_gems.each do |loaded_gem|
|
77
|
-
|
78
|
-
|
79
|
-
yarn_add_dependency = loaded_gem.to_spec.metadata["yarn-add"].split("@")
|
80
|
-
next unless yarn_add_dependency.length == 2
|
81
|
-
|
82
|
-
# check matching version number is see if it's already installed
|
83
|
-
if package_json["dependencies"]
|
84
|
-
current_package = package_json["dependencies"].dig(yarn_add_dependency.first)
|
85
|
-
next unless current_package.nil? || current_package != yarn_add_dependency.last
|
86
|
-
end
|
76
|
+
yarn_dependency = find_yarn_dependency(loaded_gem)
|
77
|
+
next unless add_yarn_dependency?(yarn_dependency, package_json)
|
87
78
|
|
88
79
|
# all right, time to install the package
|
89
|
-
cmd = "yarn add #{
|
80
|
+
cmd = "yarn add #{yarn_dependency.join("@")}"
|
90
81
|
system cmd
|
91
82
|
end
|
92
83
|
end
|
93
|
-
|
84
|
+
|
85
|
+
def self.find_yarn_dependency(loaded_gem)
|
86
|
+
yarn_dependency = loaded_gem.to_spec&.metadata&.dig("yarn-add")&.split("@")
|
87
|
+
return nil if yarn_dependency&.length != 2
|
88
|
+
|
89
|
+
yarn_dependency
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.add_yarn_dependency?(yarn_dependency, package_json)
|
93
|
+
return false if yarn_dependency.nil?
|
94
|
+
|
95
|
+
# check matching version number is see if it's already installed
|
96
|
+
if package_json["dependencies"]
|
97
|
+
current_version = package_json["dependencies"].dig(yarn_dependency.first)
|
98
|
+
package_requires_updating?(current_version, yarn_dependency.last)
|
99
|
+
else
|
100
|
+
true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.package_requires_updating?(current_version, dep_version)
|
105
|
+
current_version.nil? || current_version != dep_version && !current_version.include?("/")
|
106
|
+
end
|
94
107
|
|
95
108
|
# Require all .rb files
|
96
109
|
#
|
@@ -53,7 +53,7 @@ module Bridgetown
|
|
53
53
|
|
54
54
|
# Prepare payload and render the document
|
55
55
|
#
|
56
|
-
# Returns
|
56
|
+
# Returns nothing
|
57
57
|
def run
|
58
58
|
Bridgetown.logger.debug "Rendering:", document.relative_path
|
59
59
|
|
@@ -63,8 +63,8 @@ module Bridgetown
|
|
63
63
|
assign_layout_data!
|
64
64
|
|
65
65
|
document.trigger_hooks(:pre_render, payload)
|
66
|
-
|
67
|
-
|
66
|
+
document.output = render_document
|
67
|
+
document.trigger_hooks(:post_render)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Render the document.
|
@@ -5,7 +5,9 @@ module Bridgetown
|
|
5
5
|
class BlockRenderTag < Liquid::Block
|
6
6
|
def render(context)
|
7
7
|
context.stack({}) do
|
8
|
-
|
8
|
+
# unindent the incoming text
|
9
|
+
content = Bridgetown::Utils.reindent_for_markdown(super)
|
10
|
+
|
9
11
|
regions = gather_content_regions(context)
|
10
12
|
|
11
13
|
site = context.registers[:site]
|
@@ -17,7 +19,7 @@ module Bridgetown
|
|
17
19
|
unless regions.empty?
|
18
20
|
regions.each do |region_name, region_content|
|
19
21
|
region_name = region_name.sub("content_with_region_", "")
|
20
|
-
context[region_name] = converter.convert(region_content.
|
22
|
+
context[region_name] = converter.convert(region_content.strip_heredoc)
|
21
23
|
render_params.push "#{region_name}: #{region_name}"
|
22
24
|
end
|
23
25
|
end
|
@@ -287,6 +287,50 @@ module Bridgetown
|
|
287
287
|
merged
|
288
288
|
end
|
289
289
|
|
290
|
+
# Returns a string that's been reindented so that Markdown's four+ spaces =
|
291
|
+
# code doesn't get triggered for nested Liquid components
|
292
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
293
|
+
def reindent_for_markdown(input)
|
294
|
+
lines = input.lines
|
295
|
+
return input if lines.first.nil?
|
296
|
+
|
297
|
+
starting_indentation = lines.find { |line| line != "\n" }&.match(%r!^ +!)
|
298
|
+
return input unless starting_indentation
|
299
|
+
|
300
|
+
starting_indent_length = starting_indentation[0].length
|
301
|
+
|
302
|
+
skip_pre_lines = false
|
303
|
+
lines.map do |line|
|
304
|
+
continue_processing = !skip_pre_lines
|
305
|
+
|
306
|
+
if skip_pre_lines
|
307
|
+
skip_pre_lines = false if line.include?("</pre>")
|
308
|
+
end
|
309
|
+
if line.include?("<pre")
|
310
|
+
skip_pre_lines = true
|
311
|
+
continue_processing = false
|
312
|
+
end
|
313
|
+
|
314
|
+
if continue_processing
|
315
|
+
line_indentation = line.match(%r!^ +!).yield_self do |indent|
|
316
|
+
indent.nil? ? "" : indent[0]
|
317
|
+
end
|
318
|
+
new_indentation = line_indentation.rjust(starting_indent_length, " ")
|
319
|
+
|
320
|
+
if %r!^ +!.match?(line)
|
321
|
+
line
|
322
|
+
.sub(%r!^ {1,#{starting_indent_length}}!, new_indentation)
|
323
|
+
.sub(%r!^#{new_indentation}!, "")
|
324
|
+
else
|
325
|
+
line
|
326
|
+
end
|
327
|
+
else
|
328
|
+
line
|
329
|
+
end
|
330
|
+
end.join("")
|
331
|
+
end
|
332
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
333
|
+
|
290
334
|
private
|
291
335
|
|
292
336
|
def merge_values(target, overwrite)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.0.
|
4
|
+
version: 0.15.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|