bridgetown-core 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +42 -0
- data/bridgetown-core.gemspec +46 -0
- data/lib/bridgetown-core.rb +202 -0
- data/lib/bridgetown-core/cache.rb +190 -0
- data/lib/bridgetown-core/cleaner.rb +111 -0
- data/lib/bridgetown-core/collection.rb +279 -0
- data/lib/bridgetown-core/command.rb +106 -0
- data/lib/bridgetown-core/commands/build.rb +96 -0
- data/lib/bridgetown-core/commands/clean.rb +43 -0
- data/lib/bridgetown-core/commands/console.rb +56 -0
- data/lib/bridgetown-core/commands/doctor.rb +172 -0
- data/lib/bridgetown-core/commands/help.rb +34 -0
- data/lib/bridgetown-core/commands/new.rb +148 -0
- data/lib/bridgetown-core/commands/serve.rb +273 -0
- data/lib/bridgetown-core/commands/serve/servlet.rb +68 -0
- data/lib/bridgetown-core/configuration.rb +323 -0
- data/lib/bridgetown-core/converter.rb +54 -0
- data/lib/bridgetown-core/converters/identity.rb +39 -0
- data/lib/bridgetown-core/converters/markdown.rb +108 -0
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +132 -0
- data/lib/bridgetown-core/converters/smartypants.rb +69 -0
- data/lib/bridgetown-core/convertible.rb +237 -0
- data/lib/bridgetown-core/deprecator.rb +50 -0
- data/lib/bridgetown-core/document.rb +475 -0
- data/lib/bridgetown-core/drops/bridgetown_drop.rb +32 -0
- data/lib/bridgetown-core/drops/collection_drop.rb +20 -0
- data/lib/bridgetown-core/drops/document_drop.rb +69 -0
- data/lib/bridgetown-core/drops/drop.rb +215 -0
- data/lib/bridgetown-core/drops/excerpt_drop.rb +19 -0
- data/lib/bridgetown-core/drops/page_drop.rb +14 -0
- data/lib/bridgetown-core/drops/site_drop.rb +62 -0
- data/lib/bridgetown-core/drops/static_file_drop.rb +14 -0
- data/lib/bridgetown-core/drops/unified_payload_drop.rb +26 -0
- data/lib/bridgetown-core/drops/url_drop.rb +132 -0
- data/lib/bridgetown-core/entry_filter.rb +108 -0
- data/lib/bridgetown-core/errors.rb +20 -0
- data/lib/bridgetown-core/excerpt.rb +202 -0
- data/lib/bridgetown-core/external.rb +62 -0
- data/lib/bridgetown-core/filters.rb +467 -0
- data/lib/bridgetown-core/filters/date_filters.rb +110 -0
- data/lib/bridgetown-core/filters/grouping_filters.rb +64 -0
- data/lib/bridgetown-core/filters/url_filters.rb +79 -0
- data/lib/bridgetown-core/frontmatter_defaults.rb +238 -0
- data/lib/bridgetown-core/generator.rb +5 -0
- data/lib/bridgetown-core/hooks.rb +103 -0
- data/lib/bridgetown-core/layout.rb +57 -0
- data/lib/bridgetown-core/liquid_extensions.rb +22 -0
- data/lib/bridgetown-core/liquid_renderer.rb +71 -0
- data/lib/bridgetown-core/liquid_renderer/file.rb +67 -0
- data/lib/bridgetown-core/liquid_renderer/table.rb +75 -0
- data/lib/bridgetown-core/log_adapter.rb +151 -0
- data/lib/bridgetown-core/log_writer.rb +60 -0
- data/lib/bridgetown-core/mime.types +867 -0
- data/lib/bridgetown-core/page.rb +214 -0
- data/lib/bridgetown-core/page_without_a_file.rb +14 -0
- data/lib/bridgetown-core/path_manager.rb +31 -0
- data/lib/bridgetown-core/plugin.rb +80 -0
- data/lib/bridgetown-core/plugin_manager.rb +60 -0
- data/lib/bridgetown-core/publisher.rb +23 -0
- data/lib/bridgetown-core/reader.rb +185 -0
- data/lib/bridgetown-core/readers/collection_reader.rb +22 -0
- data/lib/bridgetown-core/readers/data_reader.rb +75 -0
- data/lib/bridgetown-core/readers/layout_reader.rb +48 -0
- data/lib/bridgetown-core/readers/page_reader.rb +24 -0
- data/lib/bridgetown-core/readers/post_reader.rb +74 -0
- data/lib/bridgetown-core/readers/static_file_reader.rb +24 -0
- data/lib/bridgetown-core/regenerator.rb +195 -0
- data/lib/bridgetown-core/related_posts.rb +52 -0
- data/lib/bridgetown-core/renderer.rb +261 -0
- data/lib/bridgetown-core/site.rb +469 -0
- data/lib/bridgetown-core/static_file.rb +205 -0
- data/lib/bridgetown-core/tags/component.rb +34 -0
- data/lib/bridgetown-core/tags/highlight.rb +111 -0
- data/lib/bridgetown-core/tags/include.rb +220 -0
- data/lib/bridgetown-core/tags/link.rb +41 -0
- data/lib/bridgetown-core/tags/post_url.rb +107 -0
- data/lib/bridgetown-core/url.rb +164 -0
- data/lib/bridgetown-core/utils.rb +367 -0
- data/lib/bridgetown-core/utils/ansi.rb +57 -0
- data/lib/bridgetown-core/utils/exec.rb +26 -0
- data/lib/bridgetown-core/utils/internet.rb +37 -0
- data/lib/bridgetown-core/utils/platforms.rb +80 -0
- data/lib/bridgetown-core/utils/thread_event.rb +31 -0
- data/lib/bridgetown-core/utils/win_tz.rb +75 -0
- data/lib/bridgetown-core/version.rb +5 -0
- data/lib/bridgetown-core/watcher.rb +139 -0
- data/lib/site_template/.gitignore +6 -0
- data/lib/site_template/bridgetown.config.yml +21 -0
- data/lib/site_template/frontend/javascript/index.js +3 -0
- data/lib/site_template/frontend/styles/index.scss +17 -0
- data/lib/site_template/package.json +23 -0
- data/lib/site_template/src/404.html +9 -0
- data/lib/site_template/src/_data/site_metadata.yml +11 -0
- data/lib/site_template/src/_includes/footer.html +3 -0
- data/lib/site_template/src/_includes/head.html +9 -0
- data/lib/site_template/src/_includes/navbar.html +4 -0
- data/lib/site_template/src/_layouts/default.html +15 -0
- data/lib/site_template/src/_layouts/home.html +7 -0
- data/lib/site_template/src/_layouts/page.html +7 -0
- data/lib/site_template/src/_layouts/post.html +7 -0
- data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +26 -0
- data/lib/site_template/src/about.md +11 -0
- data/lib/site_template/src/index.md +7 -0
- data/lib/site_template/webpack.config.js +60 -0
- data/rake/release.rake +30 -0
- metadata +106 -1
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class CollectionReader
|
5
|
+
SPECIAL_COLLECTIONS = %w(posts data).freeze
|
6
|
+
|
7
|
+
attr_reader :site, :content
|
8
|
+
def initialize(site)
|
9
|
+
@site = site
|
10
|
+
@content = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
# Read in all collections specified in the configuration
|
14
|
+
#
|
15
|
+
# Returns nothing.
|
16
|
+
def read
|
17
|
+
site.collections.each_value do |collection|
|
18
|
+
collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class DataReader
|
5
|
+
attr_reader :site, :content
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
@content = {}
|
9
|
+
@entry_filter = EntryFilter.new(site)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Read all the files in <dir> and adds them to @content
|
13
|
+
#
|
14
|
+
# dir - The String relative path of the directory to read.
|
15
|
+
#
|
16
|
+
# Returns @content, a Hash of the .yaml, .yml,
|
17
|
+
# .json, and .csv files in the base directory
|
18
|
+
def read(dir)
|
19
|
+
base = site.in_source_dir(dir)
|
20
|
+
read_data_to(base, @content)
|
21
|
+
@content
|
22
|
+
end
|
23
|
+
|
24
|
+
# Read and parse all .yaml, .yml, .json, .csv and .tsv
|
25
|
+
# files under <dir> and add them to the <data> variable.
|
26
|
+
#
|
27
|
+
# dir - The string absolute path of the directory to read.
|
28
|
+
# data - The variable to which data will be added.
|
29
|
+
#
|
30
|
+
# Returns nothing
|
31
|
+
def read_data_to(dir, data)
|
32
|
+
return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
|
33
|
+
|
34
|
+
entries = Dir.chdir(dir) do
|
35
|
+
Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) }
|
36
|
+
end
|
37
|
+
|
38
|
+
entries.each do |entry|
|
39
|
+
path = @site.in_source_dir(dir, entry)
|
40
|
+
next if @entry_filter.symlink?(path)
|
41
|
+
|
42
|
+
if File.directory?(path)
|
43
|
+
read_data_to(path, data[sanitize_filename(entry)] = {})
|
44
|
+
else
|
45
|
+
key = sanitize_filename(File.basename(entry, ".*"))
|
46
|
+
data[key] = read_data_file(path)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Determines how to read a data file.
|
52
|
+
#
|
53
|
+
# Returns the contents of the data file.
|
54
|
+
def read_data_file(path)
|
55
|
+
case File.extname(path).downcase
|
56
|
+
when ".csv"
|
57
|
+
CSV.read(path,
|
58
|
+
:headers => true,
|
59
|
+
:encoding => site.config["encoding"]).map(&:to_hash)
|
60
|
+
when ".tsv"
|
61
|
+
CSV.read(path,
|
62
|
+
:col_sep => "\t",
|
63
|
+
:headers => true,
|
64
|
+
:encoding => site.config["encoding"]).map(&:to_hash)
|
65
|
+
else
|
66
|
+
SafeYAML.load_file(path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def sanitize_filename(name)
|
71
|
+
name.gsub(%r![^\w\s-]+|(?<=^|\b\s)\s+(?=$|\s?\b)!, "")
|
72
|
+
.gsub(%r!\s+!, "_")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class LayoutReader
|
5
|
+
attr_reader :site
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
@layouts = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def read
|
12
|
+
layout_entries.each do |layout_file|
|
13
|
+
@layouts[layout_name(layout_file)] = \
|
14
|
+
Layout.new(site, layout_directory, layout_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
@layouts
|
18
|
+
end
|
19
|
+
|
20
|
+
def layout_directory
|
21
|
+
@layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def layout_entries
|
27
|
+
entries_in layout_directory
|
28
|
+
end
|
29
|
+
|
30
|
+
def entries_in(dir)
|
31
|
+
entries = []
|
32
|
+
within(dir) do
|
33
|
+
entries = EntryFilter.new(site).filter(Dir["**/*.*"])
|
34
|
+
end
|
35
|
+
entries
|
36
|
+
end
|
37
|
+
|
38
|
+
def layout_name(file)
|
39
|
+
file.split(".")[0..-2].join(".")
|
40
|
+
end
|
41
|
+
|
42
|
+
def within(directory)
|
43
|
+
return unless File.exist?(directory)
|
44
|
+
|
45
|
+
Dir.chdir(directory) { yield }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class PageReader
|
5
|
+
attr_reader :site, :dir, :unfiltered_content
|
6
|
+
def initialize(site, dir)
|
7
|
+
@site = site
|
8
|
+
@dir = dir
|
9
|
+
@unfiltered_content = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Create a new `Bridgetown::Page` object for each entry in a given array.
|
13
|
+
#
|
14
|
+
# files - An array of file names inside `@dir`
|
15
|
+
#
|
16
|
+
# Returns an array of publishable `Bridgetown::Page` objects.
|
17
|
+
def read(files)
|
18
|
+
files.each do |page|
|
19
|
+
@unfiltered_content << Page.new(@site, @site.source, @dir, page)
|
20
|
+
end
|
21
|
+
@unfiltered_content.select { |page| site.publisher.publish?(page) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class PostReader
|
5
|
+
attr_reader :site, :unfiltered_content
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
end
|
9
|
+
|
10
|
+
# Read all the files in <source>/<dir>/_posts and create a new Document
|
11
|
+
# object with each one.
|
12
|
+
#
|
13
|
+
# dir - The String relative path of the directory to read.
|
14
|
+
#
|
15
|
+
# Returns nothing.
|
16
|
+
def read_posts(dir)
|
17
|
+
read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Read all the files in <source>/<dir>/<magic_dir> and create a new
|
21
|
+
# Document object with each one insofar as it matches the regexp matcher.
|
22
|
+
#
|
23
|
+
# dir - The String relative path of the directory to read.
|
24
|
+
#
|
25
|
+
# Returns nothing.
|
26
|
+
def read_publishable(dir, magic_dir, matcher)
|
27
|
+
read_content(dir, magic_dir, matcher)
|
28
|
+
.tap { |docs| docs.each(&:read) }
|
29
|
+
.select { |doc| processable?(doc) }
|
30
|
+
end
|
31
|
+
|
32
|
+
# Read all the content files from <source>/<dir>/magic_dir
|
33
|
+
# and return them with the type klass.
|
34
|
+
#
|
35
|
+
# dir - The String relative path of the directory to read.
|
36
|
+
# magic_dir - The String relative directory to <dir>,
|
37
|
+
# looks for content here.
|
38
|
+
# klass - The return type of the content.
|
39
|
+
#
|
40
|
+
# Returns klass type of content files
|
41
|
+
def read_content(dir, magic_dir, matcher)
|
42
|
+
@site.reader.get_entries(dir, magic_dir).map do |entry|
|
43
|
+
next unless matcher.match?(entry)
|
44
|
+
|
45
|
+
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
|
46
|
+
Document.new(path,
|
47
|
+
:site => @site,
|
48
|
+
:collection => @site.posts)
|
49
|
+
end.reject(&:nil?)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def processable?(doc)
|
55
|
+
if doc.content.nil?
|
56
|
+
Bridgetown.logger.debug "Skipping:", "Content in #{doc.relative_path} is nil"
|
57
|
+
false
|
58
|
+
elsif !doc.content.valid_encoding?
|
59
|
+
Bridgetown.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
|
60
|
+
false
|
61
|
+
else
|
62
|
+
publishable?(doc)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def publishable?(doc)
|
67
|
+
site.publisher.publish?(doc).tap do |will_publish|
|
68
|
+
if !will_publish && site.publisher.hidden_in_the_future?(doc)
|
69
|
+
Bridgetown.logger.warn "Skipping:", "#{doc.relative_path} has a future date"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class StaticFileReader
|
5
|
+
attr_reader :site, :dir, :unfiltered_content
|
6
|
+
def initialize(site, dir)
|
7
|
+
@site = site
|
8
|
+
@dir = dir
|
9
|
+
@unfiltered_content = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Create a new StaticFile object for every entry in a given list of basenames.
|
13
|
+
#
|
14
|
+
# files - an array of file basenames.
|
15
|
+
#
|
16
|
+
# Returns an array of static files.
|
17
|
+
def read(files)
|
18
|
+
files.each do |file|
|
19
|
+
@unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)
|
20
|
+
end
|
21
|
+
@unfiltered_content
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class Regenerator
|
5
|
+
attr_reader :site, :metadata, :cache
|
6
|
+
attr_accessor :disabled
|
7
|
+
private :disabled, :disabled=
|
8
|
+
|
9
|
+
def initialize(site)
|
10
|
+
@site = site
|
11
|
+
|
12
|
+
# Read metadata from file
|
13
|
+
read_metadata
|
14
|
+
|
15
|
+
# Initialize cache to an empty hash
|
16
|
+
clear_cache
|
17
|
+
end
|
18
|
+
|
19
|
+
# Checks if a renderable object needs to be regenerated
|
20
|
+
#
|
21
|
+
# Returns a boolean.
|
22
|
+
def regenerate?(document)
|
23
|
+
return true if disabled
|
24
|
+
|
25
|
+
case document
|
26
|
+
when Page
|
27
|
+
regenerate_page?(document)
|
28
|
+
when Document
|
29
|
+
regenerate_document?(document)
|
30
|
+
else
|
31
|
+
source_path = document.respond_to?(:path) ? document.path : nil
|
32
|
+
dest_path = document.destination(@site.dest) if document.respond_to?(:destination)
|
33
|
+
source_modified_or_dest_missing?(source_path, dest_path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add a path to the metadata
|
38
|
+
#
|
39
|
+
# Returns true, also on failure.
|
40
|
+
def add(path)
|
41
|
+
return true unless File.exist?(path)
|
42
|
+
|
43
|
+
metadata[path] = {
|
44
|
+
"mtime" => File.mtime(path),
|
45
|
+
"deps" => [],
|
46
|
+
}
|
47
|
+
cache[path] = true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Force a path to regenerate
|
51
|
+
#
|
52
|
+
# Returns true.
|
53
|
+
def force(path)
|
54
|
+
cache[path] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
# Clear the metadata and cache
|
58
|
+
#
|
59
|
+
# Returns nothing
|
60
|
+
def clear
|
61
|
+
@metadata = {}
|
62
|
+
clear_cache
|
63
|
+
end
|
64
|
+
|
65
|
+
# Clear just the cache
|
66
|
+
#
|
67
|
+
# Returns nothing
|
68
|
+
def clear_cache
|
69
|
+
@cache = {}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Checks if the source has been modified or the
|
73
|
+
# destination is missing
|
74
|
+
#
|
75
|
+
# returns a boolean
|
76
|
+
def source_modified_or_dest_missing?(source_path, dest_path)
|
77
|
+
modified?(source_path) || (dest_path && !File.exist?(dest_path))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Checks if a path's (or one of its dependencies)
|
81
|
+
# mtime has changed
|
82
|
+
#
|
83
|
+
# Returns a boolean.
|
84
|
+
def modified?(path)
|
85
|
+
return true if disabled?
|
86
|
+
|
87
|
+
# objects that don't have a path are always regenerated
|
88
|
+
return true if path.nil?
|
89
|
+
|
90
|
+
# Check for path in cache
|
91
|
+
return cache[path] if cache.key? path
|
92
|
+
|
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)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Add a dependency of a path
|
104
|
+
#
|
105
|
+
# Returns nothing.
|
106
|
+
def add_dependency(path, dependency)
|
107
|
+
return if metadata[path].nil? || disabled
|
108
|
+
|
109
|
+
unless metadata[path]["deps"].include? dependency
|
110
|
+
metadata[path]["deps"] << dependency
|
111
|
+
add(dependency) unless metadata.include?(dependency)
|
112
|
+
end
|
113
|
+
regenerate? dependency
|
114
|
+
end
|
115
|
+
|
116
|
+
# Write the metadata to disk
|
117
|
+
#
|
118
|
+
# Returns nothing.
|
119
|
+
def write_metadata
|
120
|
+
unless disabled?
|
121
|
+
Bridgetown.logger.debug "Writing Metadata:", ".bridgetown-metadata"
|
122
|
+
File.binwrite(metadata_file, Marshal.dump(metadata))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Produce the absolute path of the metadata file
|
127
|
+
#
|
128
|
+
# Returns the String path of the file.
|
129
|
+
def metadata_file
|
130
|
+
@metadata_file ||= site.in_root_dir(".bridgetown-metadata")
|
131
|
+
end
|
132
|
+
|
133
|
+
# Check if metadata has been disabled
|
134
|
+
#
|
135
|
+
# Returns a Boolean (true for disabled, false for enabled).
|
136
|
+
def disabled?
|
137
|
+
self.disabled = !site.incremental? if disabled.nil?
|
138
|
+
disabled
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
# Read metadata from the metadata file, if no file is found,
|
144
|
+
# initialize with an empty hash
|
145
|
+
#
|
146
|
+
# Returns the read metadata.
|
147
|
+
def read_metadata
|
148
|
+
@metadata =
|
149
|
+
if !disabled? && File.file?(metadata_file)
|
150
|
+
content = File.binread(metadata_file)
|
151
|
+
|
152
|
+
begin
|
153
|
+
Marshal.load(content)
|
154
|
+
rescue TypeError
|
155
|
+
SafeYAML.load(content)
|
156
|
+
rescue ArgumentError => e
|
157
|
+
Bridgetown.logger.warn("Failed to load #{metadata_file}: #{e}")
|
158
|
+
{}
|
159
|
+
end
|
160
|
+
else
|
161
|
+
{}
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
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
|
+
def regenerate_document?(document)
|
173
|
+
!document.write? || document.data["regenerate"] ||
|
174
|
+
source_modified_or_dest_missing?(
|
175
|
+
document.path, document.destination(@site.dest)
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
def existing_file_modified?(path)
|
180
|
+
# If one of this file dependencies have been modified,
|
181
|
+
# set the regeneration bit for both the dependency and the file to true
|
182
|
+
metadata[path]["deps"].each do |dependency|
|
183
|
+
return cache[dependency] = cache[path] = true if modified?(dependency)
|
184
|
+
end
|
185
|
+
|
186
|
+
if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
|
187
|
+
# If this file has not been modified, set the regeneration bit to false
|
188
|
+
cache[path] = false
|
189
|
+
else
|
190
|
+
# If it has been modified, set it to true
|
191
|
+
add(path)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|