parent
6d777a2a21
commit
a28f54a59f
|
@ -88,9 +88,10 @@ Naming/HeredocDelimiterNaming:
|
||||||
- test/**/*.rb
|
- test/**/*.rb
|
||||||
Naming/MemoizedInstanceVariableName:
|
Naming/MemoizedInstanceVariableName:
|
||||||
Exclude:
|
Exclude:
|
||||||
- lib/jekyll/page_without_a_file.rb
|
- lib/jekyll/convertible.rb
|
||||||
- lib/jekyll/drops/unified_payload_drop.rb
|
|
||||||
- lib/jekyll/drops/site_drop.rb
|
- lib/jekyll/drops/site_drop.rb
|
||||||
|
- lib/jekyll/drops/unified_payload_drop.rb
|
||||||
|
- lib/jekyll/page_without_a_file.rb
|
||||||
Naming/UncommunicativeMethodParamName:
|
Naming/UncommunicativeMethodParamName:
|
||||||
AllowedNames:
|
AllowedNames:
|
||||||
- _
|
- _
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -25,7 +25,7 @@ group :test do
|
||||||
gem "nokogiri", "~> 1.7"
|
gem "nokogiri", "~> 1.7"
|
||||||
gem "rspec"
|
gem "rspec"
|
||||||
gem "rspec-mocks"
|
gem "rspec-mocks"
|
||||||
gem "rubocop", "~> 0.57.2"
|
gem "rubocop", "~> 0.59.0"
|
||||||
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
|
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
|
||||||
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)
|
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ module Jekyll
|
||||||
# Returns cached value
|
# Returns cached value
|
||||||
def [](key)
|
def [](key)
|
||||||
return @cache[key] if @cache.key?(key)
|
return @cache[key] if @cache.key?(key)
|
||||||
|
|
||||||
path = path_to(hash(key))
|
path = path_to(hash(key))
|
||||||
if @@disk_cache_enabled && File.file?(path) && File.readable?(path)
|
if @@disk_cache_enabled && File.file?(path) && File.readable?(path)
|
||||||
@cache[key] = load(path)
|
@cache[key] = load(path)
|
||||||
|
@ -57,6 +58,7 @@ module Jekyll
|
||||||
def []=(key, value)
|
def []=(key, value)
|
||||||
@cache[key] = value
|
@cache[key] = value
|
||||||
return unless @@disk_cache_enabled
|
return unless @@disk_cache_enabled
|
||||||
|
|
||||||
path = path_to(hash(key))
|
path = path_to(hash(key))
|
||||||
dump(path, value)
|
dump(path, value)
|
||||||
end
|
end
|
||||||
|
@ -78,6 +80,7 @@ module Jekyll
|
||||||
def delete(key)
|
def delete(key)
|
||||||
@cache.delete(key)
|
@cache.delete(key)
|
||||||
return unless @@disk_cache_enabled
|
return unless @@disk_cache_enabled
|
||||||
|
|
||||||
path = path_to(hash(key))
|
path = path_to(hash(key))
|
||||||
File.delete(path)
|
File.delete(path)
|
||||||
end
|
end
|
||||||
|
@ -91,6 +94,7 @@ module Jekyll
|
||||||
# Otherwise, it might be cached on disk
|
# Otherwise, it might be cached on disk
|
||||||
# but we should not consider the disk cache if it is disabled
|
# but we should not consider the disk cache if it is disabled
|
||||||
return false unless @@disk_cache_enabled
|
return false unless @@disk_cache_enabled
|
||||||
|
|
||||||
path = path_to(hash(key))
|
path = path_to(hash(key))
|
||||||
File.file?(path) && File.readable?(path)
|
File.file?(path) && File.readable?(path)
|
||||||
end
|
end
|
||||||
|
@ -103,6 +107,7 @@ module Jekyll
|
||||||
config = config.inspect
|
config = config.inspect
|
||||||
cache = Jekyll::Cache.new "Jekyll::Cache"
|
cache = Jekyll::Cache.new "Jekyll::Cache"
|
||||||
return if cache.key?("config") && cache["config"] == config
|
return if cache.key?("config") && cache["config"] == config
|
||||||
|
|
||||||
clear
|
clear
|
||||||
cache = Jekyll::Cache.new "Jekyll::Cache"
|
cache = Jekyll::Cache.new "Jekyll::Cache"
|
||||||
cache["config"] = config
|
cache["config"] = config
|
||||||
|
@ -116,6 +121,7 @@ module Jekyll
|
||||||
def path_to(hash = nil)
|
def path_to(hash = nil)
|
||||||
@base_dir ||= File.join(@@base_dir, @name)
|
@base_dir ||= File.join(@@base_dir, @name)
|
||||||
return @base_dir if hash.nil?
|
return @base_dir if hash.nil?
|
||||||
|
|
||||||
File.join(@base_dir, hash[0..1], hash[2..-1]).freeze
|
File.join(@base_dir, hash[0..1], hash[2..-1]).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,6 +151,7 @@ module Jekyll
|
||||||
# rubocop:disable Security/MarshalLoad
|
# rubocop:disable Security/MarshalLoad
|
||||||
def load(path)
|
def load(path)
|
||||||
raise unless @@disk_cache_enabled
|
raise unless @@disk_cache_enabled
|
||||||
|
|
||||||
cached_file = File.open(path, "rb")
|
cached_file = File.open(path, "rb")
|
||||||
value = Marshal.load(cached_file)
|
value = Marshal.load(cached_file)
|
||||||
cached_file.close
|
cached_file.close
|
||||||
|
@ -158,6 +165,7 @@ module Jekyll
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def dump(path, value)
|
def dump(path, value)
|
||||||
return unless @@disk_cache_enabled
|
return unless @@disk_cache_enabled
|
||||||
|
|
||||||
dir = File.dirname(path)
|
dir = File.dirname(path)
|
||||||
FileUtils.mkdir_p(dir)
|
FileUtils.mkdir_p(dir)
|
||||||
File.open(path, "wb") do |cached_file|
|
File.open(path, "wb") do |cached_file|
|
||||||
|
|
|
@ -45,6 +45,7 @@ module Jekyll
|
||||||
|
|
||||||
Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file|
|
Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file|
|
||||||
next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file)
|
next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file)
|
||||||
|
|
||||||
files << file
|
files << file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ module Jekyll
|
||||||
filtered_entries.each do |file_path|
|
filtered_entries.each do |file_path|
|
||||||
full_path = collection_dir(file_path)
|
full_path = collection_dir(file_path)
|
||||||
next if File.directory?(full_path)
|
next if File.directory?(full_path)
|
||||||
|
|
||||||
if Utils.has_yaml_header? full_path
|
if Utils.has_yaml_header? full_path
|
||||||
read_document(full_path)
|
read_document(full_path)
|
||||||
else
|
else
|
||||||
|
@ -73,6 +74,7 @@ module Jekyll
|
||||||
# relative to the collection's directory
|
# relative to the collection's directory
|
||||||
def entries
|
def entries
|
||||||
return [] unless exists?
|
return [] unless exists?
|
||||||
|
|
||||||
@entries ||=
|
@entries ||=
|
||||||
Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry|
|
Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry|
|
||||||
entry["#{collection_dir}/"] = ""
|
entry["#{collection_dir}/"] = ""
|
||||||
|
@ -86,6 +88,7 @@ module Jekyll
|
||||||
# Returns a list of filtered entry paths.
|
# Returns a list of filtered entry paths.
|
||||||
def filtered_entries
|
def filtered_entries
|
||||||
return [] unless exists?
|
return [] unless exists?
|
||||||
|
|
||||||
@filtered_entries ||=
|
@filtered_entries ||=
|
||||||
Dir.chdir(directory) do
|
Dir.chdir(directory) do
|
||||||
entry_filter.filter(entries).reject do |f|
|
entry_filter.filter(entries).reject do |f|
|
||||||
|
@ -124,6 +127,7 @@ module Jekyll
|
||||||
# is stored on the filesystem.
|
# is stored on the filesystem.
|
||||||
def collection_dir(*files)
|
def collection_dir(*files)
|
||||||
return directory if files.empty?
|
return directory if files.empty?
|
||||||
|
|
||||||
site.in_source_dir(container, relative_directory, *files)
|
site.in_source_dir(container, relative_directory, *files)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ module Jekyll
|
||||||
# Returns a full Jekyll configuration
|
# Returns a full Jekyll configuration
|
||||||
def configuration_from_options(options)
|
def configuration_from_options(options)
|
||||||
return options if options.is_a?(Jekyll::Configuration)
|
return options if options.is_a?(Jekyll::Configuration)
|
||||||
|
|
||||||
Jekyll.configuration(options)
|
Jekyll.configuration(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,10 @@ module Jekyll
|
||||||
|
|
||||||
def properly_gathered_posts?(site)
|
def properly_gathered_posts?(site)
|
||||||
return true if site.config["collections_dir"].empty?
|
return true if site.config["collections_dir"].empty?
|
||||||
|
|
||||||
posts_at_root = site.in_source_dir("_posts")
|
posts_at_root = site.in_source_dir("_posts")
|
||||||
return true unless File.directory?(posts_at_root)
|
return true unless File.directory?(posts_at_root)
|
||||||
|
|
||||||
Jekyll.logger.warn "Warning:",
|
Jekyll.logger.warn "Warning:",
|
||||||
"Detected '_posts' directory outside custom `collections_dir`!"
|
"Detected '_posts' directory outside custom `collections_dir`!"
|
||||||
Jekyll.logger.warn "",
|
Jekyll.logger.warn "",
|
||||||
|
@ -70,6 +72,7 @@ module Jekyll
|
||||||
urls = collect_urls(urls, site.posts.docs, site.dest)
|
urls = collect_urls(urls, site.posts.docs, site.dest)
|
||||||
urls.each do |url, paths|
|
urls.each do |url, paths|
|
||||||
next unless paths.size > 1
|
next unless paths.size > 1
|
||||||
|
|
||||||
conflicting_urls = true
|
conflicting_urls = true
|
||||||
Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
||||||
" for the following pages: #{paths.join(", ")}"
|
" for the following pages: #{paths.join(", ")}"
|
||||||
|
@ -79,6 +82,7 @@ module Jekyll
|
||||||
|
|
||||||
def fsnotify_buggy?(_site)
|
def fsnotify_buggy?(_site)
|
||||||
return true unless Utils::Platforms.osx?
|
return true unless Utils::Platforms.osx?
|
||||||
|
|
||||||
if Dir.pwd != `pwd`.strip
|
if Dir.pwd != `pwd`.strip
|
||||||
Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
|
Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
|
||||||
We have detected that there might be trouble using fsevent on your
|
We have detected that there might be trouble using fsevent on your
|
||||||
|
@ -98,6 +102,7 @@ module Jekyll
|
||||||
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
|
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
|
||||||
urls.each_value do |real_urls|
|
urls.each_value do |real_urls|
|
||||||
next unless real_urls.uniq.size > 1
|
next unless real_urls.uniq.size > 1
|
||||||
|
|
||||||
urls_only_differ_by_case = true
|
urls_only_differ_by_case = true
|
||||||
Jekyll.logger.warn "Warning:", "The following URLs only differ" \
|
Jekyll.logger.warn "Warning:", "The following URLs only differ" \
|
||||||
" by case. On a case-insensitive file system one of the URLs" \
|
" by case. On a case-insensitive file system one of the URLs" \
|
||||||
|
@ -138,6 +143,7 @@ module Jekyll
|
||||||
|
|
||||||
def url_exists?(url)
|
def url_exists?(url)
|
||||||
return true unless url.nil? || url.empty?
|
return true unless url.nil? || url.empty?
|
||||||
|
|
||||||
Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\
|
Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\
|
||||||
"you may encounter problems with some plugins."
|
"you may encounter problems with some plugins."
|
||||||
false
|
false
|
||||||
|
@ -156,6 +162,7 @@ module Jekyll
|
||||||
|
|
||||||
def url_absolute(url)
|
def url_absolute(url)
|
||||||
return true if Addressable::URI.parse(url).absolute?
|
return true if Addressable::URI.parse(url).absolute?
|
||||||
|
|
||||||
Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
|
Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
|
||||||
"check the value of `url` in your config file."
|
"check the value of `url` in your config file."
|
||||||
false
|
false
|
||||||
|
|
|
@ -261,6 +261,7 @@ module Jekyll
|
||||||
return system "start", address if Utils::Platforms.windows?
|
return system "start", address if Utils::Platforms.windows?
|
||||||
return system "xdg-open", address if Utils::Platforms.linux?
|
return system "xdg-open", address if Utils::Platforms.linux?
|
||||||
return system "open", address if Utils::Platforms.osx?
|
return system "open", address if Utils::Platforms.osx?
|
||||||
|
|
||||||
Jekyll.logger.error "Refusing to launch browser; " \
|
Jekyll.logger.error "Refusing to launch browser; " \
|
||||||
"Platform launcher unknown."
|
"Platform launcher unknown."
|
||||||
end
|
end
|
||||||
|
|
|
@ -196,6 +196,7 @@ module Jekyll
|
||||||
begin
|
begin
|
||||||
files.each do |config_file|
|
files.each do |config_file|
|
||||||
next if config_file.nil? || config_file.empty?
|
next if config_file.nil? || config_file.empty?
|
||||||
|
|
||||||
new_config = read_config_file(config_file)
|
new_config = read_config_file(config_file)
|
||||||
configuration = Utils.deep_merge_hashes(configuration, new_config)
|
configuration = Utils.deep_merge_hashes(configuration, new_config)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Jekyll
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
return if @setup ||= false
|
return if @setup ||= false
|
||||||
|
|
||||||
unless (@parser = get_processor)
|
unless (@parser = get_processor)
|
||||||
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
|
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
|
||||||
Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"]
|
Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"]
|
||||||
|
|
|
@ -161,6 +161,7 @@ module Jekyll
|
||||||
# Returns true if the file has Liquid Tags or Variables, false otherwise.
|
# Returns true if the file has Liquid Tags or Variables, false otherwise.
|
||||||
def render_with_liquid?
|
def render_with_liquid?
|
||||||
return false if data["render_with_liquid"] == false
|
return false if data["render_with_liquid"] == false
|
||||||
|
|
||||||
Jekyll::Utils.has_liquid_construct?(content)
|
Jekyll::Utils.has_liquid_construct?(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ module Jekyll
|
||||||
# true otherwise.
|
# true otherwise.
|
||||||
def render_with_liquid?
|
def render_with_liquid?
|
||||||
return false if data["render_with_liquid"] == false
|
return false if data["render_with_liquid"] == false
|
||||||
|
|
||||||
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
|
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -304,6 +305,7 @@ module Jekyll
|
||||||
# equal or greater than the other doc's path. See String#<=> for more details.
|
# equal or greater than the other doc's path. See String#<=> for more details.
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
return nil unless other.respond_to?(:data)
|
return nil unless other.respond_to?(:data)
|
||||||
|
|
||||||
cmp = data["date"] <=> other.data["date"]
|
cmp = data["date"] <=> other.data["date"]
|
||||||
cmp = path <=> other.path if cmp.nil? || cmp.zero?
|
cmp = path <=> other.path if cmp.nil? || cmp.zero?
|
||||||
cmp
|
cmp
|
||||||
|
|
|
@ -26,6 +26,7 @@ module Jekyll
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
return nil unless other.is_a? DocumentDrop
|
return nil unless other.is_a? DocumentDrop
|
||||||
|
|
||||||
cmp = self["date"] <=> other["date"]
|
cmp = self["date"] <=> other["date"]
|
||||||
cmp = self["path"] <=> other["path"] if cmp.nil? || cmp.zero?
|
cmp = self["path"] <=> other["path"] if cmp.nil? || cmp.zero?
|
||||||
cmp
|
cmp
|
||||||
|
|
|
@ -101,6 +101,7 @@ module Jekyll
|
||||||
def key?(key)
|
def key?(key)
|
||||||
return false if key.nil?
|
return false if key.nil?
|
||||||
return true if self.class.mutable? && @mutations.key?(key)
|
return true if self.class.mutable? && @mutations.key?(key)
|
||||||
|
|
||||||
respond_to?(key) || fallback_data.key?(key)
|
respond_to?(key) || fallback_data.key?(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ module Jekyll
|
||||||
# We should remove this in 4.0 and switch to `{{ post.related_posts }}`.
|
# We should remove this in 4.0 and switch to `{{ post.related_posts }}`.
|
||||||
def related_posts
|
def related_posts
|
||||||
return nil unless @current_document.is_a?(Jekyll::Document)
|
return nil unless @current_document.is_a?(Jekyll::Document)
|
||||||
|
|
||||||
@current_document.related_posts
|
@current_document.related_posts
|
||||||
end
|
end
|
||||||
attr_writer :current_document
|
attr_writer :current_document
|
||||||
|
|
|
@ -35,6 +35,7 @@ module Jekyll
|
||||||
next true if symlink?(e)
|
next true if symlink?(e)
|
||||||
# Do not reject this entry if it is included.
|
# Do not reject this entry if it is included.
|
||||||
next false if included?(e)
|
next false if included?(e)
|
||||||
|
|
||||||
# Reject this entry if it is special, a backup file, or excluded.
|
# Reject this entry if it is special, a backup file, or excluded.
|
||||||
special?(e) || backup?(e) || excluded?(e)
|
special?(e) || backup?(e) || excluded?(e)
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,6 +90,7 @@ module Jekyll
|
||||||
|
|
||||||
def render_with_liquid?
|
def render_with_liquid?
|
||||||
return false if data["render_with_liquid"] == false
|
return false if data["render_with_liquid"] == false
|
||||||
|
|
||||||
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
|
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ module Jekyll
|
||||||
# RubyGems.
|
# RubyGems.
|
||||||
def version_constraint(gem_name)
|
def version_constraint(gem_name)
|
||||||
return "= #{Jekyll::VERSION}" if gem_name.to_s.eql?("jekyll-docs")
|
return "= #{Jekyll::VERSION}" if gem_name.to_s.eql?("jekyll-docs")
|
||||||
|
|
||||||
"> 0"
|
"> 0"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,7 @@ module Jekyll
|
||||||
def where(input, property, value)
|
def where(input, property, value)
|
||||||
return input if property.nil? || value.nil?
|
return input if property.nil? || value.nil?
|
||||||
return input unless input.respond_to?(:select)
|
return input unless input.respond_to?(:select)
|
||||||
|
|
||||||
input = input.values if input.is_a?(Hash)
|
input = input.values if input.is_a?(Hash)
|
||||||
input_id = input.hash
|
input_id = input.hash
|
||||||
|
|
||||||
|
@ -195,6 +196,7 @@ module Jekyll
|
||||||
# Returns the filtered array of objects
|
# Returns the filtered array of objects
|
||||||
def where_exp(input, variable, expression)
|
def where_exp(input, variable, expression)
|
||||||
return input unless input.respond_to?(:select)
|
return input unless input.respond_to?(:select)
|
||||||
|
|
||||||
input = input.values if input.is_a?(Hash) # FIXME
|
input = input.values if input.is_a?(Hash) # FIXME
|
||||||
|
|
||||||
condition = parse_condition(expression)
|
condition = parse_condition(expression)
|
||||||
|
@ -214,6 +216,7 @@ module Jekyll
|
||||||
def to_integer(input)
|
def to_integer(input)
|
||||||
return 1 if input == true
|
return 1 if input == true
|
||||||
return 0 if input == false
|
return 0 if input == false
|
||||||
|
|
||||||
input.to_i
|
input.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -226,6 +229,7 @@ module Jekyll
|
||||||
# Returns the filtered array of objects
|
# Returns the filtered array of objects
|
||||||
def sort(input, property = nil, nils = "first")
|
def sort(input, property = nil, nils = "first")
|
||||||
raise ArgumentError, "Cannot sort a null object." if input.nil?
|
raise ArgumentError, "Cannot sort a null object." if input.nil?
|
||||||
|
|
||||||
if property.nil?
|
if property.nil?
|
||||||
input.sort
|
input.sort
|
||||||
else
|
else
|
||||||
|
@ -244,6 +248,7 @@ module Jekyll
|
||||||
|
|
||||||
def pop(array, num = 1)
|
def pop(array, num = 1)
|
||||||
return array unless array.is_a?(Array)
|
return array unless array.is_a?(Array)
|
||||||
|
|
||||||
num = Liquid::Utils.to_integer(num)
|
num = Liquid::Utils.to_integer(num)
|
||||||
new_ary = array.dup
|
new_ary = array.dup
|
||||||
new_ary.pop(num)
|
new_ary.pop(num)
|
||||||
|
@ -252,6 +257,7 @@ module Jekyll
|
||||||
|
|
||||||
def push(array, input)
|
def push(array, input)
|
||||||
return array unless array.is_a?(Array)
|
return array unless array.is_a?(Array)
|
||||||
|
|
||||||
new_ary = array.dup
|
new_ary = array.dup
|
||||||
new_ary.push(input)
|
new_ary.push(input)
|
||||||
new_ary
|
new_ary
|
||||||
|
@ -259,6 +265,7 @@ module Jekyll
|
||||||
|
|
||||||
def shift(array, num = 1)
|
def shift(array, num = 1)
|
||||||
return array unless array.is_a?(Array)
|
return array unless array.is_a?(Array)
|
||||||
|
|
||||||
num = Liquid::Utils.to_integer(num)
|
num = Liquid::Utils.to_integer(num)
|
||||||
new_ary = array.dup
|
new_ary = array.dup
|
||||||
new_ary.shift(num)
|
new_ary.shift(num)
|
||||||
|
@ -267,6 +274,7 @@ module Jekyll
|
||||||
|
|
||||||
def unshift(array, input)
|
def unshift(array, input)
|
||||||
return array unless array.is_a?(Array)
|
return array unless array.is_a?(Array)
|
||||||
|
|
||||||
new_ary = array.dup
|
new_ary = array.dup
|
||||||
new_ary.unshift(input)
|
new_ary.unshift(input)
|
||||||
new_ary
|
new_ary
|
||||||
|
@ -274,6 +282,7 @@ module Jekyll
|
||||||
|
|
||||||
def sample(input, num = 1)
|
def sample(input, num = 1)
|
||||||
return input unless input.respond_to?(:sample)
|
return input unless input.respond_to?(:sample)
|
||||||
|
|
||||||
num = Liquid::Utils.to_integer(num) rescue 1
|
num = Liquid::Utils.to_integer(num) rescue 1
|
||||||
if num == 1
|
if num == 1
|
||||||
input.sample
|
input.sample
|
||||||
|
@ -330,6 +339,7 @@ module Jekyll
|
||||||
def parse_sort_input(property)
|
def parse_sort_input(property)
|
||||||
number_like = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z!
|
number_like = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z!
|
||||||
return property.to_f if property =~ number_like
|
return property.to_f if property =~ number_like
|
||||||
|
|
||||||
property
|
property
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ module Jekyll
|
||||||
# Returns the formatted String.
|
# Returns the formatted String.
|
||||||
def date_to_xmlschema(date)
|
def date_to_xmlschema(date)
|
||||||
return date if date.to_s.empty?
|
return date if date.to_s.empty?
|
||||||
|
|
||||||
time(date).xmlschema
|
time(date).xmlschema
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ module Jekyll
|
||||||
# Returns the formatted String.
|
# Returns the formatted String.
|
||||||
def date_to_rfc822(date)
|
def date_to_rfc822(date)
|
||||||
return date if date.to_s.empty?
|
return date if date.to_s.empty?
|
||||||
|
|
||||||
time(date).rfc822
|
time(date).rfc822
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,11 +74,13 @@ module Jekyll
|
||||||
# Returns a stringified date or the empty input.
|
# Returns a stringified date or the empty input.
|
||||||
def stringify_date(date, month_type, type = nil, style = nil)
|
def stringify_date(date, month_type, type = nil, style = nil)
|
||||||
return date if date.to_s.empty?
|
return date if date.to_s.empty?
|
||||||
|
|
||||||
time = time(date)
|
time = time(date)
|
||||||
if type == "ordinal"
|
if type == "ordinal"
|
||||||
day = time.day
|
day = time.day
|
||||||
ordinal_day = "#{day}#{ordinal(day)}"
|
ordinal_day = "#{day}#{ordinal(day)}"
|
||||||
return time.strftime("#{month_type} #{ordinal_day}, %Y") if style == "US"
|
return time.strftime("#{month_type} #{ordinal_day}, %Y") if style == "US"
|
||||||
|
|
||||||
return time.strftime("#{ordinal_day} #{month_type} %Y")
|
return time.strftime("#{ordinal_day} #{month_type} %Y")
|
||||||
end
|
end
|
||||||
time.strftime("%d #{month_type} %Y")
|
time.strftime("%d #{month_type} %Y")
|
||||||
|
|
|
@ -10,10 +10,13 @@ module Jekyll
|
||||||
# Returns the absolute URL as a String.
|
# Returns the absolute URL as a String.
|
||||||
def absolute_url(input)
|
def absolute_url(input)
|
||||||
return if input.nil?
|
return if input.nil?
|
||||||
|
|
||||||
input = input.url if input.respond_to?(:url)
|
input = input.url if input.respond_to?(:url)
|
||||||
return input if Addressable::URI.parse(input.to_s).absolute?
|
return input if Addressable::URI.parse(input.to_s).absolute?
|
||||||
|
|
||||||
site = @context.registers[:site]
|
site = @context.registers[:site]
|
||||||
return relative_url(input) if site.config["url"].nil?
|
return relative_url(input) if site.config["url"].nil?
|
||||||
|
|
||||||
Addressable::URI.parse(
|
Addressable::URI.parse(
|
||||||
site.config["url"].to_s + relative_url(input)
|
site.config["url"].to_s + relative_url(input)
|
||||||
).normalize.to_s
|
).normalize.to_s
|
||||||
|
@ -27,6 +30,7 @@ module Jekyll
|
||||||
# Returns a URL relative to the domain root as a String.
|
# Returns a URL relative to the domain root as a String.
|
||||||
def relative_url(input)
|
def relative_url(input)
|
||||||
return if input.nil?
|
return if input.nil?
|
||||||
|
|
||||||
input = input.url if input.respond_to?(:url)
|
input = input.url if input.respond_to?(:url)
|
||||||
return input if Addressable::URI.parse(input.to_s).absolute?
|
return input if Addressable::URI.parse(input.to_s).absolute?
|
||||||
|
|
||||||
|
@ -43,6 +47,7 @@ module Jekyll
|
||||||
# Returns a URL with the trailing `/index.html` removed
|
# Returns a URL with the trailing `/index.html` removed
|
||||||
def strip_index(input)
|
def strip_index(input)
|
||||||
return if input.nil? || input.to_s.empty?
|
return if input.nil? || input.to_s.empty?
|
||||||
|
|
||||||
input.sub(%r!/index\.html?$!, "/")
|
input.sub(%r!/index\.html?$!, "/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,6 +60,7 @@ module Jekyll
|
||||||
|
|
||||||
def ensure_leading_slash(input)
|
def ensure_leading_slash(input)
|
||||||
return input if input.nil? || input.empty? || input.start_with?("/")
|
return input if input.nil? || input.empty? || input.start_with?("/")
|
||||||
|
|
||||||
"/#{input}"
|
"/#{input}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,6 +36,7 @@ module Jekyll
|
||||||
def ensure_time!(set)
|
def ensure_time!(set)
|
||||||
return set unless set.key?("values") && set["values"].key?("date")
|
return set unless set.key?("values") && set["values"].key?("date")
|
||||||
return set if set["values"]["date"].is_a?(Time)
|
return set if set["values"]["date"].is_a?(Time)
|
||||||
|
|
||||||
set["values"]["date"] = Utils.parse_date(
|
set["values"]["date"] = Utils.parse_date(
|
||||||
set["values"]["date"],
|
set["values"]["date"],
|
||||||
"An invalid date format was found in a front-matter default set: #{set}"
|
"An invalid date format was found in a front-matter default set: #{set}"
|
||||||
|
@ -132,6 +133,7 @@ module Jekyll
|
||||||
collections_dir = @site.config["collections_dir"]
|
collections_dir = @site.config["collections_dir"]
|
||||||
slashed_coll_dir = "#{collections_dir}/"
|
slashed_coll_dir = "#{collections_dir}/"
|
||||||
return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir)
|
return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir)
|
||||||
|
|
||||||
path.sub(slashed_coll_dir, "")
|
path.sub(slashed_coll_dir, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ module Jekyll
|
||||||
# Ensure the priority is a Fixnum
|
# Ensure the priority is a Fixnum
|
||||||
def self.priority_value(priority)
|
def self.priority_value(priority)
|
||||||
return priority if priority.is_a?(Integer)
|
return priority if priority.is_a?(Integer)
|
||||||
|
|
||||||
PRIORITY_MAP[priority] || DEFAULT_PRIORITY
|
PRIORITY_MAP[priority] || DEFAULT_PRIORITY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,7 @@ module Jekyll
|
||||||
# the appropriate writer method, e.g. writer.info.
|
# the appropriate writer method, e.g. writer.info.
|
||||||
def write(level_of_message, topic, message = nil, &block)
|
def write(level_of_message, topic, message = nil, &block)
|
||||||
return false unless write_message?(level_of_message)
|
return false unless write_message?(level_of_message)
|
||||||
|
|
||||||
writer.public_send(level_of_message, message(topic, message, &block))
|
writer.public_send(level_of_message, message(topic, message, &block))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,8 +37,10 @@ module Jekyll
|
||||||
# Returns false only if no dependencies have been specified, otherwise nothing.
|
# Returns false only if no dependencies have been specified, otherwise nothing.
|
||||||
def require_theme_deps
|
def require_theme_deps
|
||||||
return false unless site.theme.runtime_dependencies
|
return false unless site.theme.runtime_dependencies
|
||||||
|
|
||||||
site.theme.runtime_dependencies.each do |dep|
|
site.theme.runtime_dependencies.each do |dep|
|
||||||
next if dep.name == "jekyll"
|
next if dep.name == "jekyll"
|
||||||
|
|
||||||
External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
|
External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,6 +61,7 @@ module Jekyll
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def retrieve_posts(dir)
|
def retrieve_posts(dir)
|
||||||
return if outside_configured_directory?(dir)
|
return if outside_configured_directory?(dir)
|
||||||
|
|
||||||
site.posts.docs.concat(post_reader.read_posts(dir))
|
site.posts.docs.concat(post_reader.read_posts(dir))
|
||||||
site.posts.docs.concat(post_reader.read_drafts(dir)) if site.show_drafts
|
site.posts.docs.concat(post_reader.read_drafts(dir)) if site.show_drafts
|
||||||
end
|
end
|
||||||
|
@ -124,6 +125,7 @@ module Jekyll
|
||||||
def get_entries(dir, subfolder)
|
def get_entries(dir, subfolder)
|
||||||
base = site.in_source_dir(dir, subfolder)
|
base = site.in_source_dir(dir, subfolder)
|
||||||
return [] unless File.exist?(base)
|
return [] unless File.exist?(base)
|
||||||
|
|
||||||
entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
|
entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
|
||||||
entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
|
entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,6 +54,7 @@ module Jekyll
|
||||||
|
|
||||||
def within(directory)
|
def within(directory)
|
||||||
return unless File.exist?(directory)
|
return unless File.exist?(directory)
|
||||||
|
|
||||||
Dir.chdir(directory) { yield }
|
Dir.chdir(directory) { yield }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ module Jekyll
|
||||||
def read_content(dir, magic_dir, matcher)
|
def read_content(dir, magic_dir, matcher)
|
||||||
@site.reader.get_entries(dir, magic_dir).map do |entry|
|
@site.reader.get_entries(dir, magic_dir).map do |entry|
|
||||||
next unless entry =~ matcher
|
next unless entry =~ matcher
|
||||||
|
|
||||||
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
|
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
|
||||||
Document.new(path,
|
Document.new(path,
|
||||||
:site => @site,
|
:site => @site,
|
||||||
|
|
|
@ -12,6 +12,7 @@ module Jekyll
|
||||||
|
|
||||||
Find.find(site.theme.assets_path) do |path|
|
Find.find(site.theme.assets_path) do |path|
|
||||||
next if File.directory?(path)
|
next if File.directory?(path)
|
||||||
|
|
||||||
if File.symlink?(path)
|
if File.symlink?(path)
|
||||||
Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
|
Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -21,6 +21,7 @@ module Jekyll
|
||||||
# Returns a boolean.
|
# Returns a boolean.
|
||||||
def regenerate?(document)
|
def regenerate?(document)
|
||||||
return true if disabled
|
return true if disabled
|
||||||
|
|
||||||
case document
|
case document
|
||||||
when Page
|
when Page
|
||||||
regenerate_page?(document)
|
regenerate_page?(document)
|
||||||
|
|
|
@ -158,10 +158,10 @@ module Jekyll
|
||||||
output = render_layout(output, layout, info)
|
output = render_layout(output, layout, info)
|
||||||
add_regenerator_dependencies(layout)
|
add_regenerator_dependencies(layout)
|
||||||
|
|
||||||
if (layout = site.layouts[layout.data["layout"]])
|
next unless (layout = site.layouts[layout.data["layout"]])
|
||||||
break if used.include?(layout)
|
break if used.include?(layout)
|
||||||
used << layout
|
|
||||||
end
|
used << layout
|
||||||
end
|
end
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
@ -202,6 +202,7 @@ module Jekyll
|
||||||
|
|
||||||
def add_regenerator_dependencies(layout)
|
def add_regenerator_dependencies(layout)
|
||||||
return unless document.write?
|
return unless document.write?
|
||||||
|
|
||||||
site.regenerator.add_dependency(
|
site.regenerator.add_dependency(
|
||||||
site.in_source_dir(document.path),
|
site.in_source_dir(document.path),
|
||||||
layout.path
|
layout.path
|
||||||
|
|
|
@ -377,6 +377,7 @@ module Jekyll
|
||||||
# Returns a path which is prefixed with the theme root directory.
|
# Returns a path which is prefixed with the theme root directory.
|
||||||
def in_theme_dir(*paths)
|
def in_theme_dir(*paths)
|
||||||
return nil unless theme
|
return nil unless theme
|
||||||
|
|
||||||
paths.reduce(theme.root) do |base, path|
|
paths.reduce(theme.root) do |base, path|
|
||||||
Jekyll.sanitized_path(base, path)
|
Jekyll.sanitized_path(base, path)
|
||||||
end
|
end
|
||||||
|
@ -474,6 +475,7 @@ module Jekyll
|
||||||
|
|
||||||
def render_regenerated(document, payload)
|
def render_regenerated(document, payload)
|
||||||
return unless regenerator.regenerate?(document)
|
return unless regenerator.regenerate?(document)
|
||||||
|
|
||||||
document.output = Jekyll::Renderer.new(self, document, payload).run
|
document.output = Jekyll::Renderer.new(self, document, payload).run
|
||||||
document.trigger_hooks(:post_render)
|
document.trigger_hooks(:post_render)
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,6 +98,7 @@ module Jekyll
|
||||||
dest_path = destination(dest)
|
dest_path = destination(dest)
|
||||||
|
|
||||||
return false if File.exist?(dest_path) && !modified?
|
return false if File.exist?(dest_path) && !modified?
|
||||||
|
|
||||||
self.class.mtimes[path] = mtime
|
self.class.mtimes[path] = mtime
|
||||||
|
|
||||||
FileUtils.mkdir_p(File.dirname(dest_path))
|
FileUtils.mkdir_p(File.dirname(dest_path))
|
||||||
|
|
|
@ -17,6 +17,7 @@ module Jekyll
|
||||||
@logdev = logdevice(severity)
|
@logdev = logdevice(severity)
|
||||||
|
|
||||||
return true if @logdev.nil? || severity < @level
|
return true if @logdev.nil? || severity < @level
|
||||||
|
|
||||||
progname ||= @progname
|
progname ||= @progname
|
||||||
if message.nil?
|
if message.nil?
|
||||||
if block_given?
|
if block_given?
|
||||||
|
|
|
@ -83,6 +83,7 @@ module Jekyll
|
||||||
|
|
||||||
site.posts.docs.each do |p|
|
site.posts.docs.each do |p|
|
||||||
next unless @post.deprecated_equality p
|
next unless @post.deprecated_equality p
|
||||||
|
|
||||||
Jekyll::Deprecator.deprecation_message "A call to "\
|
Jekyll::Deprecator.deprecation_message "A call to "\
|
||||||
"'{% post_url #{@post.name} %}' did not match " \
|
"'{% post_url #{@post.name} %}' did not match " \
|
||||||
"a post using the new matching method of checking name " \
|
"a post using the new matching method of checking name " \
|
||||||
|
|
|
@ -40,6 +40,7 @@ module Jekyll
|
||||||
|
|
||||||
def configure_sass
|
def configure_sass
|
||||||
return unless sass_path
|
return unless sass_path
|
||||||
|
|
||||||
External.require_with_graceful_fail("sass") unless defined?(Sass)
|
External.require_with_graceful_fail("sass") unless defined?(Sass)
|
||||||
Sass.load_paths << sass_path
|
Sass.load_paths << sass_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,6 +68,7 @@ module Jekyll
|
||||||
def generate_url_from_hash(template)
|
def generate_url_from_hash(template)
|
||||||
@placeholders.inject(template) do |result, token|
|
@placeholders.inject(template) do |result, token|
|
||||||
break result if result.index(":").nil?
|
break result if result.index(":").nil?
|
||||||
|
|
||||||
if token.last.nil?
|
if token.last.nil?
|
||||||
# Remove leading "/" to avoid generating urls with `//`
|
# Remove leading "/" to avoid generating urls with `//`
|
||||||
result.gsub("/:#{token.first}", "")
|
result.gsub("/:#{token.first}", "")
|
||||||
|
|
|
@ -152,6 +152,7 @@ module Jekyll
|
||||||
# Returns true is the string contains sequences of `{%` or `{{`
|
# Returns true is the string contains sequences of `{%` or `{{`
|
||||||
def has_liquid_construct?(content)
|
def has_liquid_construct?(content)
|
||||||
return false if content.nil? || content.empty?
|
return false if content.nil? || content.empty?
|
||||||
|
|
||||||
content.include?("{%") || content.include?("{{")
|
content.include?("{%") || content.include?("{{")
|
||||||
end
|
end
|
||||||
# rubocop: enable PredicateName
|
# rubocop: enable PredicateName
|
||||||
|
@ -292,8 +293,10 @@ module Jekyll
|
||||||
# Returns matched pathes
|
# Returns matched pathes
|
||||||
def safe_glob(dir, patterns, flags = 0)
|
def safe_glob(dir, patterns, flags = 0)
|
||||||
return [] unless Dir.exist?(dir)
|
return [] unless Dir.exist?(dir)
|
||||||
|
|
||||||
pattern = File.join(Array(patterns))
|
pattern = File.join(Array(patterns))
|
||||||
return [dir] if pattern.empty?
|
return [dir] if pattern.empty?
|
||||||
|
|
||||||
Dir.chdir(dir) do
|
Dir.chdir(dir) do
|
||||||
Dir.glob(pattern, flags).map { |f| File.join(dir, f) }
|
Dir.glob(pattern, flags).map { |f| File.join(dir, f) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,13 +70,12 @@ module Jekyll
|
||||||
private
|
private
|
||||||
|
|
||||||
def proc_version
|
def proc_version
|
||||||
@proc_version ||= begin
|
@proc_version ||=
|
||||||
Pathutil.new(
|
begin
|
||||||
"/proc/version"
|
Pathutil.new("/proc/version").read
|
||||||
).read
|
rescue Errno::ENOENT
|
||||||
rescue Errno::ENOENT
|
nil
|
||||||
nil
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,6 +42,7 @@ class TestRegenerator < JekyllUnitTest
|
||||||
# because regenerate? checks if the destination exists
|
# because regenerate? checks if the destination exists
|
||||||
[@page, @post, @document, @asset_file].each do |item|
|
[@page, @post, @document, @asset_file].each do |item|
|
||||||
next unless item.respond_to?(:destination)
|
next unless item.respond_to?(:destination)
|
||||||
|
|
||||||
dest = item.destination(@site.dest)
|
dest = item.destination(@site.dest)
|
||||||
FileUtils.mkdir_p(File.dirname(dest))
|
FileUtils.mkdir_p(File.dirname(dest))
|
||||||
FileUtils.touch(dest)
|
FileUtils.touch(dest)
|
||||||
|
|
Loading…
Reference in New Issue