From 3a04093e5113751bbc4907c01f49412b6f94cbbd Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 23 May 2016 20:58:28 -0500 Subject: [PATCH 1/4] Rubocop cleanup for lib/jekyll/page.rb --- .rubocop.yml | 1 - lib/jekyll/page.rb | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 198cb1e6..0fdff616 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,7 +21,6 @@ AllCops: - lib/jekyll/layout.rb - lib/jekyll/liquid_renderer/table.rb - lib/jekyll/liquid_renderer.rb - - lib/jekyll/page.rb - lib/jekyll/plugin_manager.rb - lib/jekyll/reader.rb - lib/jekyll/readers/layout_reader.rb diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 2bdcdf6f..3f984709 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -9,7 +9,7 @@ module Jekyll alias_method :extname, :ext - FORWARD_SLASH = '/'.freeze + FORWARD_SLASH = "/".freeze # Attributes for Liquid templates ATTRIBUTES_FOR_LIQUID = %w( @@ -18,7 +18,7 @@ module Jekyll name path url - ) + ).freeze # A set of extensions that are considered HTML or HTML-like so we # should not alter them, this includes .xhtml through XHTM5. @@ -27,7 +27,7 @@ module Jekyll .html .xhtml .htm - ) + ).freeze # Initialize a new Page. # @@ -71,7 +71,7 @@ module Jekyll # # Returns the String permalink or nil if none has been set. def permalink - data.nil? ? nil : data['permalink'] + data.nil? ? nil : data["permalink"] end # The template of the permalink. @@ -92,9 +92,9 @@ module Jekyll # Returns the String url. def url @url ||= URL.new({ - :template => template, + :template => template, :placeholders => url_placeholders, - :permalink => permalink + :permalink => permalink }).to_s end @@ -135,7 +135,7 @@ module Jekyll # # Returns the path to the source file def path - data.fetch('path') { relative_path.sub(/\A\//, '') } + data.fetch("path") { relative_path.sub(%r{!\A\/!}, "") } end # The path to the page source file, relative to the site source @@ -167,7 +167,7 @@ module Jekyll # Returns the Boolean of whether this Page is an index file or not. def index? - basename == 'index' + basename == "index" end def trigger_hooks(hook_name, *args) From 65e78b3280dc861a3560cfa1bfd7450ee965402c Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 23 May 2016 21:07:24 -0500 Subject: [PATCH 2/4] Rubocop cleanup for lib/jekyll/plugin_manager.rb --- .rubocop.yml | 1 - lib/jekyll/plugin_manager.rb | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0fdff616..51f96642 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,7 +21,6 @@ AllCops: - lib/jekyll/layout.rb - lib/jekyll/liquid_renderer/table.rb - lib/jekyll/liquid_renderer.rb - - lib/jekyll/plugin_manager.rb - lib/jekyll/reader.rb - lib/jekyll/readers/layout_reader.rb - lib/jekyll/readers/page_reader.rb diff --git a/lib/jekyll/plugin_manager.rb b/lib/jekyll/plugin_manager.rb index 45eeaa79..ff8def48 100644 --- a/lib/jekyll/plugin_manager.rb +++ b/lib/jekyll/plugin_manager.rb @@ -24,7 +24,9 @@ module Jekyll # # Returns nothing. def require_gems - Jekyll::External.require_with_graceful_fail(site.gems.select { |gem| plugin_allowed?(gem) }) + Jekyll::External.require_with_graceful_fail( + site.gems.select { |gem| plugin_allowed?(gem) } + ) end def self.require_from_bundler @@ -33,7 +35,8 @@ module Jekyll Bundler.setup required_gems = Bundler.require(:jekyll_plugins) - Jekyll.logger.debug("PluginManager:", "Required #{required_gems.map(&:name).join(', ')}") + message = "Required #{required_gems.map(&:name).join(", ")}" + Jekyll.logger.debug("PluginManager:", message) ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true" true @@ -57,7 +60,7 @@ module Jekyll # Returns an array of strings, each string being the name of a gem name # that is allowed to be used. def whitelist - @whitelist ||= Array[site.config['whitelist']].flatten + @whitelist ||= Array[site.config["whitelist"]].flatten end # Require all .rb files if safe mode is off @@ -76,16 +79,17 @@ module Jekyll # # Returns an Array of plugin search paths def plugins_path - if site.config['plugins_dir'] == Jekyll::Configuration::DEFAULTS['plugins_dir'] - [site.in_source_dir(site.config['plugins_dir'])] + if site.config["plugins_dir"] == Jekyll::Configuration::DEFAULTS["plugins_dir"] + [site.in_source_dir(site.config["plugins_dir"])] else - Array(site.config['plugins_dir']).map { |d| File.expand_path(d) } + Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) } end end def deprecation_checks - pagination_included = (site.config['gems'] || []).include?('jekyll-paginate') || defined?(Jekyll::Paginate) - if site.config['paginate'] && !pagination_included + pagination_included = (site.config["gems"] || []).include?("jekyll-paginate") || + defined?(Jekyll::Paginate) + if site.config["paginate"] && !pagination_included Jekyll::Deprecator.deprecation_message "You appear to have pagination " \ "turned on, but you haven't included the `jekyll-paginate` gem. " \ "Ensure you have `gems: [jekyll-paginate]` in your configuration file." From de39107c76f6b769ce81203c71c6931eb904176c Mon Sep 17 00:00:00 2001 From: Brint O'Hearn Date: Mon, 23 May 2016 21:12:31 -0500 Subject: [PATCH 3/4] Rubocop cleanup for lib/jekyll/layout.rb --- .rubocop.yml | 1 - lib/jekyll/layout.rb | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 51f96642..b7dd2530 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,7 +18,6 @@ AllCops: - lib/jekyll/entry_filter.rb - lib/jekyll/filters.rb - lib/jekyll/frontmatter_defaults.rb - - lib/jekyll/layout.rb - lib/jekyll/liquid_renderer/table.rb - lib/jekyll/liquid_renderer.rb - lib/jekyll/reader.rb diff --git a/lib/jekyll/layout.rb b/lib/jekyll/layout.rb index 72005277..690d86fb 100644 --- a/lib/jekyll/layout.rb +++ b/lib/jekyll/layout.rb @@ -58,7 +58,9 @@ module Jekyll # Returns a String path which represents the relative path # from the site source to this layout def relative_path - @relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(@base_dir)).to_s + @relative_path ||= Pathname.new(path).relative_path_from( + Pathname.new(@base_dir) + ).to_s end end end From 4fbbeddae20fa52732f30ef001bb1f80258bc5d7 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 25 May 2016 17:57:09 -0700 Subject: [PATCH 4/4] Fix Page#relative_path so that it consistently does NOT have the prepending slash (previously inconsistent) Fixes for #4946 --- lib/jekyll/page.rb | 4 ++-- test/test_front_matter_defaults.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 3f984709..1542e986 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -135,12 +135,12 @@ module Jekyll # # Returns the path to the source file def path - data.fetch("path") { relative_path.sub(%r{!\A\/!}, "") } + data.fetch("path") { relative_path } end # The path to the page source file, relative to the site source def relative_path - File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)) + File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r{\A\/}, "") end # Obtain destination path. diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index f1b55ac1..51308016 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -17,7 +17,7 @@ class TestFrontMatterDefaults < JekyllUnitTest }] })) @site.process - @affected = @site.pages.find { |page| page.relative_path == "/contacts/bar.html" } + @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } end