bunto 3.0.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +124 -76
- data/README.markdown +49 -12
- data/{bin → exe}/bunto +18 -14
- data/lib/bunto.rb +83 -78
- data/lib/bunto/cleaner.rb +10 -8
- data/lib/bunto/collection.rb +33 -17
- data/lib/bunto/command.rb +19 -13
- data/lib/bunto/commands/build.rb +22 -14
- data/lib/bunto/commands/clean.rb +9 -8
- data/lib/bunto/commands/doctor.rb +10 -8
- data/lib/bunto/commands/help.rb +4 -3
- data/lib/bunto/commands/new.rb +30 -21
- data/lib/bunto/commands/new_theme.rb +36 -0
- data/lib/bunto/commands/serve.rb +26 -20
- data/lib/bunto/commands/serve/servlet.rb +4 -5
- data/lib/bunto/configuration.rb +187 -125
- data/lib/bunto/converters/markdown.rb +19 -9
- data/lib/bunto/converters/markdown/kramdown_parser.rb +12 -5
- data/lib/bunto/converters/markdown/rdiscount_parser.rb +4 -4
- data/lib/bunto/converters/markdown/redcarpet_parser.rb +90 -84
- data/lib/bunto/convertible.rb +38 -25
- data/lib/bunto/deprecator.rb +11 -6
- data/lib/bunto/desktop.ini +2 -0
- data/lib/bunto/document.rb +53 -51
- data/lib/bunto/drops/bunto_drop.rb +12 -0
- data/lib/bunto/drops/document_drop.rb +40 -5
- data/lib/bunto/drops/drop.rb +49 -10
- data/lib/bunto/drops/excerpt_drop.rb +15 -0
- data/lib/bunto/drops/site_drop.rb +4 -2
- data/lib/bunto/drops/url_drop.rb +4 -4
- data/lib/bunto/entry_filter.rb +64 -19
- data/lib/bunto/errors.rb +6 -3
- data/lib/bunto/excerpt.rb +4 -6
- data/lib/bunto/external.rb +4 -4
- data/lib/bunto/filters.rb +72 -39
- data/lib/bunto/frontmatter_defaults.rb +45 -38
- data/lib/bunto/hooks.rb +21 -21
- data/lib/bunto/layout.rb +4 -8
- data/lib/bunto/liquid_renderer.rb +14 -3
- data/lib/bunto/liquid_renderer/file.rb +5 -1
- data/lib/bunto/liquid_renderer/table.rb +11 -11
- data/lib/bunto/log_adapter.rb +2 -2
- data/lib/bunto/page.rb +10 -10
- data/lib/bunto/plugin.rb +5 -5
- data/lib/bunto/plugin_manager.rb +12 -8
- data/lib/bunto/publisher.rb +1 -1
- data/lib/bunto/reader.rb +11 -7
- data/lib/bunto/readers/data_reader.rb +9 -9
- data/lib/bunto/readers/layout_reader.rb +7 -7
- data/lib/bunto/readers/page_reader.rb +3 -1
- data/lib/bunto/readers/post_reader.rb +9 -10
- data/lib/bunto/readers/static_file_reader.rb +3 -1
- data/lib/bunto/regenerator.rb +50 -28
- data/lib/bunto/related_posts.rb +1 -1
- data/lib/bunto/renderer.rb +33 -23
- data/lib/bunto/site.rb +94 -51
- data/lib/bunto/static_file.rb +33 -26
- data/lib/bunto/stevenson.rb +6 -5
- data/lib/bunto/tags/highlight.rb +50 -35
- data/lib/bunto/tags/include.rb +42 -31
- data/lib/bunto/tags/link.rb +11 -4
- data/lib/bunto/tags/post_url.rb +8 -7
- data/lib/bunto/theme.rb +10 -8
- data/lib/bunto/theme_builder.rb +117 -0
- data/lib/bunto/url.rb +21 -14
- data/lib/bunto/utils.rb +57 -28
- data/lib/bunto/utils/ansi.rb +9 -9
- data/lib/bunto/utils/platforms.rb +2 -2
- data/lib/bunto/version.rb +1 -1
- data/lib/site_template/_config.yml +3 -1
- data/lib/site_template/_posts/0000-00-00-welcome-to-bunto.markdown.erb +3 -3
- data/lib/site_template/about.md +3 -3
- data/lib/site_template/css/main.scss +3 -17
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
- data/lib/theme_template/Gemfile +2 -0
- data/lib/theme_template/LICENSE.txt.erb +21 -0
- data/lib/theme_template/README.md.erb +48 -0
- data/lib/theme_template/_layouts/default.html +1 -0
- data/lib/theme_template/_layouts/page.html +5 -0
- data/lib/theme_template/_layouts/post.html +5 -0
- data/lib/theme_template/example/_config.yml.erb +1 -0
- data/lib/theme_template/example/_post.md +12 -0
- data/lib/theme_template/example/index.html +14 -0
- data/lib/theme_template/example/style.scss +7 -0
- data/lib/theme_template/gitignore.erb +4 -0
- data/lib/theme_template/theme.gemspec.erb +18 -0
- metadata +40 -19
- data/lib/site_template/_includes/footer.html +0 -38
- data/lib/site_template/_includes/head.html +0 -12
- data/lib/site_template/_includes/header.html +0 -27
- data/lib/site_template/_includes/icon-github.html +0 -1
- data/lib/site_template/_includes/icon-github.svg +0 -1
- data/lib/site_template/_includes/icon-twitter.html +0 -1
- data/lib/site_template/_includes/icon-twitter.svg +0 -1
- data/lib/site_template/_layouts/default.html +0 -20
- data/lib/site_template/_layouts/page.html +0 -14
- data/lib/site_template/_layouts/post.html +0 -15
- data/lib/site_template/_sass/_base.scss +0 -200
- data/lib/site_template/_sass/_layout.scss +0 -242
- data/lib/site_template/_sass/_syntax-highlighting.scss +0 -71
data/lib/bunto/plugin.rb
CHANGED
data/lib/bunto/plugin_manager.rb
CHANGED
@@ -24,7 +24,9 @@ module Bunto
|
|
24
24
|
#
|
25
25
|
# Returns nothing.
|
26
26
|
def require_gems
|
27
|
-
Bunto::External.require_with_graceful_fail(
|
27
|
+
Bunto::External.require_with_graceful_fail(
|
28
|
+
site.gems.select { |gem| plugin_allowed?(gem) }
|
29
|
+
)
|
28
30
|
end
|
29
31
|
|
30
32
|
def self.require_from_bundler
|
@@ -33,7 +35,8 @@ module Bunto
|
|
33
35
|
|
34
36
|
Bundler.setup
|
35
37
|
required_gems = Bundler.require(:bunto_plugins)
|
36
|
-
|
38
|
+
message = "Required #{required_gems.map(&:name).join(", ")}"
|
39
|
+
Bunto.logger.debug("PluginManager:", message)
|
37
40
|
ENV["BUNTO_NO_BUNDLER_REQUIRE"] = "true"
|
38
41
|
|
39
42
|
true
|
@@ -57,7 +60,7 @@ module Bunto
|
|
57
60
|
# Returns an array of strings, each string being the name of a gem name
|
58
61
|
# that is allowed to be used.
|
59
62
|
def whitelist
|
60
|
-
@whitelist ||= Array[site.config[
|
63
|
+
@whitelist ||= Array[site.config["whitelist"]].flatten
|
61
64
|
end
|
62
65
|
|
63
66
|
# Require all .rb files if safe mode is off
|
@@ -76,16 +79,17 @@ module Bunto
|
|
76
79
|
#
|
77
80
|
# Returns an Array of plugin search paths
|
78
81
|
def plugins_path
|
79
|
-
if site.config[
|
80
|
-
[site.in_source_dir(site.config[
|
82
|
+
if site.config["plugins_dir"].eql? Bunto::Configuration::DEFAULTS["plugins_dir"]
|
83
|
+
[site.in_source_dir(site.config["plugins_dir"])]
|
81
84
|
else
|
82
|
-
Array(site.config[
|
85
|
+
Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) }
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
86
89
|
def deprecation_checks
|
87
|
-
pagination_included = (site.config[
|
88
|
-
|
90
|
+
pagination_included = (site.config["gems"] || []).include?("bunto-paginate") ||
|
91
|
+
defined?(Bunto::Paginate)
|
92
|
+
if site.config["paginate"] && !pagination_included
|
89
93
|
Bunto::Deprecator.deprecation_message "You appear to have pagination " \
|
90
94
|
"turned on, but you haven't included the `bunto-paginate` gem. " \
|
91
95
|
"Ensure you have `gems: [bunto-paginate]` in your configuration file."
|
data/lib/bunto/publisher.rb
CHANGED
data/lib/bunto/reader.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "csv"
|
3
3
|
|
4
4
|
module Bunto
|
5
5
|
class Reader
|
@@ -16,7 +16,7 @@ module Bunto
|
|
16
16
|
@site.layouts = LayoutReader.new(site).read
|
17
17
|
read_directories
|
18
18
|
sort_files!
|
19
|
-
@site.data = DataReader.new(site).read(site.config[
|
19
|
+
@site.data = DataReader.new(site).read(site.config["data_dir"])
|
20
20
|
CollectionReader.new(site).read
|
21
21
|
end
|
22
22
|
|
@@ -34,13 +34,15 @@ module Bunto
|
|
34
34
|
# dir - The String relative path of the directory to read. Default: ''.
|
35
35
|
#
|
36
36
|
# Returns nothing.
|
37
|
-
def read_directories(dir =
|
37
|
+
def read_directories(dir = "")
|
38
38
|
base = site.in_source_dir(dir)
|
39
39
|
|
40
|
-
dot = Dir.chdir(base) { filter_entries(Dir.entries(
|
40
|
+
dot = Dir.chdir(base) { filter_entries(Dir.entries("."), base) }
|
41
41
|
dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) }
|
42
42
|
dot_files = (dot - dot_dirs)
|
43
|
-
dot_pages = dot_files.select
|
43
|
+
dot_pages = dot_files.select do |file|
|
44
|
+
Utils.has_yaml_header?(@site.in_source_dir(base, file))
|
45
|
+
end
|
44
46
|
dot_static_files = dot_files - dot_pages
|
45
47
|
|
46
48
|
retrieve_posts(dir)
|
@@ -71,7 +73,9 @@ module Bunto
|
|
71
73
|
dot_dirs.map do |file|
|
72
74
|
dir_path = site.in_source_dir(dir, file)
|
73
75
|
rel_path = File.join(dir, file)
|
74
|
-
|
76
|
+
unless @site.dest.sub(%r!/$!, "") == dir_path
|
77
|
+
@site.reader.read_directories(rel_path)
|
78
|
+
end
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
@@ -119,7 +123,7 @@ module Bunto
|
|
119
123
|
def get_entries(dir, subfolder)
|
120
124
|
base = site.in_source_dir(dir, subfolder)
|
121
125
|
return [] unless File.exist?(base)
|
122
|
-
entries = Dir.chdir(base) { filter_entries(Dir[
|
126
|
+
entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
|
123
127
|
entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
|
124
128
|
end
|
125
129
|
end
|
@@ -30,14 +30,14 @@ module Bunto
|
|
30
30
|
return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
|
31
31
|
|
32
32
|
entries = Dir.chdir(dir) do
|
33
|
-
Dir[
|
33
|
+
Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
|
34
34
|
end
|
35
35
|
|
36
36
|
entries.each do |entry|
|
37
37
|
path = @site.in_source_dir(dir, entry)
|
38
38
|
next if @entry_filter.symlink?(path)
|
39
39
|
|
40
|
-
key = sanitize_filename(File.basename(entry,
|
40
|
+
key = sanitize_filename(File.basename(entry, ".*"))
|
41
41
|
if File.directory?(path)
|
42
42
|
read_data_to(path, data[key] = {})
|
43
43
|
else
|
@@ -51,20 +51,20 @@ module Bunto
|
|
51
51
|
# Returns the contents of the data file.
|
52
52
|
def read_data_file(path)
|
53
53
|
case File.extname(path).downcase
|
54
|
-
when
|
54
|
+
when ".csv"
|
55
55
|
CSV.read(path, {
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
:headers => true,
|
57
|
+
:encoding => site.config["encoding"]
|
58
|
+
}).map(&:to_hash)
|
59
59
|
else
|
60
60
|
SafeYAML.load_file(path)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
def sanitize_filename(name)
|
65
|
-
name.gsub!(
|
66
|
-
name.gsub!(
|
67
|
-
name.gsub(
|
65
|
+
name.gsub!(%r![^\w\s-]+!, "")
|
66
|
+
name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2')
|
67
|
+
name.gsub(%r!\s+!, "_")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -8,11 +8,13 @@ module Bunto
|
|
8
8
|
|
9
9
|
def read
|
10
10
|
layout_entries.each do |layout_file|
|
11
|
-
@layouts[layout_name(layout_file)] =
|
11
|
+
@layouts[layout_name(layout_file)] = \
|
12
|
+
Layout.new(site, layout_directory, layout_file)
|
12
13
|
end
|
13
14
|
|
14
15
|
theme_layout_entries.each do |layout_file|
|
15
|
-
@layouts[layout_name(layout_file)] ||=
|
16
|
+
@layouts[layout_name(layout_file)] ||= \
|
17
|
+
Layout.new(site, theme_layout_directory, layout_file)
|
16
18
|
end
|
17
19
|
|
18
20
|
@layouts
|
@@ -39,7 +41,7 @@ module Bunto
|
|
39
41
|
def entries_in(dir)
|
40
42
|
entries = []
|
41
43
|
within(dir) do
|
42
|
-
entries = EntryFilter.new(site).filter(Dir[
|
44
|
+
entries = EntryFilter.new(site).filter(Dir["**/*.*"])
|
43
45
|
end
|
44
46
|
entries
|
45
47
|
end
|
@@ -54,15 +56,13 @@ module Bunto
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def layout_directory_inside_source
|
57
|
-
site.in_source_dir(site.config[
|
59
|
+
site.in_source_dir(site.config["layouts_dir"])
|
58
60
|
end
|
59
61
|
|
60
62
|
def layout_directory_in_cwd
|
61
|
-
dir = Bunto.sanitized_path(Dir.pwd, site.config[
|
63
|
+
dir = Bunto.sanitized_path(Dir.pwd, site.config["layouts_dir"])
|
62
64
|
if File.directory?(dir) && !site.safe
|
63
65
|
dir
|
64
|
-
else
|
65
|
-
nil
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -14,7 +14,9 @@ module Bunto
|
|
14
14
|
#
|
15
15
|
# Returns an array of static pages.
|
16
16
|
def read(files)
|
17
|
-
files.map
|
17
|
+
files.map do |page|
|
18
|
+
@unfiltered_content << Page.new(@site, @site.source, @dir, page)
|
19
|
+
end
|
18
20
|
@unfiltered_content.select { |page| site.publisher.publish?(page) }
|
19
21
|
end
|
20
22
|
end
|
@@ -12,7 +12,7 @@ module Bunto
|
|
12
12
|
#
|
13
13
|
# Returns nothing.
|
14
14
|
def read_drafts(dir)
|
15
|
-
read_publishable(dir,
|
15
|
+
read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Read all the files in <source>/<dir>/_posts and create a new Document
|
@@ -22,7 +22,7 @@ module Bunto
|
|
22
22
|
#
|
23
23
|
# Returns nothing.
|
24
24
|
def read_posts(dir)
|
25
|
-
read_publishable(dir,
|
25
|
+
read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Read all the files in <source>/<dir>/<magic_dir> and create a new
|
@@ -32,15 +32,14 @@ module Bunto
|
|
32
32
|
#
|
33
33
|
# Returns nothing.
|
34
34
|
def read_publishable(dir, magic_dir, matcher)
|
35
|
-
read_content(dir, magic_dir, matcher).tap
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
read_content(dir, magic_dir, matcher).tap { |docs| docs.each(&:read) }
|
36
|
+
.select do |doc|
|
37
|
+
site.publisher.publish?(doc).tap do |will_publish|
|
38
|
+
if !will_publish && site.publisher.hidden_in_the_future?(doc)
|
39
|
+
Bunto.logger.debug "Skipping:", "#{doc.relative_path} has a future date"
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
|
-
end
|
44
43
|
end
|
45
44
|
|
46
45
|
# Read all the content files from <source>/<dir>/magic_dir
|
@@ -57,7 +56,7 @@ module Bunto
|
|
57
56
|
next unless entry =~ matcher
|
58
57
|
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
|
59
58
|
Document.new(path, {
|
60
|
-
:site
|
59
|
+
:site => @site,
|
61
60
|
:collection => @site.posts
|
62
61
|
})
|
63
62
|
end.reject(&:nil?)
|
@@ -14,7 +14,9 @@ module Bunto
|
|
14
14
|
#
|
15
15
|
# Returns an array of static files.
|
16
16
|
def read(files)
|
17
|
-
files.map
|
17
|
+
files.map do |file|
|
18
|
+
@unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)
|
19
|
+
end
|
18
20
|
@unfiltered_content
|
19
21
|
end
|
20
22
|
end
|
data/lib/bunto/regenerator.rb
CHANGED
@@ -20,18 +20,14 @@ module Bunto
|
|
20
20
|
def regenerate?(document)
|
21
21
|
case document
|
22
22
|
when Page
|
23
|
-
|
24
|
-
source_modified_or_dest_missing?(
|
25
|
-
site.in_source_dir(document.relative_path), document.destination(@site.dest)
|
26
|
-
)
|
23
|
+
regenerate_page?(document)
|
27
24
|
when Document
|
28
|
-
|
29
|
-
source_modified_or_dest_missing?(
|
30
|
-
document.path, document.destination(@site.dest)
|
31
|
-
)
|
25
|
+
regenerate_document?(document)
|
32
26
|
else
|
33
|
-
source_path = document.respond_to?(:path)
|
34
|
-
dest_path
|
27
|
+
source_path = document.respond_to?(:path) ? document.path : nil
|
28
|
+
dest_path = if document.respond_to?(:destination)
|
29
|
+
document.destination(@site.dest)
|
30
|
+
end
|
35
31
|
source_modified_or_dest_missing?(source_path, dest_path)
|
36
32
|
end
|
37
33
|
end
|
@@ -44,7 +40,7 @@ module Bunto
|
|
44
40
|
|
45
41
|
metadata[path] = {
|
46
42
|
"mtime" => File.mtime(path),
|
47
|
-
"deps"
|
43
|
+
"deps" => []
|
48
44
|
}
|
49
45
|
cache[path] = true
|
50
46
|
end
|
@@ -94,23 +90,14 @@ module Bunto
|
|
94
90
|
return cache[path]
|
95
91
|
end
|
96
92
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
105
|
-
if File.exist?(path) && data["mtime"].eql?(File.mtime(path))
|
106
|
-
return cache[path] = false
|
107
|
-
else
|
108
|
-
return add(path)
|
109
|
-
end
|
93
|
+
if metadata[path]
|
94
|
+
# If we have seen this file before,
|
95
|
+
# check if it or one of its dependencies has been modified
|
96
|
+
existing_file_modified?(path)
|
97
|
+
else
|
98
|
+
# If we have not seen this file before, add it to the metadata and regenerate it
|
99
|
+
add(path)
|
110
100
|
end
|
111
|
-
|
112
|
-
# Path does not exist in metadata, add it
|
113
|
-
return add(path)
|
114
101
|
end
|
115
102
|
|
116
103
|
# Add a dependency of a path
|
@@ -139,7 +126,7 @@ module Bunto
|
|
139
126
|
#
|
140
127
|
# Returns the String path of the file.
|
141
128
|
def metadata_file
|
142
|
-
site.in_source_dir(
|
129
|
+
site.in_source_dir(".bunto-metadata")
|
143
130
|
end
|
144
131
|
|
145
132
|
# Check if metadata has been disabled
|
@@ -173,5 +160,40 @@ module Bunto
|
|
173
160
|
{}
|
174
161
|
end
|
175
162
|
end
|
163
|
+
|
164
|
+
private
|
165
|
+
def regenerate_page?(document)
|
166
|
+
document.asset_file? || document.data["regenerate"] ||
|
167
|
+
source_modified_or_dest_missing?(
|
168
|
+
site.in_source_dir(document.relative_path), document.destination(@site.dest)
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
def regenerate_document?(document)
|
174
|
+
!document.write? || document.data["regenerate"] ||
|
175
|
+
source_modified_or_dest_missing?(
|
176
|
+
document.path, document.destination(@site.dest)
|
177
|
+
)
|
178
|
+
end
|
179
|
+
|
180
|
+
private
|
181
|
+
def existing_file_modified?(path)
|
182
|
+
# If one of this file dependencies have been modified,
|
183
|
+
# set the regeneration bit for both the dependency and the file to true
|
184
|
+
metadata[path]["deps"].each do |dependency|
|
185
|
+
if modified?(dependency)
|
186
|
+
return cache[dependency] = cache[path] = true
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
|
191
|
+
# If this file has not been modified, set the regeneration bit to false
|
192
|
+
cache[path] = false
|
193
|
+
else
|
194
|
+
# If it has been modified, set it to true
|
195
|
+
add(path)
|
196
|
+
end
|
197
|
+
end
|
176
198
|
end
|
177
199
|
end
|
data/lib/bunto/related_posts.rb
CHANGED
data/lib/bunto/renderer.rb
CHANGED
@@ -38,21 +38,21 @@ module Bunto
|
|
38
38
|
payload["paginator"] = document.pager.to_liquid
|
39
39
|
end
|
40
40
|
|
41
|
-
if document.is_a?(Document) && document.collection.label ==
|
42
|
-
payload[
|
41
|
+
if document.is_a?(Document) && document.collection.label == "posts"
|
42
|
+
payload["site"]["related_posts"] = document.related_posts
|
43
43
|
else
|
44
|
-
payload[
|
44
|
+
payload["site"]["related_posts"] = nil
|
45
45
|
end
|
46
46
|
|
47
47
|
# render and transform content (this becomes the final content of the object)
|
48
|
-
payload[
|
49
|
-
payload[
|
48
|
+
payload["highlighter_prefix"] = converters.first.highlighter_prefix
|
49
|
+
payload["highlighter_suffix"] = converters.first.highlighter_suffix
|
50
50
|
|
51
51
|
Bunto.logger.debug "Pre-Render Hooks:", document.relative_path
|
52
52
|
document.trigger_hooks(:pre_render, payload)
|
53
53
|
|
54
54
|
info = {
|
55
|
-
:registers => { :site => site, :page => payload[
|
55
|
+
:registers => { :site => site, :page => payload["page"] }
|
56
56
|
}
|
57
57
|
|
58
58
|
output = document.content
|
@@ -88,7 +88,9 @@ module Bunto
|
|
88
88
|
begin
|
89
89
|
converter.convert output
|
90
90
|
rescue => e
|
91
|
-
Bunto.logger.error "Conversion error:",
|
91
|
+
Bunto.logger.error "Conversion error:",
|
92
|
+
"#{converter.class} encountered an error while "\
|
93
|
+
"converting '#{document.relative_path}':"
|
92
94
|
Bunto.logger.error("", e.to_s)
|
93
95
|
raise e
|
94
96
|
end
|
@@ -104,14 +106,19 @@ module Bunto
|
|
104
106
|
#
|
105
107
|
# Returns the content, rendered by Liquid.
|
106
108
|
def render_liquid(content, payload, info, path = nil)
|
107
|
-
site.liquid_renderer.file(path).parse(content)
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
template = site.liquid_renderer.file(path).parse(content)
|
110
|
+
template.warnings.each do |e|
|
111
|
+
Bunto.logger.warn "Liquid Warning:",
|
112
|
+
LiquidRenderer.format_error(e, path || document.relative_path)
|
113
|
+
end
|
114
|
+
template.render!(payload, info)
|
115
|
+
# rubocop: disable RescueException
|
111
116
|
rescue Exception => e
|
112
|
-
Bunto.logger.error "Liquid Exception:",
|
117
|
+
Bunto.logger.error "Liquid Exception:",
|
118
|
+
LiquidRenderer.format_error(e, path || document.relative_path)
|
113
119
|
raise e
|
114
120
|
end
|
121
|
+
# rubocop: enable RescueException
|
115
122
|
|
116
123
|
# Checks if the layout specified in the document actually exists
|
117
124
|
#
|
@@ -132,14 +139,20 @@ module Bunto
|
|
132
139
|
output = content.dup
|
133
140
|
layout = site.layouts[document.data["layout"]]
|
134
141
|
|
135
|
-
Bunto.logger.warn(
|
142
|
+
Bunto.logger.warn(
|
143
|
+
"Build Warning:",
|
144
|
+
"Layout '#{document.data["layout"]}' requested in "\
|
145
|
+
"#{document.relative_path} does not exist."
|
146
|
+
) if invalid_layout? layout
|
147
|
+
|
148
|
+
used = Set.new([layout])
|
136
149
|
|
137
|
-
|
150
|
+
# Reset the payload layout data to ensure it starts fresh for each page.
|
151
|
+
payload["layout"] = nil
|
138
152
|
|
139
153
|
while layout
|
140
|
-
payload[
|
141
|
-
payload[
|
142
|
-
payload['layout'] = Utils.deep_merge_hashes(payload['layout'] || {}, layout.data)
|
154
|
+
payload["content"] = output
|
155
|
+
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
|
143
156
|
|
144
157
|
output = render_liquid(
|
145
158
|
layout.content,
|
@@ -154,12 +167,9 @@ module Bunto
|
|
154
167
|
site.in_source_dir(layout.path)
|
155
168
|
) if document.write?
|
156
169
|
|
157
|
-
if layout = site.layouts[layout.data["layout"]]
|
158
|
-
if used.include?(layout)
|
159
|
-
|
160
|
-
else
|
161
|
-
used << layout
|
162
|
-
end
|
170
|
+
if (layout = site.layouts[layout.data["layout"]])
|
171
|
+
break if used.include?(layout)
|
172
|
+
used << layout
|
163
173
|
end
|
164
174
|
end
|
165
175
|
|