From 0eb2796a66ba1d7fab243c34e55f285b9fbec766 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 11 Dec 2014 12:48:57 -0800 Subject: [PATCH 1/3] Sort static files just once. Ref: #2075. --- lib/jekyll/site.rb | 3 ++- lib/jekyll/static_file.rb | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 7b8a4a00..3ddda474 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -187,6 +187,7 @@ module Jekyll end pages.sort_by!(&:name) + static_files.sort_by!(&:relative_path) end # Read all the files in //_posts and create a new Post @@ -384,7 +385,7 @@ module Jekyll "time" => time, "posts" => posts.sort { |a, b| b <=> a }, "pages" => pages, - "static_files" => static_files.sort { |a, b| a.relative_path <=> b.relative_path }, + "static_files" => static_files, "html_pages" => pages.select { |page| page.html? || page.url.end_with?("/") }, "categories" => post_attr_hash('categories'), "tags" => post_attr_hash('tags'), diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 8e100656..02500b1d 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -3,6 +3,8 @@ module Jekyll # The cache of last modification times [path] -> mtime. @@mtimes = Hash.new + attr_reader :relative_path + # Initialize a new StaticFile. # # site - The Site. @@ -15,6 +17,7 @@ module Jekyll @dir = dir @name = name @collection = collection + @relative_path = File.join(*[@dir, @name].compact) end # Returns source file path. @@ -22,11 +25,6 @@ module Jekyll File.join(*[@base, @dir, @name].compact) end - # Returns the source file path relative to the site source - def relative_path - @relative_path ||= File.join(*[@dir, @name].compact) - end - def extname File.extname(path) end From 2f8248a6f17f0dffb3b504aff165e25c9039666e Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 18 Dec 2014 00:10:20 -0800 Subject: [PATCH 2/3] Only call #site_payload once for all collection work. --- lib/jekyll/renderer.rb | 7 ++++--- lib/jekyll/site.rb | 3 ++- test/test_deprecator.rb | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 test/test_deprecator.rb diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 1cdf6c2a..3e66bce6 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -3,11 +3,12 @@ module Jekyll class Renderer - attr_reader :document, :site + attr_reader :document, :site, :payload - def initialize(site, document) + def initialize(site, document, payload = nil) @site = site @document = document + @payload = payload end # Determine which converters to use based on this document's @@ -32,7 +33,7 @@ module Jekyll def run payload = Utils.deep_merge_hashes({ "page" => document.to_liquid - }, site.site_payload) + }, payload || site.site_payload) info = { filters: [Jekyll::Filters], diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 3ddda474..85c479bf 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -292,9 +292,10 @@ module Jekyll def render relative_permalinks_deprecation_method + payload = site_payload collections.each do |label, collection| collection.docs.each do |document| - document.output = Jekyll::Renderer.new(self, document).run if document.regenerate? + document.output = Jekyll::Renderer.new(self, document, payload).run if document.regenerate? end end diff --git a/test/test_deprecator.rb b/test/test_deprecator.rb new file mode 100644 index 00000000..7be838d2 --- /dev/null +++ b/test/test_deprecator.rb @@ -0,0 +1,6 @@ +require 'helper' + +class TestDeprecator < Test::Unit::TestCase + def test_no_subcommand + end +end From b6641be8ef2f96e42c0a17dd5bb68cbaf4dc0b6f Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 18 Dec 2014 00:11:44 -0800 Subject: [PATCH 3/3] Call it site_payload instead of payload. --- lib/jekyll/renderer.rb | 12 ++++++------ test/test_deprecator.rb | 6 ------ 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 test/test_deprecator.rb diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 3e66bce6..e0701fd5 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -3,12 +3,12 @@ module Jekyll class Renderer - attr_reader :document, :site, :payload + attr_reader :document, :site, :site_payload - def initialize(site, document, payload = nil) - @site = site - @document = document - @payload = payload + def initialize(site, document, site_payload = nil) + @site = site + @document = document + @site_payload = site_payload end # Determine which converters to use based on this document's @@ -33,7 +33,7 @@ module Jekyll def run payload = Utils.deep_merge_hashes({ "page" => document.to_liquid - }, payload || site.site_payload) + }, site_payload || site.site_payload) info = { filters: [Jekyll::Filters], diff --git a/test/test_deprecator.rb b/test/test_deprecator.rb deleted file mode 100644 index 7be838d2..00000000 --- a/test/test_deprecator.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'helper' - -class TestDeprecator < Test::Unit::TestCase - def test_no_subcommand - end -end