bridgetown-core 0.17.1 → 0.18.0
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/lib/bridgetown-core.rb +43 -28
- 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 +44 -31
- 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 +10 -9
- data/lib/bridgetown-core/concerns/site/renderable.rb +34 -26
- data/lib/bridgetown-core/concerns/site/writable.rb +7 -15
- data/lib/bridgetown-core/configuration.rb +5 -3
- data/lib/bridgetown-core/converter.rb +0 -42
- data/lib/bridgetown-core/converters/erb_templates.rb +75 -16
- data/lib/bridgetown-core/converters/liquid_templates.rb +96 -0
- data/lib/bridgetown-core/converters/markdown.rb +0 -3
- data/lib/bridgetown-core/document.rb +31 -18
- 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 +28 -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/plugin_manager.rb +34 -1
- data/lib/bridgetown-core/reader.rb +1 -4
- data/lib/bridgetown-core/readers/post_reader.rb +28 -15
- data/lib/bridgetown-core/renderer.rb +42 -160
- data/lib/bridgetown-core/ruby_template_view.rb +22 -33
- data/lib/bridgetown-core/site.rb +12 -2
- data/lib/bridgetown-core/utils.rb +14 -0
- 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 +7 -3
@@ -5,36 +5,7 @@ require "active_support/core_ext/hash/keys"
|
|
5
5
|
|
6
6
|
module Bridgetown
|
7
7
|
class RubyTemplateView
|
8
|
-
|
9
|
-
include Bridgetown::Filters
|
10
|
-
|
11
|
-
attr_reader :view, :site
|
12
|
-
|
13
|
-
Context = Struct.new(:registers)
|
14
|
-
|
15
|
-
def initialize(view, site)
|
16
|
-
@view = view
|
17
|
-
@site = site
|
18
|
-
|
19
|
-
# duck typing for Liquid context
|
20
|
-
@context = Context.new({ site: site })
|
21
|
-
end
|
22
|
-
|
23
|
-
def webpack_path(asset_type)
|
24
|
-
Bridgetown::Utils.parse_webpack_manifest_file(site, asset_type.to_s)
|
25
|
-
end
|
26
|
-
|
27
|
-
# @param pairs [Hash] A hash of key/value pairs.
|
28
|
-
#
|
29
|
-
# @return [String] Space-separated keys where the values are truthy.
|
30
|
-
def class_map(pairs = {})
|
31
|
-
pairs.select { |_key, truthy| truthy }.keys.join(" ")
|
32
|
-
end
|
33
|
-
|
34
|
-
def t(*args)
|
35
|
-
I18n.send :t, *args
|
36
|
-
end
|
37
|
-
end
|
8
|
+
require "bridgetown-core/helpers"
|
38
9
|
|
39
10
|
attr_reader :layout, :page, :paginator, :site, :content
|
40
11
|
|
@@ -44,6 +15,7 @@ module Bridgetown
|
|
44
15
|
@page = layout.current_document
|
45
16
|
@content = layout.current_document_output
|
46
17
|
else
|
18
|
+
@layout = convertible.site.layouts[convertible.data["layout"]]
|
47
19
|
@page = convertible
|
48
20
|
end
|
49
21
|
@paginator = page.paginator if page.respond_to?(:paginator)
|
@@ -54,11 +26,20 @@ module Bridgetown
|
|
54
26
|
raise "Must be implemented in a subclass"
|
55
27
|
end
|
56
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
|
+
|
57
37
|
def site_drop
|
58
38
|
site.site_payload.site
|
59
39
|
end
|
60
40
|
|
61
41
|
def liquid_render(component, options = {})
|
42
|
+
options[:_block_content] = yield if block_given?
|
62
43
|
render_statement = _render_statement(component, options)
|
63
44
|
|
64
45
|
template = site.liquid_renderer.file(
|
@@ -90,11 +71,19 @@ module Bridgetown
|
|
90
71
|
private
|
91
72
|
|
92
73
|
def _render_statement(component, options)
|
93
|
-
render_statement = [
|
74
|
+
render_statement = if options[:_block_content]
|
75
|
+
["{% rendercontent \"#{component}\""]
|
76
|
+
else
|
77
|
+
["{% render \"#{component}\""]
|
78
|
+
end
|
94
79
|
unless options.empty?
|
95
80
|
render_statement << ", " + options.keys.map { |k| "#{k}: #{k}" }.join(", ")
|
96
81
|
end
|
97
82
|
render_statement << " %}"
|
83
|
+
if options[:_block_content]
|
84
|
+
render_statement << options[:_block_content]
|
85
|
+
render_statement << "{% endrendercontent %}"
|
86
|
+
end
|
98
87
|
render_statement.join
|
99
88
|
end
|
100
89
|
|
@@ -102,8 +91,8 @@ module Bridgetown
|
|
102
91
|
{
|
103
92
|
registers: {
|
104
93
|
site: site,
|
105
|
-
page: page,
|
106
|
-
cached_partials: Bridgetown::
|
94
|
+
page: page.to_liquid,
|
95
|
+
cached_partials: Bridgetown::Converters::LiquidTemplates.cached_partials,
|
107
96
|
},
|
108
97
|
strict_filters: site.config["liquid"]["strict_filters"],
|
109
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
|
@@ -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.
|
@@ -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.0
|
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-10-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -312,6 +312,7 @@ executables:
|
|
312
312
|
extensions: []
|
313
313
|
extra_rdoc_files: []
|
314
314
|
files:
|
315
|
+
- ".yardopts"
|
315
316
|
- Rakefile
|
316
317
|
- bin/bridgetown
|
317
318
|
- bridgetown-core.gemspec
|
@@ -350,6 +351,7 @@ files:
|
|
350
351
|
- lib/bridgetown-core/converter.rb
|
351
352
|
- lib/bridgetown-core/converters/erb_templates.rb
|
352
353
|
- lib/bridgetown-core/converters/identity.rb
|
354
|
+
- lib/bridgetown-core/converters/liquid_templates.rb
|
353
355
|
- lib/bridgetown-core/converters/markdown.rb
|
354
356
|
- lib/bridgetown-core/converters/markdown/kramdown_parser.rb
|
355
357
|
- lib/bridgetown-core/converters/smartypants.rb
|
@@ -377,6 +379,7 @@ files:
|
|
377
379
|
- lib/bridgetown-core/frontmatter_defaults.rb
|
378
380
|
- lib/bridgetown-core/generator.rb
|
379
381
|
- lib/bridgetown-core/generators/prototype_generator.rb
|
382
|
+
- lib/bridgetown-core/helpers.rb
|
380
383
|
- lib/bridgetown-core/hooks.rb
|
381
384
|
- lib/bridgetown-core/layout.rb
|
382
385
|
- lib/bridgetown-core/liquid_extensions.rb
|
@@ -449,6 +452,7 @@ files:
|
|
449
452
|
- lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb
|
450
453
|
- lib/site_template/src/about.md
|
451
454
|
- lib/site_template/src/favicon.ico
|
455
|
+
- lib/site_template/src/images/.keep
|
452
456
|
- lib/site_template/src/index.md
|
453
457
|
- lib/site_template/src/posts.md
|
454
458
|
- lib/site_template/start.js
|
@@ -478,7 +482,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
478
482
|
- !ruby/object:Gem::Version
|
479
483
|
version: 2.7.0
|
480
484
|
requirements: []
|
481
|
-
rubygems_version: 3.
|
485
|
+
rubygems_version: 3.1.4
|
482
486
|
signing_key:
|
483
487
|
specification_version: 4
|
484
488
|
summary: A Webpack-aware, Ruby-based static site generator for the modern Jamstack
|