From fa31fcb3bf3e18078fd6f471b67e4ff07a97ddd4 Mon Sep 17 00:00:00 2001 From: Jordon Bedwell Date: Wed, 4 Mar 2015 05:22:29 -0600 Subject: [PATCH 09/24] Update history.md to reflect the merger of #3418 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 23f81a0e..f4a88eda 100644 --- a/History.markdown +++ b/History.markdown @@ -46,6 +46,7 @@ * Docs: document 'ordinal' built-in permalink style (#3532) * Upgrade liquid-c to 3.x (#3531) * Use consistent syntax for deprecation warning (#3535) + * Added build --destination and --source flags (#3418) ### Bug Fixes From 2ef9bae75a5aa6d6a0843c1c5582fc047d4ee5df Mon Sep 17 00:00:00 2001 From: Martin Jorn Rogalla Date: Wed, 4 Mar 2015 14:16:55 +0100 Subject: [PATCH 10/24] Refactored url.rb to compliant with Ruby Style Guide. - Single Quotes - Fixed Typo's in variable names. - Removed Redundant Escaping in Regular Expressions. Signed-off-by: Martin Jorn Rogalla --- lib/jekyll/url.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 60c96507..4bbbf92e 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -29,7 +29,7 @@ module Jekyll @permalink = options[:permalink] if (@template || @permalink).nil? - raise ArgumentError, "One of :template or :permalink must be supplied." + raise ArgumentError, 'One of :template or :permalink must be supplied.' end end @@ -44,12 +44,12 @@ module Jekyll # # Returns the _unsanitized String URL def generated_permalink - (@generated_permlink ||= generate_url(@permalink)) if @permalink + (@generated_permalink ||= generate_url(@permalink)) if @permalink end # Generates a URL from the template # - # Returns the _unsanitized String URL + # Returns the unsanitized String URL def generated_url @generated_url ||= generate_url(@template) end @@ -57,7 +57,7 @@ module Jekyll # Internal: Generate the URL by replacing all placeholders with their # respective values in the given template # - # Returns the _unsanitizied_ String URL + # Returns the unsanitized String URL def generate_url(template) @placeholders.inject(template) do |result, token| break result if result.index(':').nil? @@ -81,7 +81,7 @@ module Jekyll .gsub(/\A([^\/])/, '/\1') # Append a trailing slash to the URL if the unsanitized URL had one - url << "/" if in_url[-1].eql?('/') + url << '/' if in_url[-1].eql?('/') url end @@ -107,7 +107,7 @@ module Jekyll # pct-encoded = "%" HEXDIG HEXDIG # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" # / "*" / "+" / "," / ";" / "=" - URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/).encode('utf-8') + URI.escape(path, /[^a-zA-Z\d\-._~!$&'()*+,;=:@\/]/).encode('utf-8') end # Unescapes a URL path segment From 0d1586a5c471d322a79177e3e9c2f5813c697c32 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Sat, 28 Feb 2015 22:23:08 -0800 Subject: [PATCH 11/24] Improved permalinks for pages and collections This updates the default permalink style for pages and collections to match the site-wide 'permalink' setting. If the permalink setting contains a trailing slash, either explicitly or by being set to ':pretty', then pages and collections permalinks will contain trailing slashes by default as well. Similarly, if the permalink setting contains a trailing ':output_ext', so will pages and collections. If the permalink setting contains neither a trailing slash or extension, neither will pages or collections. This impacts only the default permalink structure for pages and collections. Permalinks set in the frontmatter of an individual page take precedence, as does the permalink setting for a specific collection. Fixes #2691 --- lib/jekyll/collection.rb | 4 ++- lib/jekyll/page.rb | 14 ++++------- lib/jekyll/utils.rb | 40 +++++++++++++++++++++++++++++ test/test_document.rb | 26 ++++++++++++++++++- test/test_page.rb | 54 +++++++++++++++++++++++++++++++++++++++- test/test_utils.rb | 14 +++++++++++ 6 files changed, 140 insertions(+), 12 deletions(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index b09a7ed9..e8740cf6 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -170,7 +170,9 @@ module Jekyll # # Returns the URL template to render collection's documents at. def url_template - metadata.fetch('permalink', "/:collection/:path:output_ext") + metadata.fetch('permalink') do + Utils.add_permalink_suffix("/:collection/:path", site.permalink_style) + end end # Extract options for this collection from the site configuration. diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index ca824245..a4ddb698 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -63,16 +63,12 @@ module Jekyll # # Returns the template String. def template - if site.permalink_style == :pretty - if index? && html? - "/:path/" - elsif html? - "/:path/:basename/" - else - "/:path/:basename:output_ext" - end - else + if !html? "/:path/:basename:output_ext" + elsif index? + "/:path/" + else + Utils.add_permalink_suffix("/:path/:basename", site.permalink_style) end end diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index bba8b148..39302790 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -158,5 +158,45 @@ module Jekyll downcase end + # Add an appropriate suffix to template so that it matches the specified + # permalink style. + # + # template - permalink template without trailing slash or file extension + # permalink_style - permalink style, either built-in or custom + # + # The returned permalink template will use the same ending style as + # specified in permalink_style. For example, if permalink_style contains a + # trailing slash (or is :pretty, which indirectly has a trailing slash), + # then so will the returned template. If permalink_style has a trailing + # ":output_ext" (or is :none, :date, or :ordinal) then so will the returned + # template. Otherwise, template will be returned without modification. + # + # Examples: + # add_permalink_suffix("/:basename", :pretty) + # # => "/:basename/" + # + # add_permalink_suffix("/:basename", :date) + # # => "/:basename:output_ext" + # + # add_permalink_suffix("/:basename", "/:year/:month/:title/") + # # => "/:basename/" + # + # add_permalink_suffix("/:basename", "/:year/:month/:title") + # # => "/:basename" + # + # Returns the updated permalink template + def add_permalink_suffix(template, permalink_style) + case permalink_style + when :pretty + template << "/" + when :date, :ordinal, :none + template << ":output_ext" + else + template << "/" if permalink_style.to_s.end_with?("/") + template << ":output_ext" if permalink_style.to_s.end_with?(":output_ext") + end + template + end + end end diff --git a/test/test_document.rb b/test/test_document.rb index 56d6a671..f8b9db66 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -219,7 +219,31 @@ class TestDocument < JekyllUnitTest assert_equal "/slides/test/example-slide-1", @document.url end - should "produce the right destination" do + should "produce the right destination file" do + assert_equal @dest_file, @document.destination(dest_dir) + end + end + + context "a document in a collection with pretty permalink style" do + setup do + @site = fixture_site({ + "collections" => { + "slides" => { + "output" => true, + } + }, + }) + @site.permalink_style = :pretty + @site.process + @document = @site.collections["slides"].docs[0] + @dest_file = dest_dir("slides/example-slide-1/index.html") + end + + should "produce the right URL" do + assert_equal "/slides/example-slide-1/", @document.url + end + + should "produce the right destination file" do assert_equal @dest_file, @document.destination(dest_dir) end end diff --git a/test/test_page.rb b/test/test_page.rb index 9918442f..1e4d3da6 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -46,7 +46,7 @@ class TestPage < JekyllUnitTest should "create index url based on filename" do @page = setup_page('/contacts', 'index.html') - assert_equal "/contacts/index.html", @page.url + assert_equal "/contacts/", @page.url end end @@ -129,6 +129,58 @@ class TestPage < JekyllUnitTest end end + context "with date permalink style" do + setup do + @site.permalink_style = :date + end + + should "return url and destination correctly" do + @page = setup_page('contacts.html') + @dest_file = dest_dir("contacts.html") + assert_equal '/contacts.html', @page.url + assert_equal @dest_file, @page.destination(dest_dir) + end + end + + context "with custom permalink style with trailing slash" do + setup do + @site.permalink_style = "/:title/" + end + + should "return url and destination correctly" do + @page = setup_page('contacts.html') + @dest_file = dest_dir("contacts/index.html") + assert_equal '/contacts/', @page.url + assert_equal @dest_file, @page.destination(dest_dir) + end + end + + context "with custom permalink style with file extension" do + setup do + @site.permalink_style = "/:title:output_ext" + end + + should "return url and destination correctly" do + @page = setup_page('contacts.html') + @dest_file = dest_dir("contacts.html") + assert_equal '/contacts.html', @page.url + assert_equal @dest_file, @page.destination(dest_dir) + end + end + + context "with custom permalink style with no extension" do + setup do + @site.permalink_style = "/:title" + end + + should "return url and destination correctly" do + @page = setup_page('contacts.html') + @dest_file = dest_dir("contacts.html") + assert_equal '/contacts', @page.url + assert_equal @dest_file, @page.destination(dest_dir) + end + end + context "with any other permalink style" do should "return dir correctly" do @site.permalink_style = nil diff --git a/test/test_utils.rb b/test/test_utils.rb index ddb63d4b..9d4a5a4d 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -166,4 +166,18 @@ class TestUtils < JekyllUnitTest end end + context "The \`Utils.add_permalink_suffix\` method" do + should "handle built-in permalink styles" do + assert_equal "/:basename/", Utils.add_permalink_suffix("/:basename", :pretty) + assert_equal "/:basename:output_ext", Utils.add_permalink_suffix("/:basename", :date) + assert_equal "/:basename:output_ext", Utils.add_permalink_suffix("/:basename", :ordinal) + assert_equal "/:basename:output_ext", Utils.add_permalink_suffix("/:basename", :none) + end + + should "handle custom permalink styles" do + assert_equal "/:basename/", Utils.add_permalink_suffix("/:basename", "/:title/") + assert_equal "/:basename:output_ext", Utils.add_permalink_suffix("/:basename", "/:title:output_ext") + assert_equal "/:basename", Utils.add_permalink_suffix("/:basename", "/:title") + end + end end From c1562c8997397cc8ed6e1448767fbfc2bb8b7c63 Mon Sep 17 00:00:00 2001 From: Fabian Tamp Date: Wed, 4 Mar 2015 21:20:08 +0000 Subject: [PATCH 12/24] Improve consistency in site/_docs/plugins.md Three plugin strategies are listed, but then only two were referenced in the following note. I've updated this doc so that all three are referenced. --- site/_docs/plugins.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/_docs/plugins.md b/site/_docs/plugins.md index 9f4afb97..4958add3 100644 --- a/site/_docs/plugins.md +++ b/site/_docs/plugins.md @@ -42,12 +42,12 @@ You have 3 options for installing plugins:
- _plugins and gems + _plugins, _config.yml and Gemfile can be used simultaneously

- You may use both of the aforementioned plugin options simultaneously in the - same site if you so choose. Use of one does not restrict the use of the other + You may use any of the aforementioned plugin options simultaneously in the + same site if you so choose. Use of one does not restrict the use of the others.

From ca7375a51b779e754553c4bb5bd98cbf14aca490 Mon Sep 17 00:00:00 2001 From: Martin Jorn Rogalla Date: Wed, 4 Mar 2015 22:31:19 +0100 Subject: [PATCH 13/24] Corrected quote-usage. Replaced [-1].eql with end_with. Signed-off-by: Martin Jorn Rogalla --- lib/jekyll/url.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 4bbbf92e..14b70631 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -29,7 +29,7 @@ module Jekyll @permalink = options[:permalink] if (@template || @permalink).nil? - raise ArgumentError, 'One of :template or :permalink must be supplied.' + raise ArgumentError, "One of :template or :permalink must be supplied." end end @@ -81,7 +81,7 @@ module Jekyll .gsub(/\A([^\/])/, '/\1') # Append a trailing slash to the URL if the unsanitized URL had one - url << '/' if in_url[-1].eql?('/') + url << "/" if in_url.end_with?("/") url end From c8d23ffee25f42e844bc31e667ce41416f8ae307 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 4 Mar 2015 15:14:18 -0800 Subject: [PATCH 14/24] Update history to reflect merge of #3544 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index f4a88eda..29085385 100644 --- a/History.markdown +++ b/History.markdown @@ -90,6 +90,7 @@ * Remove trailing whitespace (#3497) * Use `fixture_site` for Document tests (#3511) * Remove adapters deprecation warning (#3529) + * Minor fixes to `url.rb` to follow GitHub style guide (#3544) ### Site Enhancements From 252665ddc66c9b85f79875f7171423aff32d41d0 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 4 Mar 2015 15:16:07 -0800 Subject: [PATCH 15/24] Update history to reflect merge of #3546 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 29085385..dd0e61df 100644 --- a/History.markdown +++ b/History.markdown @@ -131,6 +131,7 @@ * Add jekyll-auto-image generator to the list of third-party plugins (#3489) * Replace link to the proposed `picture` element spec (#3530) * Add frontmatter date formatting information (#3469) + * Improve consistency and clarity of plugins options note (#3546) ## 2.5.3 / 2014-12-22 From a608494e18cec86637c1d72cbcb5d038b6d18207 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 4 Mar 2015 15:20:25 -0800 Subject: [PATCH 16/24] Update history to reflect merge of #3538 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index dd0e61df..fb95cca6 100644 --- a/History.markdown +++ b/History.markdown @@ -11,6 +11,7 @@ * Move to Rouge as default highlighter (#3323) * Mimic GitHub Pages `.html` extension stripping behavior in WEBrick (#3452) * Always include file extension on output files (#3490) + * Improved permalinks for pages and collections (#3538) ### Minor Enhancements From 117bd8a6f07646c2b7b17b6e79fdb015d77f7e25 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 4 Mar 2015 18:33:22 -0800 Subject: [PATCH 17/24] Update history to reflect merge of #3537 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index fb95cca6..1808818b 100644 --- a/History.markdown +++ b/History.markdown @@ -48,6 +48,7 @@ * Upgrade liquid-c to 3.x (#3531) * Use consistent syntax for deprecation warning (#3535) * Added build --destination and --source flags (#3418) + * Site template: remove unused `page.meta` attribute (#3537) ### Bug Fixes From 489da6784a216b1eb1789b618d6aa96f815114b2 Mon Sep 17 00:00:00 2001 From: ChaYoung You Date: Thu, 5 Mar 2015 18:19:32 +0900 Subject: [PATCH 18/24] Remove duplicated range from regex `/\w/` is equivalent to `[a-zA-Z0-9_]`. See http://ruby-doc.org/core-2.2.0/doc/regexp_rdoc.html#label-Character+Classes. --- lib/jekyll/site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index aadfb8d0..96910255 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -528,7 +528,7 @@ module Jekyll end def sanitize_filename(name) - name.gsub!(/[^\w\s_-]+/, '') + name.gsub!(/[^\w\s-]+/, '') name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2') name.gsub(/\s+/, '_') end From 7806f9ed52e5f506736f78a5be5757aa87a4dbc5 Mon Sep 17 00:00:00 2001 From: ChaYoung You Date: Thu, 5 Mar 2015 18:21:52 +0900 Subject: [PATCH 19/24] Replace `File.exists?` with `File.exist?` `File.exists?` is deprecated method. See http://ruby-doc.org//core-2.2.0/File.html#exists-3F-method. --- lib/jekyll/configuration.rb | 2 +- test/test_configuration.rb | 6 +++--- test/test_site.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index e4855a9d..ca5d4839 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -137,7 +137,7 @@ module Jekyll config_files = override.delete('config') if config_files.to_s.empty? default = %w[yml yaml].find(Proc.new { 'yml' }) do |ext| - File.exists? Jekyll.sanitized_path(source(override), "_config.#{ext}") + File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}")) end config_files = Jekyll.sanitized_path(source(override), "_config.#{default}") @default_config_file = true diff --git a/test/test_configuration.rb b/test/test_configuration.rb index 7e14a418..8de8ac29 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -42,12 +42,12 @@ class TestConfiguration < JekyllUnitTest assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) end should "return .yaml if it exists but .yml does not" do - mock(File).exists?(source_dir("_config.yml")) { false } - mock(File).exists?(source_dir("_config.yaml")) { true } + mock(File).exist?(source_dir("_config.yml")) { false } + mock(File).exist?(source_dir("_config.yaml")) { true } assert_equal [source_dir("_config.yaml")], @config.config_files(@no_override) end should "return .yml if both .yml and .yaml exist" do - mock(File).exists?(source_dir("_config.yml")) { true } + mock(File).exist?(source_dir("_config.yml")) { true } assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) end should "return the config if given one config file" do diff --git a/test/test_site.rb b/test/test_site.rb index c460d873..76ce9ce1 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -143,7 +143,7 @@ class TestSite < JekyllUnitTest # simulate destination file deletion File.unlink dest - refute File.exists?(dest) + refute File.exist?(dest) sleep 1 @site.process From 3a4d826852db59b85c1d83d4890f4bfe4b495c4c Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 5 Mar 2015 11:20:13 -0800 Subject: [PATCH 20/24] Update history to reflect merge of #3547 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 1808818b..aa414666 100644 --- a/History.markdown +++ b/History.markdown @@ -93,6 +93,7 @@ * Use `fixture_site` for Document tests (#3511) * Remove adapters deprecation warning (#3529) * Minor fixes to `url.rb` to follow GitHub style guide (#3544) + * Minor changes to resolve deprecation warnings (#3547) ### Site Enhancements From b41ddbb8a92934e9b02ba0b4dd715496a519e59e Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Thu, 5 Mar 2015 14:35:40 -0600 Subject: [PATCH 21/24] Update history to reflect merge of #3520 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index aa414666..1375f45e 100644 --- a/History.markdown +++ b/History.markdown @@ -49,6 +49,7 @@ * Use consistent syntax for deprecation warning (#3535) * Added build --destination and --source flags (#3418) * Site template: remove unused `page.meta` attribute (#3537) + * Improve the error message when sorting null objects (#3520) ### Bug Fixes From bb4d47b905a474052cdbd9719750764df14450b0 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 5 Mar 2015 13:14:15 -0800 Subject: [PATCH 22/24] Move History declaration for #3528 back up to HEAD. --- History.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/History.markdown b/History.markdown index aa414666..60503693 100644 --- a/History.markdown +++ b/History.markdown @@ -94,6 +94,7 @@ * Remove adapters deprecation warning (#3529) * Minor fixes to `url.rb` to follow GitHub style guide (#3544) * Minor changes to resolve deprecation warnings (#3547) + * Convert remaining textile test documents to markdown (#3528) ### Site Enhancements @@ -299,7 +300,6 @@ * Allow Travis to 'parallelize' our tests (#2859) * Fix test for Liquid rendering in Sass (#2856) * Fixing "vertycal" typo in site template's `_base.scss` (#2889) - * Convert remaining textile test documents to markdown (#3528) ### Site Enhancements From 6d9258bcdcd7537920a87889a69d8ddc003ed6c5 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 5 Mar 2015 13:40:10 -0800 Subject: [PATCH 23/24] Release :gem: v3.0.0.beta2 --- lib/jekyll/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/version.rb b/lib/jekyll/version.rb index 8b67d1cf..64cdaba2 100644 --- a/lib/jekyll/version.rb +++ b/lib/jekyll/version.rb @@ -1,3 +1,3 @@ module Jekyll - VERSION = '3.0.0-beta1' + VERSION = '3.0.0.beta2' end