bridgetown-core 0.17.0 → 0.18.3
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/.yardopts +1 -0
- data/bridgetown-core.gemspec +1 -0
- data/lib/bridgetown-core.rb +44 -29
- data/lib/bridgetown-core/collection.rb +5 -1
- data/lib/bridgetown-core/commands/apply.rb +2 -2
- data/lib/bridgetown-core/commands/new.rb +1 -1
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/concerns/liquid_renderable.rb +10 -0
- data/lib/bridgetown-core/concerns/site/configurable.rb +21 -23
- data/lib/bridgetown-core/concerns/site/content.rb +46 -33
- data/lib/bridgetown-core/concerns/site/extensible.rb +14 -13
- data/lib/bridgetown-core/concerns/site/localizable.rb +6 -2
- data/lib/bridgetown-core/concerns/site/processable.rb +12 -15
- data/lib/bridgetown-core/concerns/site/renderable.rb +34 -26
- data/lib/bridgetown-core/concerns/site/writable.rb +7 -15
- data/lib/bridgetown-core/concerns/validatable.rb +2 -2
- data/lib/bridgetown-core/configuration.rb +10 -4
- data/lib/bridgetown-core/converter.rb +0 -42
- data/lib/bridgetown-core/converters/erb_templates.rb +80 -16
- data/lib/bridgetown-core/converters/liquid_templates.rb +103 -0
- data/lib/bridgetown-core/converters/markdown.rb +0 -3
- data/lib/bridgetown-core/document.rb +34 -21
- data/lib/bridgetown-core/drops/site_drop.rb +4 -0
- data/lib/bridgetown-core/drops/unified_payload_drop.rb +0 -1
- data/lib/bridgetown-core/drops/url_drop.rb +19 -3
- data/lib/bridgetown-core/excerpt.rb +1 -1
- data/lib/bridgetown-core/filters.rb +36 -7
- data/lib/bridgetown-core/generators/prototype_generator.rb +42 -25
- data/lib/bridgetown-core/helpers.rb +84 -0
- data/lib/bridgetown-core/liquid_renderer.rb +1 -1
- data/lib/bridgetown-core/log_writer.rb +2 -2
- data/lib/bridgetown-core/page.rb +8 -2
- data/lib/bridgetown-core/plugin_manager.rb +34 -1
- data/lib/bridgetown-core/reader.rb +1 -4
- data/lib/bridgetown-core/readers/data_reader.rb +3 -3
- data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
- data/lib/bridgetown-core/readers/post_reader.rb +28 -15
- data/lib/bridgetown-core/renderer.rb +42 -162
- data/lib/bridgetown-core/ruby_template_view.rb +26 -26
- data/lib/bridgetown-core/site.rb +12 -2
- data/lib/bridgetown-core/tags/render_content.rb +2 -2
- data/lib/bridgetown-core/utils.rb +14 -0
- data/lib/bridgetown-core/utils/ruby_exec.rb +1 -1
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +1 -0
- data/lib/site_template/src/images/.keep +1 -0
- metadata +21 -3
@@ -5,28 +5,9 @@ require "active_support/core_ext/hash/keys"
|
|
5
5
|
|
6
6
|
module Bridgetown
|
7
7
|
class RubyTemplateView
|
8
|
-
|
9
|
-
include Bridgetown::Filters
|
8
|
+
require "bridgetown-core/helpers"
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(site)
|
14
|
-
@site = site
|
15
|
-
|
16
|
-
# duck typing for Liquid context
|
17
|
-
@context = Context.new({ site: @site })
|
18
|
-
end
|
19
|
-
|
20
|
-
def webpack_path(asset_type)
|
21
|
-
Bridgetown::Utils.parse_webpack_manifest_file(@site, asset_type.to_s)
|
22
|
-
end
|
23
|
-
|
24
|
-
def t(*args)
|
25
|
-
I18n.send :t, *args
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
attr_reader :layout, :page, :site, :content
|
10
|
+
attr_reader :layout, :page, :paginator, :site, :content
|
30
11
|
|
31
12
|
def initialize(convertible)
|
32
13
|
if convertible.is_a?(Layout)
|
@@ -34,8 +15,10 @@ module Bridgetown
|
|
34
15
|
@page = layout.current_document
|
35
16
|
@content = layout.current_document_output
|
36
17
|
else
|
18
|
+
@layout = convertible.site.layouts[convertible.data["layout"]]
|
37
19
|
@page = convertible
|
38
20
|
end
|
21
|
+
@paginator = page.paginator if page.respond_to?(:paginator)
|
39
22
|
@site = page.site
|
40
23
|
end
|
41
24
|
|
@@ -43,11 +26,20 @@ module Bridgetown
|
|
43
26
|
raise "Must be implemented in a subclass"
|
44
27
|
end
|
45
28
|
|
29
|
+
def render(item, options = {}, &block)
|
30
|
+
if item.respond_to?(:render_in)
|
31
|
+
item.render_in(self, &block)
|
32
|
+
else
|
33
|
+
partial(item, options, &block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
46
37
|
def site_drop
|
47
38
|
site.site_payload.site
|
48
39
|
end
|
49
40
|
|
50
|
-
def liquid_render(component, options = {})
|
41
|
+
def liquid_render(component, options = {}, &block)
|
42
|
+
options[:_block_content] = capture(&block) if block && respond_to?(:capture)
|
51
43
|
render_statement = _render_statement(component, options)
|
52
44
|
|
53
45
|
template = site.liquid_renderer.file(
|
@@ -61,7 +53,7 @@ module Bridgetown
|
|
61
53
|
end
|
62
54
|
|
63
55
|
def helpers
|
64
|
-
@helpers ||= Helpers.new(
|
56
|
+
@helpers ||= Helpers.new(self, site)
|
65
57
|
end
|
66
58
|
|
67
59
|
def method_missing(method, *args, &block)
|
@@ -79,11 +71,19 @@ module Bridgetown
|
|
79
71
|
private
|
80
72
|
|
81
73
|
def _render_statement(component, options)
|
82
|
-
render_statement = [
|
74
|
+
render_statement = if options[:_block_content]
|
75
|
+
["{% rendercontent \"#{component}\""]
|
76
|
+
else
|
77
|
+
["{% render \"#{component}\""]
|
78
|
+
end
|
83
79
|
unless options.empty?
|
84
80
|
render_statement << ", " + options.keys.map { |k| "#{k}: #{k}" }.join(", ")
|
85
81
|
end
|
86
82
|
render_statement << " %}"
|
83
|
+
if options[:_block_content]
|
84
|
+
render_statement << options[:_block_content]
|
85
|
+
render_statement << "{% endrendercontent %}"
|
86
|
+
end
|
87
87
|
render_statement.join
|
88
88
|
end
|
89
89
|
|
@@ -91,8 +91,8 @@ module Bridgetown
|
|
91
91
|
{
|
92
92
|
registers: {
|
93
93
|
site: site,
|
94
|
-
page: page,
|
95
|
-
cached_partials: Bridgetown::
|
94
|
+
page: page.to_liquid,
|
95
|
+
cached_partials: Bridgetown::Converters::LiquidTemplates.cached_partials,
|
96
96
|
},
|
97
97
|
strict_filters: site.config["liquid"]["strict_filters"],
|
98
98
|
strict_variables: site.config["liquid"]["strict_variables"],
|
data/lib/bridgetown-core/site.rb
CHANGED
@@ -15,8 +15,18 @@ module Bridgetown
|
|
15
15
|
attr_reader :root_dir, :source, :dest, :cache_dir, :config,
|
16
16
|
:regenerator, :liquid_renderer, :components_load_paths,
|
17
17
|
:includes_load_paths
|
18
|
-
|
19
|
-
|
18
|
+
|
19
|
+
# All files not pages/documents or structured data in the source folder
|
20
|
+
# @return [Array<StaticFile>]
|
21
|
+
attr_accessor :static_files
|
22
|
+
|
23
|
+
# @return [Array<Layout>]
|
24
|
+
attr_accessor :layouts
|
25
|
+
|
26
|
+
# @return [Array<Page>]
|
27
|
+
attr_accessor :pages
|
28
|
+
|
29
|
+
attr_accessor :exclude, :include, :lsi, :highlighter, :permalink_style,
|
20
30
|
:time, :future, :unpublished, :limit_posts,
|
21
31
|
:keep_files, :baseurl, :data, :file_read_opts,
|
22
32
|
:plugin_manager, :converters, :generators, :reader
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
module Tags
|
5
5
|
class BlockRenderTag < Liquid::Block
|
6
|
-
# rubocop:disable Metrics/
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
7
|
def render(context)
|
8
8
|
context.stack({}) do
|
9
9
|
# unindent the incoming text
|
@@ -37,7 +37,7 @@ module Bridgetown
|
|
37
37
|
.render_tag(context, +"")
|
38
38
|
end
|
39
39
|
end
|
40
|
-
# rubocop:enable Metrics/
|
40
|
+
# rubocop:enable Metrics/MethodLength
|
41
41
|
|
42
42
|
private
|
43
43
|
|
@@ -23,6 +23,20 @@ module Bridgetown
|
|
23
23
|
slug.gsub(%r![_ ]!, "-").split("-").map!(&:capitalize).join(" ")
|
24
24
|
end
|
25
25
|
|
26
|
+
# XML escape a string for use. Replaces any special characters with
|
27
|
+
# appropriate HTML entity replacements.
|
28
|
+
#
|
29
|
+
# Examples
|
30
|
+
#
|
31
|
+
# xml_escape('foo "bar" <baz>')
|
32
|
+
# # => "foo "bar" <baz>"
|
33
|
+
#
|
34
|
+
# @param input [String] The String to escape.
|
35
|
+
# @return [String] the escaped String.
|
36
|
+
def xml_escape(input)
|
37
|
+
input.to_s.encode(xml: :attr).gsub(%r!\A"|"\Z!, "")
|
38
|
+
end
|
39
|
+
|
26
40
|
# Non-destructive version of deep_merge_hashes! See that method.
|
27
41
|
#
|
28
42
|
# Returns the merged hashes.
|
@@ -59,7 +59,7 @@ module Bridgetown
|
|
59
59
|
|
60
60
|
# This is where the magic happens! DON'T BE EVIL!!! ;-)
|
61
61
|
output = obj.instance_eval(ruby_code)
|
62
|
-
output.is_a?(Hash) ? output.
|
62
|
+
output.is_a?(Hash) ? output.with_dot_access : output
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -130,6 +130,7 @@ module Bridgetown
|
|
130
130
|
Bridgetown::Hooks.trigger :site, :pre_reload, site
|
131
131
|
Bridgetown::Hooks.clear_reloadable_hooks
|
132
132
|
site.plugin_manager.reload_plugin_files
|
133
|
+
site.plugin_manager.reload_component_loaders
|
133
134
|
site.process
|
134
135
|
Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
|
135
136
|
" #{(Time.now - time).ceil(2)} seconds."
|
@@ -0,0 +1 @@
|
|
1
|
+
|
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.
|
4
|
+
version: 0.18.3
|
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-
|
11
|
+
date: 2020-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: hash_with_dot_access
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: i18n
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -298,6 +312,7 @@ executables:
|
|
298
312
|
extensions: []
|
299
313
|
extra_rdoc_files: []
|
300
314
|
files:
|
315
|
+
- ".yardopts"
|
301
316
|
- Rakefile
|
302
317
|
- bin/bridgetown
|
303
318
|
- bridgetown-core.gemspec
|
@@ -336,6 +351,7 @@ files:
|
|
336
351
|
- lib/bridgetown-core/converter.rb
|
337
352
|
- lib/bridgetown-core/converters/erb_templates.rb
|
338
353
|
- lib/bridgetown-core/converters/identity.rb
|
354
|
+
- lib/bridgetown-core/converters/liquid_templates.rb
|
339
355
|
- lib/bridgetown-core/converters/markdown.rb
|
340
356
|
- lib/bridgetown-core/converters/markdown/kramdown_parser.rb
|
341
357
|
- lib/bridgetown-core/converters/smartypants.rb
|
@@ -363,6 +379,7 @@ files:
|
|
363
379
|
- lib/bridgetown-core/frontmatter_defaults.rb
|
364
380
|
- lib/bridgetown-core/generator.rb
|
365
381
|
- lib/bridgetown-core/generators/prototype_generator.rb
|
382
|
+
- lib/bridgetown-core/helpers.rb
|
366
383
|
- lib/bridgetown-core/hooks.rb
|
367
384
|
- lib/bridgetown-core/layout.rb
|
368
385
|
- lib/bridgetown-core/liquid_extensions.rb
|
@@ -435,6 +452,7 @@ files:
|
|
435
452
|
- lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb
|
436
453
|
- lib/site_template/src/about.md
|
437
454
|
- lib/site_template/src/favicon.ico
|
455
|
+
- lib/site_template/src/images/.keep
|
438
456
|
- lib/site_template/src/index.md
|
439
457
|
- lib/site_template/src/posts.md
|
440
458
|
- lib/site_template/start.js
|
@@ -464,7 +482,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
464
482
|
- !ruby/object:Gem::Version
|
465
483
|
version: 2.7.0
|
466
484
|
requirements: []
|
467
|
-
rubygems_version: 3.
|
485
|
+
rubygems_version: 3.1.4
|
468
486
|
signing_key:
|
469
487
|
specification_version: 4
|
470
488
|
summary: A Webpack-aware, Ruby-based static site generator for the modern Jamstack
|