From c0d891b08bcae703b87db2b281b42785e72142f5 Mon Sep 17 00:00:00 2001 From: Eric Cornelissen Date: Thu, 8 Feb 2018 14:51:13 +0100 Subject: [PATCH 001/337] Add jekyll-fontello to plugins (#6757) Merge pull request 6757 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index 9cd906e42f4..f52c6f87d08 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -782,6 +782,7 @@ You can find a few useful plugins at the following locations: - [Stickyposts](https://github.com/ibrado/jekyll-stickyposts): Moves or copies (pins) posts marked `sticky: true` to the top of the list. Perfect for keeping important announcements on the home page, or giving collections a descriptive entry. Paginator friendly. - [Jekyll::Paginate::Content](https://github.com/ibrado/jekyll-paginate-content): Content paginator in the style of jekyll-paginator-v2 that splits pages, posts, and collection entries into several pages. Specify a separator or use HTML <h1> etc. headers. Automatic splitting, single-page view, pager/trail, self-adjusting links, multipage TOC, SEO support. - [Premonition](https://github.com/amedia/premonition): Adds block-styled side content to your page. For example summary, notes, hints or warning boxes. +- [jekyll-fontello](https://github.com/ericcornelissen/jekyll-fontello): A Jekyll plugin that automatically downloads your webfont from Fontello. #### Converters From 0b09c4ad8d790f9ed0fa923b370d907fedd029e1 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 8 Feb 2018 08:51:15 -0500 Subject: [PATCH 002/337] Update history to reflect merge of #6757 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 8b6e44f4218..9774c5db5fe 100644 --- a/History.markdown +++ b/History.markdown @@ -15,6 +15,7 @@ * Added Premonition plugin to list of plugins (#6750) * Add document on releasing a new version (#6745) * Mention Talkyard, a new commenting system for Jekyll and others. (#6752) + * Add 'jekyll-fontello' to plugins (#6757) ### Site Enhancements From 8ebe5e3a3eeebca1ec692f27e2d6836d9447c36f Mon Sep 17 00:00:00 2001 From: Damien Solodow Date: Sat, 10 Feb 2018 15:34:45 -0500 Subject: [PATCH 003/337] Update windows.md (#6765) Merge pull request 6765 --- docs/_docs/windows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/windows.md b/docs/_docs/windows.md index d1a30b2752f..e0ca4d7b6fd 100644 --- a/docs/_docs/windows.md +++ b/docs/_docs/windows.md @@ -30,7 +30,7 @@ Now we can install Ruby. To do this we will use a repository from [BrightBox](ht ```sh sudo apt-add-repository ppa:brightbox/ruby-ng sudo apt-get update -sudo apt-get install ruby2.3 ruby2.3-dev build-essential +sudo apt-get install ruby2.3 ruby2.3-dev build-essential dh-autoreconf ``` Next let's update our Ruby gems: From 33017b702d44f6446f353620daf1f12dda29f331 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 10 Feb 2018 15:34:46 -0500 Subject: [PATCH 004/337] Update history to reflect merge of #6765 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 9774c5db5fe..b150e4a301e 100644 --- a/History.markdown +++ b/History.markdown @@ -16,6 +16,7 @@ * Add document on releasing a new version (#6745) * Mention Talkyard, a new commenting system for Jekyll and others. (#6752) * Add 'jekyll-fontello' to plugins (#6757) + * Update windows.md (#6765) ### Site Enhancements From 8fae0052c8e0888953da159045909ea2c1336b3d Mon Sep 17 00:00:00 2001 From: Semen Zhydenko Date: Sun, 11 Feb 2018 03:58:13 +0100 Subject: [PATCH 005/337] Fix typos (#6764) Merge pull request 6764 --- .github/ISSUE_TEMPLATE.md | 2 +- .github/first-timers-issue-template.md | 2 +- History.markdown | 8 ++++---- docs/_docs/history.md | 8 ++++---- docs/_docs/themes.md | 2 +- test/test_page_without_a_file.rb | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index fdba86159e2..73c8928dbbe 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -48,7 +48,7 @@ ## My Reproduction Steps - -{% endif %} - {% if site.google_analytics_id %} ").strip - end - - context "with pygments enabled" do - setup do - @markdown = Converters::Markdown.new @config.merge( - { "highlighter" => "pygments" } - ) - end - - should "render fenced code blocks with syntax highlighting" do - assert_equal( - %(
puts "Hello world"\n
), - @markdown.convert(@sample).strip - ) - end - end - - context "with rouge enabled" do - setup do - @markdown = Converters::Markdown.new @config.merge({ "highlighter" => "rouge" }) - end - - should "render fenced code blocks with syntax highlighting" do - assert_equal( - %(
puts "Hello world"\n
), - @markdown.convert(@sample).strip - ) - end - end - - context "without any highlighter" do - setup do - @markdown = Converters::Markdown.new @config.merge({ "highlighter" => nil }) - end - - should "render fenced code blocks without syntax highlighting" do - assert_equal( - %(
puts "Hello world"\n
), - @markdown.convert(@sample).strip - ) - end - end - end -end diff --git a/test/test_tags.rb b/test/test_tags.rb index ee01a596549..739ced21483 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -494,7 +494,7 @@ def highlight_block_with_opts(options_string) setup do @content = <FINISH HIM!, @result end end - - context "using Redcarpet" do - setup do - if jruby? - skip( - "JRuby does not perform well with CExt, test disabled." - ) - end - - create_post(@content, { - "markdown" => "redcarpet", - }) - end - - should "parse correctly" do - assert_match %r{FIGHT!}, @result - assert_match %r!FINISH HIM!, @result - end - end end context "simple page with post linking" do From 7612056bed8ce1a929508390b9bb3fe48ea3c503 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 6 May 2018 10:18:04 -0400 Subject: [PATCH 228/337] Update history to reflect merge of #6987 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 5fa186004b2..69a08b1c855 100644 --- a/History.markdown +++ b/History.markdown @@ -28,6 +28,7 @@ * bump i18n (#6931) * We are not using Ruby 2.2 anymore (#6977) * Drop support for older versions of Rouge (#6978) + * Remove support for Redcarpet (#6987) ### Development Fixes From 694800270ae0e1efa4926ed4492c8db6dc51560c Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 7 May 2018 03:45:34 -0400 Subject: [PATCH 229/337] Update history to reflect merge of #6990 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 69a08b1c855..ce9fc970c98 100644 --- a/History.markdown +++ b/History.markdown @@ -12,6 +12,7 @@ * Fix typo (#6969) * Add version number for group_by_exp doc (#6956) * Update Windows install docs (#6926) + * Remove documentation for using Redcarpet (#6990) ### Minor Enhancements From 192df096b037902de3274ca78ce68bd71e9fc448 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 7 May 2018 13:43:41 +0530 Subject: [PATCH 230/337] Revert update to docs meant for v4.0 --- docs/_docs/templates.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/docs/_docs/templates.md b/docs/_docs/templates.md index e91de10dbfb..4b93b75afd1 100644 --- a/docs/_docs/templates.md +++ b/docs/_docs/templates.md @@ -588,23 +588,6 @@ One major benefit of using the `link` or `post_url` tag is link validation. If t Note you cannot add filters to `link` tags. For example, you cannot append a string using Liquid filters, such as `{% raw %}{% link mypage.html | append: "#section1" %} {% endraw %}`. To link to sections on a page, you will need to use regular HTML or Markdown linking techniques. -The name of the file you want to link can be specified as a variable instead of an actual file name. For example, suppose you defined a variable in your page's front matter like this: - -```yaml ---- -title: My page -my_variable: footer_company_a.html ---- -``` - -You could then reference that variable in your link: - -```liquid -{% raw %}{% link {{ page.my_variable }} %}{% endraw %} -``` - -In this example, the link would add link to the file `footer_company_a.html`. - ### Linking to posts If you want to include a link to a post on your site, the `post_url` tag will generate the correct permalink URL for the post you specify. From cec17d03f8c6a83df31952a8681db986ad12d7a0 Mon Sep 17 00:00:00 2001 From: Arjun Thakur Date: Mon, 7 May 2018 23:19:55 +0530 Subject: [PATCH 231/337] Updated nginx configuration for custom-404-page documentation (#6994) Merge pull request 6994 --- docs/_tutorials/custom-404-page.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/_tutorials/custom-404-page.md b/docs/_tutorials/custom-404-page.md index 47efe958247..91cd9c87686 100644 --- a/docs/_tutorials/custom-404-page.md +++ b/docs/_tutorials/custom-404-page.md @@ -53,7 +53,7 @@ More info on configuring Apache Error Pages can found in [official documentation The procedure is just as simple as configuring Apache servers, but slightly different. -Add the following to the nginx configuration file, `nginx.conf`, which is usually located inside `/etc/nginx/` or `/etc/nginx/conf/`: +The nginx configuration file depends on the system in which it is installed. In most systems, it is the `nginx.conf` file, which is usually located inside `/etc/nginx/` or `/etc/nginx/conf/`. However, in other systems like Ubuntu, you would have to look for a `default` nginx configuration file, containing server related information, which is usually located inside `/etc/nginx/sites-available/` or `/etc/nginx/sites-enabled/`. Add the following to your nginx configuration file, _i.e._ either to `nginx.conf` file or to `default` file: ```nginx server { @@ -63,5 +63,11 @@ server { } } ``` - +If the `server` block already exists, only add the code inside the `server` block given above. The `location` directive prevents users from directly browsing the 404.html page. + +More info on nginx error page can be found on [nginx official documentation](http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page). + +

+ Proceed with caution while editing the configuration file. +

From 0c5b74377bd59c5e8001643800ca8a812818b491 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 7 May 2018 13:49:56 -0400 Subject: [PATCH 232/337] Update history to reflect merge of #6994 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index ce9fc970c98..95eab348cc5 100644 --- a/History.markdown +++ b/History.markdown @@ -13,6 +13,7 @@ * Add version number for group_by_exp doc (#6956) * Update Windows install docs (#6926) * Remove documentation for using Redcarpet (#6990) + * Updated nginx configuration for custom-404-page documentation (#6994) ### Minor Enhancements From 66f8e748fe5a1a8b3980ab4a445636a409228d84 Mon Sep 17 00:00:00 2001 From: olivia Date: Mon, 7 May 2018 19:52:59 +0200 Subject: [PATCH 233/337] Replace individual core team emails --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index c6864b4b3ad..fe5e91f7b13 100644 --- a/README.markdown +++ b/README.markdown @@ -45,7 +45,7 @@ conduct. Please adhere to this code of conduct in any interactions you have in the Jekyll community. It is strictly enforced on all official Jekyll repositories, websites, and resources. If you encounter someone violating -these terms, please let one of our core team members [Olivia](mailto:olivia@jekyllrb.com?subject=Jekyll%20CoC%20Violation), [Pat](mailto:pat@jekyllrb.com?subject=Jekyll%20CoC%20Violation), [Matt](mailto:matt@jekyllrb.com?subject=Jekyll%20CoC%20Violation) or [Parker](mailto:parker@jekyllrb.com?subject=Jekyll%20CoC%20Violation) know and we will address it as soon as possible. +these terms, please let one of our [core team members](https://jekyllrb.com/team/#core-team) know and we will address it as soon as possible. ## Diving In From e2d8d3b92f8bfe09dc5bbfa63ae08b044f936c07 Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Wed, 9 May 2018 12:20:23 +0200 Subject: [PATCH 234/337] List all static files variables (#7002) Merge pull request 7002 --- docs/_docs/variables.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/_docs/variables.md b/docs/_docs/variables.md index a53d9285deb..d39def6e7ff 100644 --- a/docs/_docs/variables.md +++ b/docs/_docs/variables.md @@ -124,8 +124,7 @@ following is a reference of the available data. A list of all static files (i.e. files not processed by Jekyll's converters or the Liquid renderer). - Each file has three properties: path, - modified_time and extname. + Each file has five properties: path, modified_time, name, basename and extname.

From a59eaff78963483d41602f62e3d8f53e46d1e166 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 9 May 2018 06:20:25 -0400 Subject: [PATCH 235/337] Update history to reflect merge of #7002 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 95eab348cc5..196d1d2724f 100644 --- a/History.markdown +++ b/History.markdown @@ -14,6 +14,7 @@ * Update Windows install docs (#6926) * Remove documentation for using Redcarpet (#6990) * Updated nginx configuration for custom-404-page documentation (#6994) + * List all static files variables (#7002) ### Minor Enhancements From e9b507a0df0d9d18ba17bffebe819085ffe4bccd Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Wed, 9 May 2018 13:45:18 +0200 Subject: [PATCH 236/337] Textile is only supported through a converter plugin (#7003) Merge pull request 7003 --- docs/_docs/pagination.md | 2 +- docs/_docs/structure.md | 5 +++-- docs/_docs/upgrading/2-to-3.md | 4 ++++ docs/index.html | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/_docs/pagination.md b/docs/_docs/pagination.md index 41a3a8a26e5..1735ee64012 100644 --- a/docs/_docs/pagination.md +++ b/docs/_docs/pagination.md @@ -14,7 +14,7 @@ your `_config.yml` under `plugins`. For Jekyll 2, this is standard.
Pagination only works within HTML files

- Pagination does not work from within Markdown or Textile files from + Pagination does not work from within Markdown files from your Jekyll site. Pagination works when called from within the HTML file, named index.html, which optionally may reside in and produce pagination from within a subdirectory, via the diff --git a/docs/_docs/structure.md b/docs/_docs/structure.md index 6735d6e02ac..6a069f29fca 100644 --- a/docs/_docs/structure.md +++ b/docs/_docs/structure.md @@ -5,7 +5,8 @@ permalink: /docs/structure/ Jekyll is, at its core, a text transformation engine. The concept behind the system is this: you give it text written in your favorite markup language, be -that Markdown, Textile, or just plain HTML, and it churns that through a layout +that Markdown, [Textile](https://github.com/jekyll/jekyll-textile-converter) +, or just plain HTML, and it churns that through a layout or a series of layout files. Throughout that process you can tweak how you want the site URLs to look, what data gets displayed in the layout, and more. This is all done through editing text files; the static web site is the final @@ -185,7 +186,7 @@ An overview of what each of these does:

index.html or index.md and other HTML, - Markdown, Textile files

+ Markdown files

diff --git a/docs/_docs/upgrading/2-to-3.md b/docs/_docs/upgrading/2-to-3.md index c12a1a91f41..bafda35ffae 100644 --- a/docs/_docs/upgrading/2-to-3.md +++ b/docs/_docs/upgrading/2-to-3.md @@ -44,6 +44,10 @@ For `site.collections.myCollection` in Jekyll 2, you now do: This is a bit cumbersome at first, but is easier than a big `for` loop. +### Textile support + +We dropped native support for Textile, from now on you have to install our [jekyll-textile-converter](https://github.com/jekyll/jekyll-textile-converter) plugin to work with Textile files. + ### Dropped dependencies We dropped a number of dependencies the Core Team felt were optional. As such, in 3.0, they must be explicitly installed and included if you use any of the features. They are: diff --git a/docs/index.html b/docs/index.html index 082e02d8eee..a33774784c8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -21,7 +21,7 @@

Simple

-
Be sure to move posts into custom collections directory
+
Be sure to move drafts and posts into custom collections directory
-

If you specify a directory to store all your collections in the same place with collections_dir: my_collections, then you will need to move your _posts directory to my_collections/_posts. Note that, the name of your collections directory cannot start with an underscore (`_`).

+

If you specify a directory to store all your collections in the same place with collections_dir: my_collections, then you will need to move your _drafts and _posts directory to my_collections/_drafts and my_collections/_posts. Note that, the name of your collections directory cannot start with an underscore (`_`).

### Step 2: Add your content {#step2} From c2211eec0c514cb6f1a0a595eb15dbbc2039951f Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 9 May 2018 07:52:13 -0400 Subject: [PATCH 239/337] Update history to reflect merge of #6985 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 7e5b2830061..c13d624d4ea 100644 --- a/History.markdown +++ b/History.markdown @@ -17,6 +17,7 @@ * Remove documentation for using Redcarpet (#6990) * Updated nginx configuration for custom-404-page documentation (#6994) * List all static files variables (#7002) + * Document that _drafts need to be contained within the custom collection directory (#6985) ### Minor Enhancements From 149d5de59a6c506490cf7cd7c3d52e7b5a1812a7 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 9 May 2018 09:44:36 -0400 Subject: [PATCH 240/337] Remove support for rdiscount (#6988) Merge pull request 6988 --- Gemfile | 1 - features/site_configuration.feature | 8 --- lib/jekyll/configuration.rb | 4 -- lib/jekyll/converters/markdown.rb | 7 ++- .../converters/markdown/rdiscount_parser.rb | 37 -------------- test/helper.rb | 4 -- test/test_rdiscount.rb | 51 ------------------- test/test_tags.rb | 21 +------- 8 files changed, 4 insertions(+), 129 deletions(-) delete mode 100644 lib/jekyll/converters/markdown/rdiscount_parser.rb delete mode 100644 test/test_rdiscount.rb diff --git a/Gemfile b/Gemfile index 1f31549e962..08ab18af225 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,6 @@ group :jekyll_optional_dependencies do gem "classifier-reborn", "~> 2.2.0" gem "liquid-c", "~> 3.0" gem "pygments.rb", "~> 1.0" - gem "rdiscount", "~> 2.0" gem "yajl-ruby", "~> 1.3" end diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 4baa36a87a3..698c59bca7d 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -65,14 +65,6 @@ Feature: Site configuration And the "_site/Rakefile" file should not exist And the "_site/README" file should not exist - Scenario: Use RDiscount for markup - Given I have an "index.markdown" page that contains "[Google](https://www.google.com)" - And I have a configuration file with "markdown" set to "rdiscount" - When I run jekyll build - Then I should get a zero exit status - And the _site directory should exist - And I should see "Google" in "_site/index.html" - Scenario: Use Kramdown for markup Given I have an "index.markdown" page that contains "[Google](https://www.google.com)" And I have a configuration file with "markdown" set to "kramdown" diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index fb51cd5b626..e49eb62bd9d 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -66,10 +66,6 @@ class Configuration < Hash "strict_variables" => false, }, - "rdiscount" => { - "extensions" => [], - }, - "kramdown" => { "auto_ids" => true, "toc_levels" => "1..6", diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 567bc120e36..3c1c3458761 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -30,8 +30,7 @@ def setup # rubocop:disable Naming/AccessorMethodName def get_processor case @config["markdown"].downcase - when "kramdown" then return KramdownParser.new(@config) - when "rdiscount" then return RDiscountParser.new(@config) + when "kramdown" then return KramdownParser.new(@config) else custom_processor end @@ -43,7 +42,7 @@ def get_processor # are not in safe mode.) def valid_processors - %w(rdiscount kramdown) + third_party_processors + %w(kramdown) + third_party_processors end # Public: A list of processors that you provide via plugins. @@ -52,7 +51,7 @@ def valid_processors def third_party_processors self.class.constants - \ - %w(KramdownParser RDiscountParser PRIORITIES).map( + %w(KramdownParser PRIORITIES).map( &:to_sym ) end diff --git a/lib/jekyll/converters/markdown/rdiscount_parser.rb b/lib/jekyll/converters/markdown/rdiscount_parser.rb deleted file mode 100644 index 9da177d4bad..00000000000 --- a/lib/jekyll/converters/markdown/rdiscount_parser.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -module Jekyll - module Converters - class Markdown - class RDiscountParser - def initialize(config) - unless defined?(RDiscount) - Jekyll::External.require_with_graceful_fail "rdiscount" - end - @config = config - @rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym) - end - - def convert(content) - rd = RDiscount.new(content, *@rdiscount_extensions) - html = rd.to_html - if @config["rdiscount"]["toc_token"] - html = replace_generated_toc(rd, html, @config["rdiscount"]["toc_token"]) - end - html - end - - private - def replace_generated_toc(rd_instance, html, toc_token) - if rd_instance.generate_toc && html.include?(toc_token) - utf8_toc = rd_instance.toc_content - utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding) - html.gsub(toc_token, utf8_toc) - else - html - end - end - end - end - end -end diff --git a/test/helper.rb b/test/helper.rb index a3cd6568c94..9e01b7de2e1 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -34,10 +34,6 @@ def jruby? Jekyll.logger = Logger.new(StringIO.new, :error) -unless jruby? - require "rdiscount" -end - require "kramdown" require "shoulda" diff --git a/test/test_rdiscount.rb b/test/test_rdiscount.rb deleted file mode 100644 index 7116c29a238..00000000000 --- a/test/test_rdiscount.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -require "helper" - -class TestRdiscount < JekyllUnitTest - context "rdiscount" do - setup do - if jruby? - then skip( - "JRuby does not perform well with CExt, test disabled." - ) - end - - config = { - "markdown" => "rdiscount", - "rdiscount" => { - "toc_token" => "{:toc}", - "extensions" => %w(smart generate_toc), - }, - } - - @markdown = Converters::Markdown.new config - end - - should "pass rdiscount extensions" do - assert_equal "

“smart”

", @markdown.convert('"smart"').strip - end - - should "render toc" do - toc = <<-TOC - -

Header 1

- - -

Header 2

- -

- -

-TOC - assert_equal toc.strip, - @markdown.convert("# Header 1\n\n## Header 2\n\n{:toc}").strip - end - end -end diff --git a/test/test_tags.rb b/test/test_tags.rb index 739ced21483..54b8e4b7a63 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -494,7 +494,7 @@ def highlight_block_with_opts(options_string) setup do @content = < "rdiscount", - }) - end - - should "parse correctly" do - assert_match %r{FIGHT!}, @result - assert_match %r!FINISH HIM!, @result - end - end - context "using Kramdown" do setup do create_post(@content, "markdown" => "kramdown") From 5d1823b604f1ae220ced957bf327afa4b70e65d6 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 9 May 2018 09:44:38 -0400 Subject: [PATCH 241/337] Update history to reflect merge of #6988 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index c13d624d4ea..5eb713b4748 100644 --- a/History.markdown +++ b/History.markdown @@ -35,6 +35,7 @@ * We are not using Ruby 2.2 anymore (#6977) * Drop support for older versions of Rouge (#6978) * Remove support for Redcarpet (#6987) + * Remove support for rdiscount (#6988) ### Development Fixes From 9343d2e6bb90a496d3a92aa9e035682862b93823 Mon Sep 17 00:00:00 2001 From: penguinpet <34348929+penguinpet@users.noreply.github.com> Date: Thu, 10 May 2018 10:40:54 -0400 Subject: [PATCH 242/337] proposed change for passive voice. (#7005) Merge pull request 7005 --- docs/_docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/contributing.md b/docs/_docs/contributing.md index f1c643d3f71..f42f6f09b7e 100644 --- a/docs/_docs/contributing.md +++ b/docs/_docs/contributing.md @@ -16,7 +16,7 @@ Whether you're a developer, a designer, or just a Jekyll devotee, there are lots * [Install Jekyll on your computer](https://jekyllrb.com/docs/installation/) and kick the tires. Does it work? Does it do what you'd expect? If not, [open an issue](https://github.com/jekyll/jekyll/issues/new) and let us know. * Comment on some of the project's [open issues](https://github.com/jekyll/jekyll/issues). Have you experienced the same problem? Know a work around? Do you have a suggestion for how the feature could be better? -* Read through [the documentation](https://jekyllrb.com/docs/home/), and click the "improve this page" button, any time you see something confusing, or have a suggestion for something that could be improved. +* Read through [the documentation](https://jekyllrb.com/docs/home/), and click the "improve this page" button, any time you see something confusing, or have a suggestion for to improve something. * Browse through [the Jekyll discussion forum](https://talk.jekyllrb.com/), and lend a hand answering questions. There's a good chance you've already experienced what another user is experiencing. * Find [an open issue](https://github.com/jekyll/jekyll/issues) (especially [those labeled `help-wanted`](https://github.com/jekyll/jekyll/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted)), and submit a proposed fix. If it's your first pull request, we promise we won't bite, and are glad to answer any questions. * Help evaluate [open pull requests](https://github.com/jekyll/jekyll/pulls), by testing the changes locally and reviewing what's proposed. From b63036989abe87830fd6cb4fdd9caf53c32a2e09 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 10 May 2018 10:40:55 -0400 Subject: [PATCH 243/337] Update history to reflect merge of #7005 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 5eb713b4748..7d2969008e3 100644 --- a/History.markdown +++ b/History.markdown @@ -18,6 +18,7 @@ * Updated nginx configuration for custom-404-page documentation (#6994) * List all static files variables (#7002) * Document that _drafts need to be contained within the custom collection directory (#6985) + * proposed change for passive voice. (#7005) ### Minor Enhancements From c6000597d9efe3c10e944ecf6e6f7f5bcb690b14 Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Thu, 10 May 2018 18:35:18 +0200 Subject: [PATCH 244/337] Rephrase sentence --- docs/_docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/contributing.md b/docs/_docs/contributing.md index f42f6f09b7e..9eea7282d13 100644 --- a/docs/_docs/contributing.md +++ b/docs/_docs/contributing.md @@ -16,7 +16,7 @@ Whether you're a developer, a designer, or just a Jekyll devotee, there are lots * [Install Jekyll on your computer](https://jekyllrb.com/docs/installation/) and kick the tires. Does it work? Does it do what you'd expect? If not, [open an issue](https://github.com/jekyll/jekyll/issues/new) and let us know. * Comment on some of the project's [open issues](https://github.com/jekyll/jekyll/issues). Have you experienced the same problem? Know a work around? Do you have a suggestion for how the feature could be better? -* Read through [the documentation](https://jekyllrb.com/docs/home/), and click the "improve this page" button, any time you see something confusing, or have a suggestion for to improve something. +* Read through [the documentation](https://jekyllrb.com/docs/home/), and click the "improve this page" button, any time you see something confusing, or have a suggestion on how to improve something. * Browse through [the Jekyll discussion forum](https://talk.jekyllrb.com/), and lend a hand answering questions. There's a good chance you've already experienced what another user is experiencing. * Find [an open issue](https://github.com/jekyll/jekyll/issues) (especially [those labeled `help-wanted`](https://github.com/jekyll/jekyll/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted)), and submit a proposed fix. If it's your first pull request, we promise we won't bite, and are glad to answer any questions. * Help evaluate [open pull requests](https://github.com/jekyll/jekyll/pulls), by testing the changes locally and reviewing what's proposed. From 4f06767ac8fd9402d08411f705a4cb3e93f1fdd7 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 11 May 2018 03:58:39 +0530 Subject: [PATCH 245/337] Load Rouge for TestKramdown (#7007) Merge pull request 7007 --- test/test_kramdown.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index f7b5ea70d47..62b70ddddc4 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "helper" +require "rouge" class TestKramdown < JekyllUnitTest context "kramdown" do From 5a41149b7bc70f9b0ecc8f79af81b8c2afcfdeca Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 10 May 2018 18:28:40 -0400 Subject: [PATCH 246/337] Update history to reflect merge of #7007 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 7d2969008e3..db99bcc3bff 100644 --- a/History.markdown +++ b/History.markdown @@ -44,6 +44,7 @@ * Loggers should accept both numbers and symbols (#6967) * Update instructions for releasing docs Gem (#6975) * yajl-ruby update to v1.4.0 (#6976) + * Load Rouge for TestKramdown (#7007) ## 3.8.1 / 2018-05-01 From df0a5f7b0b520a1512cdbbf272afab6924284325 Mon Sep 17 00:00:00 2001 From: Martin Scharm Date: Mon, 14 May 2018 16:05:22 +0200 Subject: [PATCH 247/337] added the CAT plugin to the plugin list (#7011) Merge pull request 7011 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index ee3da917a75..1c3332e3fb9 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -887,6 +887,7 @@ You can find a few useful plugins at the following locations: - [jekyll-onebox](https://github.com/rriemann/jekyll-onebox): Liquid tag for displaying HTML previews (embeds) for links to popular domains. Plugin is based on [Onebox](https://github.com/discourse/onebox) that powers link previews in [Discourse](http://github.com/discourse/discourse) forums. - [jekyll-w2m](https://github.com/kacperduras/jekyll-w2m): A Jekyll plugin to liberate content from Microsoft Word documents (powered by [word-to-markdown](https://github.com/benbalter/word-to-markdown)). - [jekyll-flickr](https://github.com/rriemann/jekyll-flickr): Liquid tag for responsive Flickr images using HTML5 srcset. Subtitles and automatic license notices are supported. +- [CAT](https://github.com/binfalse/jekyll-cat): Include the contents of any file (like the `include` command, but also for files outside of `_include`). Similar to Unix' `cat` tool; useful for including source code etc. in posts and pages. #### Collections From 62d297d4a0bf231f22d2145ff7ee84ce2d9f4488 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 14 May 2018 10:05:24 -0400 Subject: [PATCH 248/337] Update history to reflect merge of #7011 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index db99bcc3bff..6b47fbd9c3b 100644 --- a/History.markdown +++ b/History.markdown @@ -19,6 +19,7 @@ * List all static files variables (#7002) * Document that _drafts need to be contained within the custom collection directory (#6985) * proposed change for passive voice. (#7005) + * added the CAT plugin to the plugin list (#7011) ### Minor Enhancements From fbaf591c12eab3109d8b739945b75d0c393c922d Mon Sep 17 00:00:00 2001 From: Nikita Skalkin Date: Tue, 15 May 2018 22:37:05 +0300 Subject: [PATCH 249/337] Update rubocop version (#7016) Merge pull request 7016 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 08ab18af225..ce43b6798f9 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 0.55.0" + gem "rubocop", "~> 0.56.0" 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__) From 3bf940b7eea7c025323237fd109ee91a9b9c346f Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Tue, 15 May 2018 15:37:08 -0400 Subject: [PATCH 250/337] Update history to reflect merge of #7016 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 6b47fbd9c3b..0a51d4a62d6 100644 --- a/History.markdown +++ b/History.markdown @@ -46,6 +46,7 @@ * Update instructions for releasing docs Gem (#6975) * yajl-ruby update to v1.4.0 (#6976) * Load Rouge for TestKramdown (#7007) + * Update rubocop version (#7016) ## 3.8.1 / 2018-05-01 From b915c7577b7f2f68c4b82474f49062f700855082 Mon Sep 17 00:00:00 2001 From: Kyle Barbour Date: Thu, 17 May 2018 15:22:32 -0700 Subject: [PATCH 251/337] Add whitespace control to LIQUID_TAG_REGEX (#7015) Merge pull request 7015 --- lib/jekyll/excerpt.rb | 9 +++- ...liquid-block-excerpt-whitespace-control.md | 9 ++++ ...-15-excerpt-whitespace-control-variable.md | 7 +++ ...liquid-block-excerpt-whitespace-control.md | 10 ++++ test/test_excerpt.rb | 52 +++++++++++++++++++ test/test_generated_site.rb | 2 +- 6 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md create mode 100644 test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md create mode 100644 test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 18d456ea847..41bcb18a58a 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -128,7 +128,7 @@ def render_with_liquid? # # Returns excerpt String - LIQUID_TAG_REGEX = %r!{%\s*(\w+).+\s*%}!m + LIQUID_TAG_REGEX = %r!{%-?\s*(\w+).+\s*-?%}!m MKDWN_LINK_REF_REGEX = %r!^ {0,3}\[[^\]]+\]:.+$! def extract_excerpt(doc_content) @@ -141,7 +141,7 @@ def extract_excerpt(doc_content) head =~ LIQUID_TAG_REGEX tag_name = Regexp.last_match(1) - if liquid_block?(tag_name) && head.match(%r!{%\s*end#{tag_name}\s*%}!).nil? + if liquid_block?(tag_name) && head.match(%r!{%-?\s*end#{tag_name}\s*-?%}!).nil? print_build_warning head << "\n{% end#{tag_name} %}" end @@ -158,6 +158,11 @@ def extract_excerpt(doc_content) def liquid_block?(tag_name) Liquid::Template.tags[tag_name].superclass == Liquid::Block + rescue NoMethodError + Jekyll.logger.error "Error:", + "A Liquid tag in the excerpt of #{doc.relative_path} couldn't be " \ + "parsed." + raise end def print_build_warning diff --git a/test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md b/test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md new file mode 100644 index 00000000000..c43559244df --- /dev/null +++ b/test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md @@ -0,0 +1,9 @@ +--- +title: LIQUID_TAG_REGEX excerpt whitespace control test +layout: post +--- + +{%- for post in site.posts -%} + You are in a maze of twisty little passages, all alike. + There's lots more to say about this, but that's enough for now. +{%- endfor -%} diff --git a/test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md b/test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md new file mode 100644 index 00000000000..aad1207a355 --- /dev/null +++ b/test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md @@ -0,0 +1,7 @@ +--- +title: LIQUID_TAG_REGEX excerpt whitespace control test +layout: post +--- + +{%- assign xyzzy = 'You are in a maze of twisty little passages, all alike.' %} +{{- xyzzy -}} diff --git a/test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md b/test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md new file mode 100644 index 00000000000..4ed799585d3 --- /dev/null +++ b/test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md @@ -0,0 +1,10 @@ +--- +title: LIQUID_TAG_REGEX excerpt whitespace control test +layout: post +--- + +{%- for post in site.posts -%} + You are in a maze of twisty little passages, all alike. + + There's lots more to say about this, but that's enough for now. +{%- endfor -%} diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index c4b4538d2ee..24647decada 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -212,4 +212,56 @@ def do_render(document) assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) end end + + context "An excerpt with non-closed but valid Liquid block tag with whitespace control" do + setup do + clear_dest + @site = fixture_site + @post = setup_post("2018-05-15-open-liquid-block-excerpt-whitespace-control.md") + @excerpt = @post.data["excerpt"] + + assert_includes @post.content, "{%- for" + refute_includes @post.content.split("\n\n")[0], "{%- endfor -%}" + end + + should "be appended to as necessary and generated" do + assert_includes @excerpt.content, "{% endfor %}" + refute_includes @excerpt.content, "{% endfor %}\n\n{% endfor %}" + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + end + + context "An excerpt with valid closed Liquid block tag with whitespace control" do + setup do + clear_dest + @site = fixture_site + @post = setup_post("2018-05-15-closed-liquid-block-excerpt-whitespace-control.md") + @excerpt = @post.data["excerpt"] + + assert_includes @post.content, "{%- for" + assert_includes @post.content.split("\n\n")[0], "{%- endfor -%}" + end + + should "not be appended to but generated as is" do + assert_includes @excerpt.content, "{%- endfor -%}" + refute_includes @excerpt.content, "{% endfor %}\n\n{% endfor %}" + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + end + + context "An excerpt with valid Liquid variable with whitespace control" do + setup do + clear_dest + @site = fixture_site + @post = setup_post("2018-05-15-excerpt-whitespace-control-variable.md") + @excerpt = @post.data["excerpt"] + + assert_includes @post.content, "{%- assign" + end + + should "not be appended to but generated as is" do + assert_includes @excerpt.content, "{{- xyzzy -}}" + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + end end diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 4eaddb29f37..7ce093536ff 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -16,7 +16,7 @@ class TestGeneratedSite < JekyllUnitTest end should "ensure post count is as expected" do - assert_equal 54, @site.posts.size + assert_equal 57, @site.posts.size end should "insert site.posts into the index" do From aed72f6464f675c4426324123ee81e94dab3de43 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 17 May 2018 18:22:33 -0400 Subject: [PATCH 252/337] Update history to reflect merge of #7015 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index 0a51d4a62d6..9d1b7c80791 100644 --- a/History.markdown +++ b/History.markdown @@ -48,6 +48,10 @@ * Load Rouge for TestKramdown (#7007) * Update rubocop version (#7016) +### Bug Fixes + + * Add whitespace control to LIQUID_TAG_REGEX (#7015) + ## 3.8.1 / 2018-05-01 ### Bug Fixes From 74581422e3dbdf754ee519386d59db4e3c73f28f Mon Sep 17 00:00:00 2001 From: Kyle Barbour Date: Thu, 17 May 2018 15:22:32 -0700 Subject: [PATCH 253/337] Add whitespace control to LIQUID_TAG_REGEX (#7015) Merge pull request 7015 --- lib/jekyll/excerpt.rb | 9 +++- ...liquid-block-excerpt-whitespace-control.md | 9 ++++ ...-15-excerpt-whitespace-control-variable.md | 7 +++ ...liquid-block-excerpt-whitespace-control.md | 10 ++++ test/test_excerpt.rb | 52 +++++++++++++++++++ test/test_generated_site.rb | 2 +- 6 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md create mode 100644 test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md create mode 100644 test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index d270624c062..1df15e09a53 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -128,7 +128,7 @@ def render_with_liquid? # # Returns excerpt String - LIQUID_TAG_REGEX = %r!{%\s*(\w+).+\s*%}!m + LIQUID_TAG_REGEX = %r!{%-?\s*(\w+).+\s*-?%}!m MKDWN_LINK_REF_REGEX = %r!^ {0,3}\[[^\]]+\]:.+$! def extract_excerpt(doc_content) @@ -141,7 +141,7 @@ def extract_excerpt(doc_content) head =~ LIQUID_TAG_REGEX tag_name = Regexp.last_match(1) - if liquid_block?(tag_name) && head.match(%r!{%\s*end#{tag_name}\s*%}!).nil? + if liquid_block?(tag_name) && head.match(%r!{%-?\s*end#{tag_name}\s*-?%}!).nil? print_build_warning head << "\n{% end#{tag_name} %}" end @@ -158,6 +158,11 @@ def extract_excerpt(doc_content) def liquid_block?(tag_name) Liquid::Template.tags[tag_name].superclass == Liquid::Block + rescue NoMethodError + Jekyll.logger.error "Error:", + "A Liquid tag in the excerpt of #{doc.relative_path} couldn't be " \ + "parsed." + raise end def print_build_warning diff --git a/test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md b/test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md new file mode 100644 index 00000000000..c43559244df --- /dev/null +++ b/test/source/_posts/2018-05-15-closed-liquid-block-excerpt-whitespace-control.md @@ -0,0 +1,9 @@ +--- +title: LIQUID_TAG_REGEX excerpt whitespace control test +layout: post +--- + +{%- for post in site.posts -%} + You are in a maze of twisty little passages, all alike. + There's lots more to say about this, but that's enough for now. +{%- endfor -%} diff --git a/test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md b/test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md new file mode 100644 index 00000000000..aad1207a355 --- /dev/null +++ b/test/source/_posts/2018-05-15-excerpt-whitespace-control-variable.md @@ -0,0 +1,7 @@ +--- +title: LIQUID_TAG_REGEX excerpt whitespace control test +layout: post +--- + +{%- assign xyzzy = 'You are in a maze of twisty little passages, all alike.' %} +{{- xyzzy -}} diff --git a/test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md b/test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md new file mode 100644 index 00000000000..4ed799585d3 --- /dev/null +++ b/test/source/_posts/2018-05-15-open-liquid-block-excerpt-whitespace-control.md @@ -0,0 +1,10 @@ +--- +title: LIQUID_TAG_REGEX excerpt whitespace control test +layout: post +--- + +{%- for post in site.posts -%} + You are in a maze of twisty little passages, all alike. + + There's lots more to say about this, but that's enough for now. +{%- endfor -%} diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index c4b4538d2ee..24647decada 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -212,4 +212,56 @@ def do_render(document) assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) end end + + context "An excerpt with non-closed but valid Liquid block tag with whitespace control" do + setup do + clear_dest + @site = fixture_site + @post = setup_post("2018-05-15-open-liquid-block-excerpt-whitespace-control.md") + @excerpt = @post.data["excerpt"] + + assert_includes @post.content, "{%- for" + refute_includes @post.content.split("\n\n")[0], "{%- endfor -%}" + end + + should "be appended to as necessary and generated" do + assert_includes @excerpt.content, "{% endfor %}" + refute_includes @excerpt.content, "{% endfor %}\n\n{% endfor %}" + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + end + + context "An excerpt with valid closed Liquid block tag with whitespace control" do + setup do + clear_dest + @site = fixture_site + @post = setup_post("2018-05-15-closed-liquid-block-excerpt-whitespace-control.md") + @excerpt = @post.data["excerpt"] + + assert_includes @post.content, "{%- for" + assert_includes @post.content.split("\n\n")[0], "{%- endfor -%}" + end + + should "not be appended to but generated as is" do + assert_includes @excerpt.content, "{%- endfor -%}" + refute_includes @excerpt.content, "{% endfor %}\n\n{% endfor %}" + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + end + + context "An excerpt with valid Liquid variable with whitespace control" do + setup do + clear_dest + @site = fixture_site + @post = setup_post("2018-05-15-excerpt-whitespace-control-variable.md") + @excerpt = @post.data["excerpt"] + + assert_includes @post.content, "{%- assign" + end + + should "not be appended to but generated as is" do + assert_includes @excerpt.content, "{{- xyzzy -}}" + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + end end diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 4eaddb29f37..7ce093536ff 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -16,7 +16,7 @@ class TestGeneratedSite < JekyllUnitTest end should "ensure post count is as expected" do - assert_equal 54, @site.posts.size + assert_equal 57, @site.posts.size end should "insert site.posts into the index" do From b18872b658528b725825fd2911e84468bbd21908 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 17 May 2018 18:22:33 -0400 Subject: [PATCH 254/337] Update history to reflect merge of #7015 [ci skip] --- History.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/History.markdown b/History.markdown index 5cef9fef342..1333ff194a3 100644 --- a/History.markdown +++ b/History.markdown @@ -1,3 +1,9 @@ +## HEAD + +### Bug Fixes + + * Add whitespace control to LIQUID_TAG_REGEX (#7015) + ## 3.8.1 / 2018-05-01 ### Bug Fixes From 450da91b4b0c0f25868f6492cbc0c3db257dba90 Mon Sep 17 00:00:00 2001 From: Nikita Skalkin Date: Tue, 15 May 2018 22:37:05 +0300 Subject: [PATCH 255/337] Update rubocop version (#7016) Merge pull request 7016 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c20ea23406d..af7e21902a0 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ group :test do gem "nokogiri", RUBY_VERSION >= "2.2" ? "~> 1.7" : "~> 1.7.0" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 0.55.0" + gem "rubocop", "~> 0.56.0" 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__) From b89efa5d5d6a5f7284bf91370a8e759b99d17b5c Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Tue, 15 May 2018 15:37:08 -0400 Subject: [PATCH 256/337] Update history to reflect merge of #7016 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index 1333ff194a3..6ddf11c3364 100644 --- a/History.markdown +++ b/History.markdown @@ -1,5 +1,9 @@ ## HEAD +### Development Fixes + + * Update rubocop version (#7016) + ### Bug Fixes * Add whitespace control to LIQUID_TAG_REGEX (#7015) From d22b8ee3920c28a1a540462d931896eaf695f33c Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Sat, 19 May 2018 10:30:00 -0500 Subject: [PATCH 257/337] Release :gem: 3.8.2 --- History.markdown | 2 +- docs/_config.yml | 2 +- docs/_docs/history.md | 14 ++++++++++++++ .../2018-05-18-jekyll-3-8-2-released.markdown | 19 +++++++++++++++++++ docs/latest_version.txt | 2 +- lib/jekyll/version.rb | 2 +- 6 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 docs/_posts/2018-05-18-jekyll-3-8-2-released.markdown diff --git a/History.markdown b/History.markdown index 6ddf11c3364..64f743f5a32 100644 --- a/History.markdown +++ b/History.markdown @@ -1,4 +1,4 @@ -## HEAD +## 3.8.2 / 2018-05-18 ### Development Fixes diff --git a/docs/_config.yml b/docs/_config.yml index 4084cdd6700..e608b1b6e8d 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,5 +1,5 @@ --- -version: 3.8.1 +version: 3.8.2 name: Jekyll • Simple, blog-aware, static sites description: Transform your plain text into static websites and blogs url: https://jekyllrb.com diff --git a/docs/_docs/history.md b/docs/_docs/history.md index e30472b2c42..4a9faf7f29a 100644 --- a/docs/_docs/history.md +++ b/docs/_docs/history.md @@ -4,6 +4,20 @@ permalink: "/docs/history/" note: This file is autogenerated. Edit /History.markdown instead. --- +## 3.8.2 / 2018-05-18 +{: #v3-8-2} + +### Development Fixes +{: #development-fixes-v3-8-2} + +- Update rubocop version ([#7016]({{ site.repository }}/issues/7016)) + +### Bug Fixes +{: #bug-fixes-v3-8-2} + +- Add whitespace control to LIQUID_TAG_REGEX ([#7015]({{ site.repository }}/issues/7015)) + + ## 3.8.1 / 2018-05-01 {: #v3-8-1} diff --git a/docs/_posts/2018-05-18-jekyll-3-8-2-released.markdown b/docs/_posts/2018-05-18-jekyll-3-8-2-released.markdown new file mode 100644 index 00000000000..7d964e8602a --- /dev/null +++ b/docs/_posts/2018-05-18-jekyll-3-8-2-released.markdown @@ -0,0 +1,19 @@ +--- +title: 'Jekyll 3.8.2 Released' +date: 2018-05-19 10:30:00 -0500 +author: pathawks +version: 3.8.2 +categories: [release] +--- + +Hello Jekyllers!! + +Today we are releasing `v3.8.2`, which fixes the way Jekyll generates excerpts +for posts when the first paragraph of the post contains Liquid tags that take +advantage of [Liquid's whitespace control feature][Liquid whitespace]. + +Big thanks to @kylebarbour, who first reported this issue and also very quickly +submitted a fix. Also thanks to @nickskalkin for making sure that we are using +the latest version of Rubocop to lint our code. + +[Liquid whitespace]: https://shopify.github.io/liquid/basics/whitespace/ diff --git a/docs/latest_version.txt b/docs/latest_version.txt index f2807196747..a08ffae0cae 100644 --- a/docs/latest_version.txt +++ b/docs/latest_version.txt @@ -1 +1 @@ -3.8.1 +3.8.2 diff --git a/lib/jekyll/version.rb b/lib/jekyll/version.rb index f958b6af05d..0a6a8a2d3d7 100644 --- a/lib/jekyll/version.rb +++ b/lib/jekyll/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Jekyll - VERSION = "3.8.1".freeze + VERSION = "3.8.2".freeze end From bc8460301724fd502a0c3143fe574cea3da41e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Sat, 19 May 2018 21:49:54 +0200 Subject: [PATCH 258/337] Useless privates removed (#6768) Merge pull request 6768 --- .rubocop.yml | 2 -- lib/jekyll/collection.rb | 4 --- lib/jekyll/commands/serve.rb | 33 +------------------ .../commands/serve/live_reload_reactor.rb | 4 +-- lib/jekyll/commands/serve/servlet.rb | 6 +--- lib/jekyll/configuration.rb | 9 +---- lib/jekyll/converters/markdown.rb | 3 +- .../converters/markdown/kramdown_parser.rb | 6 +--- lib/jekyll/document.rb | 9 +---- lib/jekyll/filters.rb | 3 -- lib/jekyll/filters/date_filters.rb | 2 -- lib/jekyll/filters/grouping_filters.rb | 3 +- lib/jekyll/regenerator.rb | 3 -- lib/jekyll/renderer.rb | 13 ++------ lib/jekyll/site.rb | 11 ++----- lib/jekyll/utils.rb | 4 +-- lib/jekyll/utils/internet.rb | 2 -- 17 files changed, 13 insertions(+), 104 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f94395cd496..ce750ace645 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,8 +57,6 @@ Lint/UnneededRequireStatement: Enabled: false Lint/UnreachableCode: Severity: error -Lint/UselessAccessModifier: - Enabled: false Lint/Void: Enabled: false Metrics/AbcSize: diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index bdfa4b8674f..5f2aa12aadc 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -207,16 +207,12 @@ def container @container ||= site.config["collections_dir"] end - private - def read_document(full_path) doc = Document.new(full_path, :site => site, :collection => self) doc.read docs << doc unless doc.data["published"] == false end - private - def read_static_file(file_path, full_path) relative_dir = Jekyll.sanitized_path( relative_directory, diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index efdaea67cf0..9b8417cdd5a 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -103,6 +103,7 @@ def shutdown # Perform logical validation of CLI options private + def validate_options(opts) if opts["livereload"] if opts["detach"] @@ -131,9 +132,6 @@ def validate_options(opts) end end - # - - private # rubocop:disable Metrics/AbcSize def register_reload_hooks(opts) require_relative "serve/live_reload_reactor" @@ -171,7 +169,6 @@ def register_reload_hooks(opts) # when we get ready to party, checking for an setting up an error page # and making sure our destination exists. - private def setup(destination) require_relative "serve/servlet" @@ -186,9 +183,6 @@ def create_error_page end end - # - - private def webrick_opts(opts) opts = { :JekyllOptions => opts, @@ -209,9 +203,6 @@ def webrick_opts(opts) opts end - # - - private def start_up_webrick(opts, destination) if opts["livereload"] @reload_reactor.start(opts) @@ -226,8 +217,6 @@ def start_up_webrick(opts, destination) end # Recreate NondisclosureName under utf-8 circumstance - - private def file_handler_opts WEBrick::Config::FileHandler.merge({ :FancyIndexing => true, @@ -237,9 +226,6 @@ def file_handler_opts }) end - # - - private def server_address(server, options = {}) format_url( server.config[:SSLEnable], @@ -249,7 +235,6 @@ def server_address(server, options = {}) ) end - private def format_url(ssl_enabled, address, port, baseurl = nil) format("%s://%
s:%i%s", { :prefix => ssl_enabled ? "https" : "http", @@ -259,9 +244,6 @@ def format_url(ssl_enabled, address, port, baseurl = nil) }) end - # - - private def default_url(opts) config = configuration_from_options(opts) format_url( @@ -271,9 +253,6 @@ def default_url(opts) ) end - # - - private def launch_browser(server, opts) address = server_address(server, opts) return system "start", address if Utils::Platforms.windows? @@ -286,8 +265,6 @@ def launch_browser(server, opts) # Keep in our area with a thread or detach the server as requested # by the user. This method determines what we do based on what you # ask us to do. - - private def boot_or_detach(server, opts) if opts["detach"] pid = Process.fork do @@ -305,8 +282,6 @@ def boot_or_detach(server, opts) end # Make the stack verbose if the user requests it. - - private def enable_logging(opts) opts[:AccessLog] = [] level = WEBrick::Log.const_get(opts[:JekyllOptions]["verbose"] ? :DEBUG : :WARN) @@ -316,8 +291,6 @@ def enable_logging(opts) # Add SSL to the stack if the user triggers --enable-ssl and they # provide both types of certificates commonly needed. Raise if they # forget to add one of the certificates. - - private def enable_ssl(opts) cert, key, src = opts[:JekyllOptions].values_at("ssl_cert", "ssl_key", "source") @@ -333,7 +306,6 @@ def enable_ssl(opts) opts[:SSLEnable] = true end - private def start_callback(detached) unless detached proc do @@ -348,7 +320,6 @@ def start_callback(detached) end end - private def stop_callback(detached) unless detached proc do @@ -364,13 +335,11 @@ def stop_callback(detached) end end - private def mime_types file = File.expand_path("../mime.types", __dir__) WEBrick::HTTPUtils.load_mime_types(file) end - private def read_file(source_dir, file_path) File.read(Jekyll.sanitized_path(source_dir, file_path)) end diff --git a/lib/jekyll/commands/serve/live_reload_reactor.rb b/lib/jekyll/commands/serve/live_reload_reactor.rb index 5f3a4877cce..eeafa236e72 100644 --- a/lib/jekyll/commands/serve/live_reload_reactor.rb +++ b/lib/jekyll/commands/serve/live_reload_reactor.rb @@ -81,6 +81,7 @@ def reload(pages) end private + def connect(websocket, handshake) @connections_count += 1 if @connections_count == 1 @@ -99,12 +100,10 @@ def connect(websocket, handshake) @websockets << websocket end - private def disconnect(websocket) @websockets.delete(websocket) end - private def print_message(json_message) msg = JSON.parse(json_message) # Not sure what the 'url' command even does in LiveReload. The spec is silent @@ -114,7 +113,6 @@ def print_message(json_message) end end - private def log_error(error) Jekyll.logger.error "LiveReload experienced an error. " \ "Run with --trace for more information." diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index 567ec313cbe..3b05bf87fe1 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -178,9 +178,8 @@ def do_GET(req, res) end # rubocop:enable Naming/MethodName - # - private + def validate_and_ensure_charset(_req, res) key = res.header.keys.grep(%r!content-type!i).first typ = res.header[key] @@ -190,9 +189,6 @@ def validate_and_ensure_charset(_req, res) end end - # - - private def set_defaults hash_ = @jekyll_opts.fetch("webrick", {}).fetch("headers", {}) DEFAULTS.each_with_object(@headers = hash_) do |(key, val), hash| diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index e49eb62bd9d..cf7fea55397 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -278,6 +278,7 @@ def renamed_key(old, new, config, _ = nil) end private + def style_to_permalink(permalink_style) case permalink_style.to_sym when :pretty @@ -299,14 +300,12 @@ def style_to_permalink(permalink_style) # file - the file from which the config was extracted # # Raises an ArgumentError if given config is not a hash - private def check_config_is_hash!(extracted_config, file) unless extracted_config.is_a?(Hash) raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow end end - private def check_auto(config) if config.key?("auto") || config.key?("watch") Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \ @@ -317,7 +316,6 @@ def check_auto(config) end end - private def check_server(config) if config.key?("server") Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \ @@ -327,7 +325,6 @@ def check_server(config) end end - private def check_pygments(config) if config.key?("pygments") Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \ @@ -340,7 +337,6 @@ def check_pygments(config) end end - private def check_include_exclude(config) %w(include exclude).each do |option| if config[option].is_a?(String) @@ -354,7 +350,6 @@ def check_include_exclude(config) end end - private def check_coderay(config) if (config["kramdown"] || {}).key?("use_coderay") Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \ @@ -363,7 +358,6 @@ def check_coderay(config) end end - private def check_maruku(config) if config.fetch("markdown", "kramdown").to_s.casecmp("maruku").zero? Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \ @@ -380,7 +374,6 @@ def check_maruku(config) # # Raises a Jekyll::Errors::InvalidConfigurationError if the config `plugins` # is a string - private def check_plugins(config) if config.key?("plugins") && config["plugins"].is_a?(String) Jekyll.logger.error "Configuration Error:", "You specified the" \ diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 3c1c3458761..220bc3820d4 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -76,6 +76,7 @@ def convert(content) end private + def custom_processor converter_name = @config["markdown"] if custom_class_allowed?(converter_name) @@ -90,8 +91,6 @@ def custom_processor # # Returns true if the parser name contains only alphanumeric # characters and is defined within Jekyll::Converters::Markdown - - private def custom_class_allowed?(parser_name) parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?( parser_name.to_sym diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index b7caab551d4..cdae8664a3f 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -47,6 +47,7 @@ def convert(content) end private + def make_accessible(hash = @config) hash.keys.each do |key| hash[key.to_sym] = hash[key] @@ -59,8 +60,6 @@ def make_accessible(hash = @config) # config[highlighter] # Where `enable_coderay` is now deprecated because Kramdown # supports Rouge now too. - - private def highlighter return @highlighter if @highlighter @@ -84,7 +83,6 @@ def highlighter end end - private def strip_coderay_prefix(hash) hash.each_with_object({}) do |(key, val), hsh| cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "") @@ -102,8 +100,6 @@ def strip_coderay_prefix(hash) # If our highlighter is CodeRay we go in to merge the CodeRay defaults # with your "coderay" key if it's there, deprecating it in the # process of you using it. - - private def modernize_coderay_config unless @config["coderay"].empty? Jekyll::Deprecator.deprecation_message( diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 061839f13b5..a4f989b88c6 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -416,6 +416,7 @@ def populate_tags end private + def merge_categories!(other) if other.key?("categories") && !other["categories"].nil? if other["categories"].is_a?(String) @@ -425,7 +426,6 @@ def merge_categories!(other) end end - private def merge_date!(source) if data.key?("date") data["date"] = Utils.parse_date( @@ -435,7 +435,6 @@ def merge_date!(source) end end - private def merge_defaults defaults = @site.frontmatter_defaults.all( relative_path, @@ -444,7 +443,6 @@ def merge_defaults merge_data!(defaults, :source => "front matter defaults") unless defaults.empty? end - private def read_content(opts) self.content = File.read(path, Utils.merged_file_read_opts(site, opts)) if content =~ YAML_FRONT_MATTER_REGEXP @@ -454,7 +452,6 @@ def read_content(opts) end end - private def read_post_data populate_title populate_categories @@ -462,7 +459,6 @@ def read_post_data generate_excerpt end - private def handle_read_error(error) if error.is_a? Psych::SyntaxError Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}" @@ -475,7 +471,6 @@ def handle_read_error(error) end end - private def populate_title if relative_path =~ DATE_FILENAME_MATCHER date, slug, ext = Regexp.last_match.captures @@ -491,14 +486,12 @@ def populate_title data["ext"] ||= ext end - private def modify_date(date) if !data["date"] || data["date"].to_i == site.time.to_i merge_data!({ "date" => date }, :source => "filename") end end - private def generate_excerpt if generate_excerpt? data["excerpt"] ||= Jekyll::Excerpt.new(self) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 209a3e0e331..1708d5fa9f3 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -316,7 +316,6 @@ def sort_input(input, property, order) .map!(&:last) end - private def item_property(item, property) if item.respond_to?(:to_liquid) property.to_s.split(".").reduce(item.to_liquid) do |subvalue, attribute| @@ -329,7 +328,6 @@ def item_property(item, property) end end - private def as_liquid(item) case item when Hash @@ -353,7 +351,6 @@ def as_liquid(item) end # Parse a string to a Liquid Condition - private def parse_condition(exp) parser = Liquid::Parser.new(exp) left_expr = parser.expression diff --git a/lib/jekyll/filters/date_filters.rb b/lib/jekyll/filters/date_filters.rb index 40028c88c77..7bdf0fffd1b 100644 --- a/lib/jekyll/filters/date_filters.rb +++ b/lib/jekyll/filters/date_filters.rb @@ -81,7 +81,6 @@ def stringify_date(date, month_type, type = nil, style = nil) time.strftime("%d #{month_type} %Y") end - private def ordinal(number) return "th" if (11..13).cover?(number) @@ -93,7 +92,6 @@ def ordinal(number) end end - private def time(input) date = Liquid::Utils.to_date(input) unless date.respond_to?(:to_time) diff --git a/lib/jekyll/filters/grouping_filters.rb b/lib/jekyll/filters/grouping_filters.rb index 4086bbe9854..c9cdc6544cc 100644 --- a/lib/jekyll/filters/grouping_filters.rb +++ b/lib/jekyll/filters/grouping_filters.rb @@ -41,16 +41,15 @@ def group_by_exp(input, variable, expression) end private + def parse_expression(str) Liquid::Variable.new(str, Liquid::ParseContext.new) end - private def groupable?(element) element.respond_to?(:group_by) end - private def grouped_array(groups) groups.each_with_object([]) do |item, array| array << { diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 178cb1a90c6..864bb0c8072 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -165,7 +165,6 @@ def read_metadata end end - private def regenerate_page?(document) document.asset_file? || document.data["regenerate"] || source_modified_or_dest_missing?( @@ -173,7 +172,6 @@ def regenerate_page?(document) ) end - private def regenerate_document?(document) !document.write? || document.data["regenerate"] || source_modified_or_dest_missing?( @@ -181,7 +179,6 @@ def regenerate_document?(document) ) end - private def existing_file_modified?(path) # If one of this file dependencies have been modified, # set the regeneration bit for both the dependency and the file to true diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 9c47b2568e1..acd9a4ee426 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -166,11 +166,12 @@ def place_in_layouts(content, payload, info) output end + private + # Checks if the layout specified in the document actually exists # # layout - the layout to check # Returns nothing - private def validate_layout(layout) if invalid_layout?(layout) Jekyll.logger.warn( @@ -187,7 +188,6 @@ def validate_layout(layout) # Render layout content into document.output # # Returns String rendered content - private def render_layout(output, layout, info) payload["content"] = output payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) @@ -200,7 +200,6 @@ def render_layout(output, layout, info) ) end - private def add_regenerator_dependencies(layout) return unless document.write? site.regenerator.add_dependency( @@ -212,7 +211,6 @@ def add_regenerator_dependencies(layout) # Set page content to payload and assign pager if document has one. # # Returns nothing - private def assign_pages! payload["page"] = document.to_liquid payload["paginator"] = if document.respond_to?(:pager) @@ -223,7 +221,6 @@ def assign_pages! # Set related posts to payload if document is a post. # # Returns nothing - private def assign_current_document! payload["site"].current_document = document end @@ -231,13 +228,11 @@ def assign_current_document! # Set highlighter prefix and suffix # # Returns nothing - private def assign_highlighter_options! payload["highlighter_prefix"] = converters.first.highlighter_prefix payload["highlighter_suffix"] = converters.first.highlighter_suffix end - private def assign_layout_data! layout = layouts[document.data["layout"]] if layout @@ -245,7 +240,6 @@ def assign_layout_data! end end - private def permalink_ext document_permalink = document.permalink if document_permalink && !document_permalink.end_with?("/") @@ -254,7 +248,6 @@ def permalink_ext end end - private def converter_output_ext if output_exts.size == 1 output_exts.last @@ -263,14 +256,12 @@ def converter_output_ext end end - private def output_exts @output_exts ||= converters.map do |c| c.output_ext(document.extname) end.compact end - private def liquid_options @liquid_options ||= site.config["liquid"] end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 25257a64c0d..6264c102bba 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -403,10 +403,11 @@ def collections_path @collections_path ||= dir_str.empty? ? source : in_source_dir(dir_str) end + private + # Limits the current posts; removes the posts which exceed the limit_posts # # Returns nothing - private def limit_posts! if limit_posts > 0 limit = posts.docs.length < limit_posts ? posts.docs.length : limit_posts @@ -418,18 +419,15 @@ def limit_posts! # already exist. # # Returns The Cleaner - private def site_cleaner @site_cleaner ||= Cleaner.new(self) end - private def configure_plugins self.plugin_manager = Jekyll::PluginManager.new(self) self.plugins = plugin_manager.plugins_path end - private def configure_theme self.theme = nil return if config["theme"].nil? @@ -444,20 +442,17 @@ def configure_theme end end - private def configure_include_paths @includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s)) @includes_load_paths << theme.includes_path if theme && theme.includes_path end - private def configure_file_read_opts self.file_read_opts = {} self.file_read_opts[:encoding] = config["encoding"] if config["encoding"] self.file_read_opts = Jekyll::Utils.merged_file_read_opts(self, {}) end - private def render_docs(payload) collections.each_value do |collection| collection.docs.each do |document| @@ -466,14 +461,12 @@ def render_docs(payload) end end - private def render_pages(payload) pages.flatten.each do |page| render_regenerated(page, payload) end end - private def render_regenerated(document, payload) return unless regenerator.regenerate?(document) document.output = Jekyll::Renderer.new(self, document, payload).run diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index e17a4cdc1bd..f52a62ff439 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -313,6 +313,7 @@ def merged_file_read_opts(site, opts) end private + def merge_values(target, overwrite) target.merge!(overwrite) do |_key, old_val, new_val| if new_val.nil? @@ -325,14 +326,12 @@ def merge_values(target, overwrite) end end - private def merge_default_proc(target, overwrite) if target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil? target.default_proc = overwrite.default_proc end end - private def duplicate_frozen_values(target) target.each do |key, val| target[key] = val.dup if val.frozen? && duplicable?(val) @@ -343,7 +342,6 @@ def duplicate_frozen_values(target) # # See Utils#slugify for a description of the character sequence specified # by each mode. - private def replace_character_sequence_with_hyphen(string, mode: "default") replaceable_char = case mode diff --git a/lib/jekyll/utils/internet.rb b/lib/jekyll/utils/internet.rb index f895596c548..f723469b49a 100644 --- a/lib/jekyll/utils/internet.rb +++ b/lib/jekyll/utils/internet.rb @@ -23,8 +23,6 @@ def connected? !dns("example.com").nil? end - private - module_function def dns(domain) require "resolv" Resolv::DNS.open do |resolver| From 9968df06b3fb61dc356c0f0488a604b03df6e6ec Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 19 May 2018 15:49:56 -0400 Subject: [PATCH 259/337] Update history to reflect merge of #6768 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 4eb0cac7bc5..2bd80e6545b 100644 --- a/History.markdown +++ b/History.markdown @@ -46,6 +46,7 @@ * Update instructions for releasing docs Gem (#6975) * yajl-ruby update to v1.4.0 (#6976) * Load Rouge for TestKramdown (#7007) + * Useless privates removed (#6768) ## 3.8.2 / 2018-05-18 From 9aec161550dcf48ebb816a9998c03b4e8c12c9ae Mon Sep 17 00:00:00 2001 From: Philip Belesky Date: Mon, 21 May 2018 02:30:15 +1000 Subject: [PATCH 260/337] Fix --unpublished not affecting collection documents (#7027) Merge pull request 7027 --- features/collections.feature | 98 ++++++++++++++++++++++++++++++++++++ lib/jekyll/collection.rb | 4 +- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/features/collections.feature b/features/collections.feature index 33a01ade6ed..03f10dc1e6f 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -263,6 +263,104 @@ Feature: Collections And the "_site/puppies/snowy.html" file should not exist And the "_site/puppies/hardy.html" file should not exist + Scenario: Access rendered collection with future date and unpublished flag via Liquid + Given I have a _puppies directory + And I have the following documents under the puppies collection: + | title | date | content | published | + | Rover | 2007-12-31 | content for Rover. | true | + | Figor | 2007-12-31 | content for Figor. | false | + | Snowy | 2199-12-31 | content for Snowy. | true | + | Hardy | 2199-12-31 | content for Hardy. | false | + And I have a "_config.yml" file with content: + """ + collections: + puppies: + output: true + """ + And I have a "index.md" page that contains "{% for puppy in site.puppies %}
{{ puppy.title }}
{% endfor %}" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + But I should see "
Snowy
" in "_site/index.html" + And I should not see "
Figor
" in "_site/index.html" + And I should not see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished --future + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should exist + And the "_site/puppies/snowy.html" file should exist + And the "_site/puppies/figor.html" file should exist + And the "_site/puppies/hardy.html" file should exist + + Scenario: Access unrendered collection with future date and unpublished flag via Liquid + Given I have a _puppies directory + And I have the following documents under the puppies collection: + | title | date | content | published | + | Rover | 2007-12-31 | content for Rover. | true | + | Figor | 2007-12-31 | content for Figor. | false | + | Snowy | 2199-12-31 | content for Snowy. | true | + | Hardy | 2199-12-31 | content for Hardy. | false | + And I have a "_config.yml" file with content: + """ + collections: + puppies: + output: false + """ + And I have a "index.md" page that contains "{% for puppy in site.puppies %}
{{ puppy.title }}
{% endfor %}" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + But I should see "
Snowy
" in "_site/index.html" + And I should not see "
Figor
" in "_site/index.html" + And I should not see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should not exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should not exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished --future + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should not exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + Scenario: All the documents Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}" And I have fixture collections diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 5f2aa12aadc..92dff21aeae 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -210,7 +210,9 @@ def container def read_document(full_path) doc = Document.new(full_path, :site => site, :collection => self) doc.read - docs << doc unless doc.data["published"] == false + if site.unpublished || doc.published? + docs << doc + end end def read_static_file(file_path, full_path) From e932a1e27f7f1fb103d94d07c470cc5d9f666295 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 20 May 2018 12:30:17 -0400 Subject: [PATCH 261/337] Update history to reflect merge of #7027 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index 2bd80e6545b..d79d45c650b 100644 --- a/History.markdown +++ b/History.markdown @@ -48,6 +48,10 @@ * Load Rouge for TestKramdown (#7007) * Useless privates removed (#6768) +### Bug Fixes + + * Fix --unpublished not affecting collection documents (#7027) + ## 3.8.2 / 2018-05-18 ### Development Fixes From 6792ff936c987972ec686d749647675d91dcd593 Mon Sep 17 00:00:00 2001 From: Philip Belesky Date: Mon, 21 May 2018 02:30:15 +1000 Subject: [PATCH 262/337] Fix --unpublished not affecting collection documents (#7027) Merge pull request 7027 --- features/collections.feature | 98 ++++++++++++++++++++++++++++++++++++ lib/jekyll/collection.rb | 4 +- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/features/collections.feature b/features/collections.feature index 33a01ade6ed..03f10dc1e6f 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -263,6 +263,104 @@ Feature: Collections And the "_site/puppies/snowy.html" file should not exist And the "_site/puppies/hardy.html" file should not exist + Scenario: Access rendered collection with future date and unpublished flag via Liquid + Given I have a _puppies directory + And I have the following documents under the puppies collection: + | title | date | content | published | + | Rover | 2007-12-31 | content for Rover. | true | + | Figor | 2007-12-31 | content for Figor. | false | + | Snowy | 2199-12-31 | content for Snowy. | true | + | Hardy | 2199-12-31 | content for Hardy. | false | + And I have a "_config.yml" file with content: + """ + collections: + puppies: + output: true + """ + And I have a "index.md" page that contains "{% for puppy in site.puppies %}
{{ puppy.title }}
{% endfor %}" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + But I should see "
Snowy
" in "_site/index.html" + And I should not see "
Figor
" in "_site/index.html" + And I should not see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished --future + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should exist + And the "_site/puppies/snowy.html" file should exist + And the "_site/puppies/figor.html" file should exist + And the "_site/puppies/hardy.html" file should exist + + Scenario: Access unrendered collection with future date and unpublished flag via Liquid + Given I have a _puppies directory + And I have the following documents under the puppies collection: + | title | date | content | published | + | Rover | 2007-12-31 | content for Rover. | true | + | Figor | 2007-12-31 | content for Figor. | false | + | Snowy | 2199-12-31 | content for Snowy. | true | + | Hardy | 2199-12-31 | content for Hardy. | false | + And I have a "_config.yml" file with content: + """ + collections: + puppies: + output: false + """ + And I have a "index.md" page that contains "{% for puppy in site.puppies %}
{{ puppy.title }}
{% endfor %}" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + But I should see "
Snowy
" in "_site/index.html" + And I should not see "
Figor
" in "_site/index.html" + And I should not see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should not exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should not exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + When I run jekyll build --unpublished --future + Then I should get a zero exit status + And the _site directory should exist + And I should see "
Rover
" in "_site/index.html" + And I should see "
Snowy
" in "_site/index.html" + And I should see "
Figor
" in "_site/index.html" + But I should see "
Hardy
" in "_site/index.html" + And the "_site/puppies/rover.html" file should not exist + And the "_site/puppies/snowy.html" file should not exist + And the "_site/puppies/figor.html" file should not exist + And the "_site/puppies/hardy.html" file should not exist + Scenario: All the documents Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}" And I have fixture collections diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index bdfa4b8674f..4a8b6f5320e 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -212,7 +212,9 @@ def container def read_document(full_path) doc = Document.new(full_path, :site => site, :collection => self) doc.read - docs << doc unless doc.data["published"] == false + if site.unpublished || doc.published? + docs << doc + end end private From 03c252ba4d659c6758f39e96507e38820fba2189 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 20 May 2018 12:30:17 -0400 Subject: [PATCH 263/337] Update history to reflect merge of #7027 [ci skip] --- History.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/History.markdown b/History.markdown index 64f743f5a32..b50563f8e3b 100644 --- a/History.markdown +++ b/History.markdown @@ -1,3 +1,9 @@ +## HEAD + +### Bug Fixes + + * Fix --unpublished not affecting collection documents (#7027) + ## 3.8.2 / 2018-05-18 ### Development Fixes From 97c28f54956f582d80e4733a1914cf71af015953 Mon Sep 17 00:00:00 2001 From: Dan Friedman Date: Mon, 21 May 2018 01:45:03 -0500 Subject: [PATCH 264/337] Updated to supported version (#7031) Merge pull request 7031 --- docs/_docs/windows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/windows.md b/docs/_docs/windows.md index 63a52a15753..e4835a9861f 100644 --- a/docs/_docs/windows.md +++ b/docs/_docs/windows.md @@ -89,7 +89,7 @@ Now we can install Ruby. To do this we will use a repository from [BrightBox](ht ```sh sudo apt-add-repository ppa:brightbox/ruby-ng sudo apt-get update -sudo apt-get install ruby2.3 ruby2.3-dev build-essential dh-autoreconf +sudo apt-get install ruby2.4 ruby2.4-dev build-essential dh-autoreconf ``` Next let's update our Ruby gems: From a96f846bdb7ca7086011e2d194884c163948ec77 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 21 May 2018 02:45:05 -0400 Subject: [PATCH 265/337] Update history to reflect merge of #7031 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index d79d45c650b..afd7f93c91d 100644 --- a/History.markdown +++ b/History.markdown @@ -20,6 +20,7 @@ * Document that _drafts need to be contained within the custom collection directory (#6985) * proposed change for passive voice. (#7005) * added the CAT plugin to the plugin list (#7011) + * Updated to supported version (#7031) ### Minor Enhancements From e3b325931b9ea3846a8cea75c11630ccfaee9995 Mon Sep 17 00:00:00 2001 From: Ali Thompson Date: Thu, 24 May 2018 13:27:57 -0700 Subject: [PATCH 266/337] Update drafts.md (#7037) Merge pull request 7037 --- docs/_docs/drafts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/drafts.md b/docs/_docs/drafts.md index c4b4f9f0514..0e6bfd7dfb8 100644 --- a/docs/_docs/drafts.md +++ b/docs/_docs/drafts.md @@ -3,7 +3,7 @@ title: Working with drafts permalink: /docs/drafts/ --- -Drafts are posts without a date. They're posts you're still working on and +Drafts are posts without a date in the filename. They're posts you're still working on and don't want to publish yet. To get up and running with drafts, create a `_drafts` folder in your site's root (as described in the [site structure](/docs/structure/) section) and create your first draft: From d64493806c55caa959ccdc5fe62ed27c71a10745 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 24 May 2018 16:27:59 -0400 Subject: [PATCH 267/337] Update history to reflect merge of #7037 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index afd7f93c91d..27df3c522a3 100644 --- a/History.markdown +++ b/History.markdown @@ -21,6 +21,7 @@ * proposed change for passive voice. (#7005) * added the CAT plugin to the plugin list (#7011) * Updated to supported version (#7031) + * Clarify definition of 'draft' (#7037) ### Minor Enhancements From 1684905ec793be16ebb3ca4e81406aff5cbdbd10 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 31 May 2018 10:13:45 -0600 Subject: [PATCH 268/337] Allow i18n v0.9.5 and higher (#7044) Merge pull request 7044 --- jekyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 107fe7c3db5..76f92f41bc0 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -33,7 +33,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency("addressable", "~> 2.4") s.add_runtime_dependency("colorator", "~> 1.0") s.add_runtime_dependency("em-websocket", "~> 0.5") - s.add_runtime_dependency("i18n", "~> 1.0") + s.add_runtime_dependency("i18n", ">= 0.9.5", "< 2") s.add_runtime_dependency("jekyll-sass-converter", "~> 1.0") s.add_runtime_dependency("jekyll-watch", "~> 2.0") s.add_runtime_dependency("kramdown", "~> 1.14") From 6805f1c342e9e3d0332ff3b46841af1d37779876 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 31 May 2018 12:13:47 -0400 Subject: [PATCH 269/337] Update history to reflect merge of #7044 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 27df3c522a3..20e4bf01a7e 100644 --- a/History.markdown +++ b/History.markdown @@ -49,6 +49,7 @@ * yajl-ruby update to v1.4.0 (#6976) * Load Rouge for TestKramdown (#7007) * Useless privates removed (#6768) + * Allow i18n v0.9.5 and higher (#7044) ### Bug Fixes From 6c771608e5cf347414692520d1055d90d4dadbee Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Sat, 2 Jun 2018 12:50:32 +0200 Subject: [PATCH 270/337] Update Rubocop's config (#7050) Merge pull request 7050 --- .rubocop.yml | 66 ++----- lib/jekyll/collection.rb | 6 +- lib/jekyll/command.rb | 12 +- lib/jekyll/commands/build.rb | 14 +- lib/jekyll/commands/doctor.rb | 14 +- lib/jekyll/commands/help.rb | 2 +- lib/jekyll/commands/new.rb | 56 +++--- lib/jekyll/commands/new_theme.rb | 58 +++--- lib/jekyll/commands/serve.rb | 61 +++--- .../commands/serve/live_reload_reactor.rb | 12 +- lib/jekyll/commands/serve/servlet.rb | 4 +- lib/jekyll/configuration.rb | 6 +- lib/jekyll/converters/markdown.rb | 10 +- lib/jekyll/converters/smartypants.rb | 26 +-- lib/jekyll/convertible.rb | 20 +- lib/jekyll/deprecator.rb | 4 +- lib/jekyll/document.rb | 36 ++-- lib/jekyll/drops/collection_drop.rb | 5 +- lib/jekyll/drops/drop.rb | 2 +- lib/jekyll/drops/site_drop.rb | 3 +- lib/jekyll/drops/unified_payload_drop.rb | 1 + lib/jekyll/drops/url_drop.rb | 1 + lib/jekyll/entry_filter.rb | 4 +- lib/jekyll/excerpt.rb | 24 +-- lib/jekyll/external.rb | 10 +- lib/jekyll/filters.rb | 5 +- lib/jekyll/filters/date_filters.rb | 3 +- lib/jekyll/filters/url_filters.rb | 1 - lib/jekyll/frontmatter_defaults.rb | 4 +- lib/jekyll/hooks.rb | 4 +- lib/jekyll/liquid_extensions.rb | 2 - lib/jekyll/liquid_renderer/table.rb | 132 ++++++------- lib/jekyll/page.rb | 6 +- lib/jekyll/plugin.rb | 16 +- lib/jekyll/reader.rb | 4 +- lib/jekyll/readers/data_reader.rb | 16 +- lib/jekyll/readers/layout_reader.rb | 4 +- lib/jekyll/readers/post_reader.rb | 7 +- lib/jekyll/readers/theme_assets_reader.rb | 11 +- lib/jekyll/regenerator.rb | 12 +- lib/jekyll/renderer.rb | 16 +- lib/jekyll/site.rb | 30 ++- lib/jekyll/static_file.rb | 7 +- lib/jekyll/stevenson.rb | 4 +- lib/jekyll/tags/highlight.rb | 24 +-- lib/jekyll/tags/include.rb | 26 +-- lib/jekyll/tags/link.rb | 10 +- lib/jekyll/tags/post_url.rb | 30 +-- lib/jekyll/theme.rb | 12 +- lib/jekyll/theme_builder.rb | 180 +++++++++--------- lib/jekyll/url.rb | 4 +- lib/jekyll/utils/exec.rb | 1 - lib/jekyll/utils/internet.rb | 4 +- lib/jekyll/utils/platforms.rb | 3 +- lib/jekyll/utils/thread_event.rb | 6 +- lib/jekyll/utils/win_tz.rb | 2 +- lib/jekyll/version.rb | 2 +- 57 files changed, 473 insertions(+), 572 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ce750ace645..9edab2bd064 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,30 +18,14 @@ AllCops: - script/**/* - vendor/**/* - tmp/**/* -Layout/AlignArray: - Enabled: false Layout/AlignHash: EnforcedHashRocketStyle: table -Layout/AlignParameters: - Enabled: false -Layout/EmptyLinesAroundAccessModifier: - Enabled: false -Layout/EmptyLinesAroundModuleBody: - Enabled: false -Layout/EndOfLine: - EnforcedStyle: native -Layout/ExtraSpacing: - AllowForAlignment: true -Layout/FirstParameterIndentation: - EnforcedStyle: consistent Layout/IndentationWidth: Severity: error Layout/IndentArray: EnforcedStyle: consistent Layout/IndentHash: EnforcedStyle: consistent -Layout/IndentHeredoc: - Enabled: false Layout/MultilineMethodCallIndentation: EnforcedStyle: indented Layout/MultilineOperationIndentation: @@ -53,12 +37,11 @@ Layout/EmptyComment: Enabled: false Layout/EndAlignment: Severity: error -Lint/UnneededRequireStatement: - Enabled: false Lint/UnreachableCode: Severity: error Lint/Void: - Enabled: false + Exclude: + - lib/jekyll/site.rb Metrics/AbcSize: Max: 21 Metrics/BlockLength: @@ -66,22 +49,26 @@ Metrics/BlockLength: - test/**/*.rb - lib/jekyll/configuration.rb - rake/*.rake - - jekyll.gemspec Metrics/ClassLength: Exclude: - !ruby/regexp /features\/.*.rb$/ - !ruby/regexp /test\/.*.rb$/ - Max: 300 + - lib/jekyll/document.rb + - lib/jekyll/site.rb + - lib/jekyll/commands/serve.rb + - lib/jekyll/configuration.rb + Max: 240 Metrics/CyclomaticComplexity: - Max: 9 + Exclude: + - lib/jekyll/utils.rb + - lib/jekyll/commands/serve.rb Metrics/LineLength: Exclude: - !ruby/regexp /features\/.*.rb/ - Rakefile - rake/*.rake - Gemfile - - jekyll.gemspec - Max: 90 + Max: 100 Severity: warning Metrics/MethodLength: CountComments: false @@ -95,8 +82,6 @@ Metrics/PerceivedComplexity: Max: 8 Naming/FileName: Enabled: false -Naming/HeredocDelimiterNaming: - Enabled: false Naming/MemoizedInstanceVariableName: Exclude: - lib/jekyll/page_without_a_file.rb @@ -105,8 +90,6 @@ Naming/MemoizedInstanceVariableName: Naming/UncommunicativeMethodParamName: AllowedNames: - _ -Performance/UnfreezeString: - Enabled: false Security/MarshalLoad: Exclude: - !ruby/regexp /test\/.*.rb$/ @@ -116,19 +99,13 @@ Security/YAMLLoad: - !ruby/regexp /features\/.*.rb/ - !ruby/regexp /test\/.*.rb$/ Style/Alias: - Enabled: false + EnforcedStyle: prefer_alias_method Style/AndOr: Severity: error -Style/BracesAroundHashParameters: - Enabled: false -Style/ClassAndModuleChildren: - Enabled: false Style/FrozenStringLiteralComment: EnforcedStyle: always Style/Documentation: Enabled: false - Exclude: - - !ruby/regexp /features\/.*.rb$/ Style/DoubleNegation: Enabled: false Style/FormatStringToken: @@ -139,10 +116,6 @@ Style/GuardClause: Style/HashSyntax: EnforcedStyle: hash_rockets Severity: error -Style/IfUnlessModifier: - Enabled: false -Style/InverseMethods: - Enabled: false Style/MixinUsage: Exclude: - test/helper.rb @@ -150,8 +123,6 @@ Style/ModuleFunction: Enabled: false Style/MultilineTernaryOperator: Severity: error -Style/NumericPredicate: - Enabled: false Style/PercentLiteralDelimiters: PreferredDelimiters: "%q": "{}" @@ -161,28 +132,21 @@ Style/PercentLiteralDelimiters: "%w": "()" "%W": "()" "%x": "()" -Style/RedundantFreeze: - Enabled: false -Style/RedundantReturn: - Enabled: false -Style/RedundantSelf: - Enabled: false Style/RegexpLiteral: EnforcedStyle: percent_r Style/RescueModifier: Enabled: false Style/SafeNavigation: - Enabled: false + Exclude: + - lib/jekyll/document.rb Style/SignalException: EnforcedStyle: only_raise -Style/SingleLineMethods: - Enabled: false Style/StringLiterals: EnforcedStyle: double_quotes Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes Style/SymbolArray: - Enabled: false + EnforcedStyle: brackets Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: consistent_comma Style/TrailingCommaInHashLiteral: diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 92dff21aeae..e4af6a3a10c 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -35,7 +35,7 @@ def respond_to_missing?(method, include_private = false) def method_missing(method, *args, &blck) if docs.respond_to?(method.to_sym) Jekyll.logger.warn "Deprecation:", - "#{label}.#{method} should be changed to #{label}.docs.#{method}." + "#{label}.#{method} should be changed to #{label}.docs.#{method}." Jekyll.logger.warn "", "Called by #{caller(0..0)}." docs.public_send(method.to_sym, *args, &blck) else @@ -210,9 +210,7 @@ def container def read_document(full_path) doc = Document.new(full_path, :site => site, :collection => self) doc.read - if site.unpublished || doc.published? - docs << doc - end + docs << doc if site.unpublished || doc.published? end def read_static_file(file_path, full_path) diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index 50cfe8de6dc..d81ccef59cd 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -51,26 +51,26 @@ def configuration_from_options(options) # rubocop:disable Metrics/MethodLength def add_build_options(cmd) cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", - Array, "Custom configuration file" + Array, "Custom configuration file" cmd.option "destination", "-d", "--destination DESTINATION", - "The current folder will be generated into DESTINATION" + "The current folder will be generated into DESTINATION" cmd.option "source", "-s", "--source SOURCE", "Custom source directory" cmd.option "future", "--future", "Publishes posts with a future date" cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer, - "Limits the number of posts to parse and publish" + "Limits the number of posts to parse and publish" cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild" cmd.option "baseurl", "-b", "--baseurl URL", - "Serve the website from the given base URL" + "Serve the website from the given base URL" cmd.option "force_polling", "--force_polling", "Force watch to use polling" cmd.option "lsi", "--lsi", "Use LSI for improved related posts" cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder" cmd.option "unpublished", "--unpublished", - "Render posts that were marked as unpublished" + "Render posts that were marked as unpublished" cmd.option "quiet", "-q", "--quiet", "Silence output." cmd.option "verbose", "-V", "--verbose", "Print verbose output." cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild." cmd.option "strict_front_matter", "--strict_front_matter", - "Fail if errors are present in front matter" + "Fail if errors are present in front matter" end # rubocop:enable Metrics/MethodLength diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index a5b26704b46..3e0b715edcd 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -31,14 +31,14 @@ def process(options) if options.fetch("skip_initial_build", false) Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \ - " This may result in an out-of-date site." + " This may result in an out-of-date site." else build(site, options) end if options.fetch("detach", false) Jekyll.logger.info "Auto-regeneration:", - "disabled when running server detached." + "disabled when running server detached." elsif options.fetch("watch", false) watch(site, options) else @@ -60,7 +60,7 @@ def build(site, options) Jekyll.logger.info "Source:", source Jekyll.logger.info "Destination:", destination Jekyll.logger.info "Incremental build:", - (incremental ? "enabled" : "disabled. Enable with --incremental") + (incremental ? "enabled" : "disabled. Enable with --incremental") Jekyll.logger.info "Generating..." process_site(site) Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds." @@ -76,12 +76,12 @@ def watch(site, options) # Warn Windows users that they might need to upgrade. if Utils::Platforms.bash_on_windows? Jekyll.logger.warn "", - "Auto-regeneration may not work on some Windows versions." + "Auto-regeneration may not work on some Windows versions." Jekyll.logger.warn "", - "Please see: https://github.com/Microsoft/BashOnWindows/issues/216" + "Please see: https://github.com/Microsoft/BashOnWindows/issues/216" Jekyll.logger.warn "", - "If it does not work, please upgrade Bash on Windows or "\ - "run Jekyll with --no-watch." + "If it does not work, please upgrade Bash on Windows or "\ + "run Jekyll with --no-watch." end External.require_with_graceful_fail "jekyll-watch" diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index bb313152c37..4cc196cdd15 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -11,7 +11,7 @@ def init_with_program(prog) c.alias(:hyde) c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, - "Custom configuration file" + "Custom configuration file" c.action do |_, options| Jekyll::Commands::Doctor.process(options) @@ -48,19 +48,18 @@ def properly_gathered_posts?(site) posts_at_root = site.in_source_dir("_posts") return true unless File.directory?(posts_at_root) Jekyll.logger.warn "Warning:", - "Detected '_posts' directory outside custom `collections_dir`!" + "Detected '_posts' directory outside custom `collections_dir`!" Jekyll.logger.warn "", - "Please move '#{posts_at_root}' into the custom directory at " \ + "Please move '#{posts_at_root}' into the custom directory at " \ "'#{site.in_source_dir(site.config["collections_dir"])}'" false end def deprecated_relative_permalinks(site) if site.config["relative_permalinks"] - Jekyll::Deprecator.deprecation_message "Your site still uses relative" \ - " permalinks, which was removed in" \ - " Jekyll v3.0.0." - return true + Jekyll::Deprecator.deprecation_message "Your site still uses relative permalinks," \ + " which was removed in Jekyll v3.0.0." + true end end @@ -117,6 +116,7 @@ def proper_site_url?(site) end private + def collect_urls(urls, things, destination) things.each do |thing| dest = thing.destination(destination) diff --git a/lib/jekyll/commands/help.rb b/lib/jekyll/commands/help.rb index 80c80e9aeac..90403dfd06c 100644 --- a/lib/jekyll/commands/help.rb +++ b/lib/jekyll/commands/help.rb @@ -25,7 +25,7 @@ def init_with_program(prog) def invalid_command(prog, cmd) Jekyll.logger.error "Error:", - "Hmm... we don't know what the '#{cmd}' command is." + "Hmm... we don't know what the '#{cmd}' command is." Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ") end end diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index b123015641e..dc5d7284a11 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -62,38 +62,32 @@ def initialized_post_name private def gemfile_contents - <<-RUBY -source "https://rubygems.org" - -# Hello! This is where you manage which Jekyll version is used to run. -# When you want to use a different version, change it below, save the -# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: -# -# bundle exec jekyll serve -# -# This will help ensure the proper Jekyll version is running. -# Happy Jekylling! -gem "jekyll", "~> #{Jekyll::VERSION}" - -# This is the default theme for new Jekyll sites. You may change this to anything you like. -gem "minima", "~> 2.0" - -# If you want to use GitHub Pages, remove the "gem "jekyll"" above and -# uncomment the line below. To upgrade, run `bundle update github-pages`. -# gem "github-pages", group: :jekyll_plugins - -# If you have any plugins, put them here! -group :jekyll_plugins do - gem "jekyll-feed", "~> 0.6" -end - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] - -# Performance-booster for watching directories on Windows -gem "wdm", "~> 0.1.0" if Gem.win_platform? + <<~RUBY + source "https://rubygems.org" + # Hello! This is where you manage which Jekyll version is used to run. + # When you want to use a different version, change it below, save the + # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: + # + # bundle exec jekyll serve + # + # This will help ensure the proper Jekyll version is running. + # Happy Jekylling! + gem "jekyll", "~> #{Jekyll::VERSION}" + # This is the default theme for new Jekyll sites. You may change this to anything you like. + gem "minima", "~> 2.0" + # If you want to use GitHub Pages, remove the "gem "jekyll"" above and + # uncomment the line below. To upgrade, run `bundle update github-pages`. + # gem "github-pages", group: :jekyll_plugins + # If you have any plugins, put them here! + group :jekyll_plugins do + gem "jekyll-feed", "~> 0.6" + end + # Windows does not include zoneinfo files, so bundle the tzinfo-data gem + gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] + # Performance-booster for watching directories on Windows + gem "wdm", "~> 0.1.0" if Gem.win_platform? -RUBY + RUBY end def create_site(new_blog_path) diff --git a/lib/jekyll/commands/new_theme.rb b/lib/jekyll/commands/new_theme.rb index c55e68127d8..b26dabe4c18 100644 --- a/lib/jekyll/commands/new_theme.rb +++ b/lib/jekyll/commands/new_theme.rb @@ -2,39 +2,41 @@ require "erb" -class Jekyll::Commands::NewTheme < Jekyll::Command - class << self - def init_with_program(prog) - prog.command(:"new-theme") do |c| - c.syntax "new-theme NAME" - c.description "Creates a new Jekyll theme scaffold" - c.option "code_of_conduct", \ - "-c", "--code-of-conduct", \ - "Include a Code of Conduct. (defaults to false)" +module Jekyll + module Commands + class NewTheme < Jekyll::Command + class << self + def init_with_program(prog) + prog.command(:"new-theme") do |c| + c.syntax "new-theme NAME" + c.description "Creates a new Jekyll theme scaffold" + c.option "code_of_conduct", \ + "-c", "--code-of-conduct", \ + "Include a Code of Conduct. (defaults to false)" - c.action do |args, opts| - Jekyll::Commands::NewTheme.process(args, opts) + c.action do |args, opts| + Jekyll::Commands::NewTheme.process(args, opts) + end + end end - end - end - # rubocop:disable Metrics/AbcSize - def process(args, opts) - if !args || args.empty? - raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name." - end + # rubocop:disable Metrics/AbcSize + def process(args, opts) + if !args || args.empty? + raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name." + end - new_theme_name = args.join("_") - theme = Jekyll::ThemeBuilder.new(new_theme_name, opts) - if theme.path.exist? - Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." - end + new_theme_name = args.join("_") + theme = Jekyll::ThemeBuilder.new(new_theme_name, opts) + Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." if theme.path.exist? - theme.create! - Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}," \ - " is ready for you in #{theme.path.to_s.cyan}!" - Jekyll.logger.info "For help getting started, read #{theme.path}/README.md." + theme.create! + Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}," \ + " is ready for you in #{theme.path.to_s.cyan}!" + Jekyll.logger.info "For help getting started, read #{theme.path}/README.md." + end + # rubocop:enable Metrics/AbcSize + end end - # rubocop:enable Metrics/AbcSize end end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 9b8417cdd5a..ecf6fe67cdb 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "thread" - module Jekyll module Commands class Serve < Command @@ -19,25 +17,28 @@ class << self "host" => ["host", "-H", "--host [HOST]", "Host to bind to"], "open_url" => ["-o", "--open-url", "Launch your site in a browser"], "detach" => ["-B", "--detach", - "Run the server in the background",], + "Run the server in the background",], "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."], "port" => ["-P", "--port [PORT]", "Port to listen on"], "show_dir_listing" => ["--show-dir-listing", - "Show a directory listing instead of loading your index file.",], + "Show a directory listing instead of loading" \ + " your index file.",], "skip_initial_build" => ["skip_initial_build", "--skip-initial-build", - "Skips the initial site build which occurs before the server is started.",], + "Skips the initial site build which occurs before" \ + " the server is started.",], "livereload" => ["-l", "--livereload", - "Use LiveReload to automatically refresh browsers",], + "Use LiveReload to automatically refresh browsers",], "livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]", - Array, - "Files for LiveReload to ignore. Remember to quote the values so your shell "\ - "won't expand them",], + Array, + "Files for LiveReload to ignore. " \ + "Remember to quote the values so your shell " \ + "won't expand them",], "livereload_min_delay" => ["--livereload-min-delay [SECONDS]", - "Minimum reload delay",], + "Minimum reload delay",], "livereload_max_delay" => ["--livereload-max-delay [SECONDS]", - "Maximum reload delay",], + "Maximum reload delay",], "livereload_port" => ["--livereload-port [PORT]", Integer, - "Port for LiveReload to listen on",], + "Port for LiveReload to listen on",], }.freeze DIRECTORY_INDEX = %w( @@ -107,8 +108,8 @@ def shutdown def validate_options(opts) if opts["livereload"] if opts["detach"] - Jekyll.logger.warn "Warning:", - "--detach and --livereload are mutually exclusive. Choosing --livereload" + Jekyll.logger.warn "Warning:", "--detach and --livereload are mutually exclusive." \ + " Choosing --livereload" opts["detach"] = false end if opts["ssl_cert"] || opts["ssl_key"] @@ -123,9 +124,9 @@ def validate_options(opts) opts["watch"] = true end elsif %w(livereload_min_delay - livereload_max_delay - livereload_ignore - livereload_port).any? { |o| opts[o] } + livereload_max_delay + livereload_ignore + livereload_port).any? { |o| opts[o] } Jekyll.logger.abort_with "--livereload-min-delay, "\ "--livereload-max-delay, --livereload-ignore, and "\ "--livereload-port require the --livereload option." @@ -204,9 +205,7 @@ def webrick_opts(opts) end def start_up_webrick(opts, destination) - if opts["livereload"] - @reload_reactor.start(opts) - end + @reload_reactor.start(opts) if opts["livereload"] @server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") } @server.mount(opts["baseurl"].to_s, Servlet, destination, file_handler_opts) @@ -218,12 +217,12 @@ def start_up_webrick(opts, destination) # Recreate NondisclosureName under utf-8 circumstance def file_handler_opts - WEBrick::Config::FileHandler.merge({ + WEBrick::Config::FileHandler.merge( :FancyIndexing => true, :NondisclosureName => [ ".ht*", "~*", - ], - }) + ] + ) end def server_address(server, options = {}) @@ -236,12 +235,11 @@ def server_address(server, options = {}) end def format_url(ssl_enabled, address, port, baseurl = nil) - format("%s://%
s:%i%s", { - :prefix => ssl_enabled ? "https" : "http", - :address => address, - :port => port, - :baseurl => baseurl ? "#{baseurl}/" : "", - }) + format("%s://%
s:%i%s", + :prefix => ssl_enabled ? "https" : "http", + :address => address, + :port => port, + :baseurl => baseurl ? "#{baseurl}/" : "") end def default_url(opts) @@ -273,7 +271,8 @@ def boot_or_detach(server, opts) Process.detach(pid) Jekyll.logger.info "Server detached with pid '#{pid}'.", \ - "Run `pkill -f jekyll' or `kill -9 #{pid}' to stop the server." + "Run `pkill -f jekyll' or `kill -9 #{pid}'" \ + " to stop the server." else t = Thread.new { server.start } trap("INT") { server.shutdown } @@ -311,7 +310,7 @@ def start_callback(detached) proc do mutex.synchronize do # Block until EventMachine reactor starts - @reload_reactor.started_event.wait unless @reload_reactor.nil? + @reload_reactor&.started_event&.wait @running = true Jekyll.logger.info("Server running...", "press ctrl-c to stop.") @run_cond.broadcast diff --git a/lib/jekyll/commands/serve/live_reload_reactor.rb b/lib/jekyll/commands/serve/live_reload_reactor.rb index eeafa236e72..960b558259e 100644 --- a/lib/jekyll/commands/serve/live_reload_reactor.rb +++ b/lib/jekyll/commands/serve/live_reload_reactor.rb @@ -58,7 +58,7 @@ def start(opts) EM.add_shutdown_hook { @stopped_event.set } Jekyll.logger.info "LiveReload address:", - "http://#{opts["host"]}:#{opts["livereload_port"]}" + "http://#{opts["host"]}:#{opts["livereload_port"]}" end end @thread.abort_on_exception = true @@ -68,11 +68,11 @@ def start(opts) # http://feedback.livereload.com/knowledgebase/articles/86174-livereload-protocol def reload(pages) pages.each do |p| - json_message = JSON.dump({ + json_message = JSON.dump( :command => "reload", :path => p.url, - :liveCSS => true, - }) + :liveCSS => true + ) Jekyll.logger.debug "LiveReload:", "Reloading #{p.url}" Jekyll.logger.debug "", json_message @@ -108,9 +108,7 @@ def print_message(json_message) msg = JSON.parse(json_message) # Not sure what the 'url' command even does in LiveReload. The spec is silent # on its purpose. - if msg["command"] == "url" - Jekyll.logger.info "LiveReload:", "Browser URL: #{msg["url"]}" - end + Jekyll.logger.info "LiveReload:", "Browser URL: #{msg["url"]}" if msg["command"] == "url" end def log_error(error) diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index 3b05bf87fe1..b25f1d9d7fd 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -121,9 +121,7 @@ def livereload_args if @options["livereload_max_delay"] src += "&maxdelay=#{@options["livereload_max_delay"]}" end - if @options["livereload_port"] - src += "&port=#{@options["livereload_port"]}" - end + src += "&port=#{@options["livereload_port"]}" if @options["livereload_port"] src end end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index cf7fea55397..95cd87fbe7d 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -346,7 +346,7 @@ def check_include_exclude(config) " as a list of comma-separated values." config[option] = csv_to_array(config[option]) end - config[option].map!(&:to_s) if config[option] + config[option]&.map!(&:to_s) end end @@ -381,8 +381,8 @@ def check_plugins(config) " use an array instead. If you wanted to set the directory of your" \ " plugins, use the config key `plugins_dir` instead." raise Jekyll::Errors::InvalidConfigurationError, - "'plugins' should not be a string, but was: " \ - "#{config["plugins"].inspect}. Use 'plugins_dir' instead." + "'plugins' should not be a string, but was: " \ + "#{config["plugins"].inspect}. Use 'plugins_dir' instead." end end end diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 220bc3820d4..67b10409ba1 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -11,9 +11,7 @@ def setup return if @setup ||= false unless (@parser = get_processor) Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"] - if @config["safe"] - Jekyll.logger.info "", "Custom processors are not loaded in safe mode" - end + Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"] Jekyll.logger.error( "", "Available processors are: #{valid_processors.join(", ")}" @@ -30,7 +28,7 @@ def setup # rubocop:disable Naming/AccessorMethodName def get_processor case @config["markdown"].downcase - when "kramdown" then return KramdownParser.new(@config) + when "kramdown" then KramdownParser.new(@config) else custom_processor end @@ -79,9 +77,7 @@ def convert(content) def custom_processor converter_name = @config["markdown"] - if custom_class_allowed?(converter_name) - self.class.const_get(converter_name).new(@config) - end + self.class.const_get(converter_name).new(@config) if custom_class_allowed?(converter_name) end # Private: Determine whether a class name is an allowed custom diff --git a/lib/jekyll/converters/smartypants.rb b/lib/jekyll/converters/smartypants.rb index 8234a41afc1..29c19b1bac6 100644 --- a/lib/jekyll/converters/smartypants.rb +++ b/lib/jekyll/converters/smartypants.rb @@ -1,16 +1,20 @@ # frozen_string_literal: true -class Kramdown::Parser::SmartyPants < Kramdown::Parser::Kramdown - def initialize(source, options) - super - @block_parsers = [:block_html, :content] - @span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html] - end +module Kramdown + module Parser + class SmartyPants < Kramdown::Parser::Kramdown + def initialize(source, options) + super + @block_parsers = [:block_html, :content] + @span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html] + end - def parse_content - add_text @src.scan(%r!\A.*\n!) + def parse_content + add_text @src.scan(%r!\A.*\n!) + end + define_parser(:content, %r!\A!) + end end - define_parser(:content, %r!\A!) end module Jekyll @@ -20,9 +24,7 @@ class SmartyPants < Converter priority :low def initialize(config) - unless defined?(Kramdown) - Jekyll::External.require_with_graceful_fail "kramdown" - end + Jekyll::External.require_with_graceful_fail "kramdown" unless defined?(Kramdown) @config = config["kramdown"].dup || {} @config[:input] = :SmartyPants end diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index bfd03986329..5e703505f7b 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -46,10 +46,10 @@ def read_yaml(base, name, opts = {}) end rescue Psych::SyntaxError => e Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}" - raise e if self.site.config["strict_front_matter"] + raise e if site.config["strict_front_matter"] rescue StandardError => e Jekyll.logger.warn "Error reading file #{filename}: #{e.message}" - raise e if self.site.config["strict_front_matter"] + raise e if site.config["strict_front_matter"] end self.data ||= {} @@ -64,12 +64,12 @@ def read_yaml(base, name, opts = {}) def validate_data!(filename) unless self.data.is_a?(Hash) raise Errors::InvalidYAMLFrontMatterError, - "Invalid YAML front matter in #{filename}" + "Invalid YAML front matter in #{filename}" end end def validate_permalink!(filename) - if self.data["permalink"] && self.data["permalink"].to_s.empty? + if self.data["permalink"]&.to_s&.empty? raise Errors::InvalidPermalinkError, "Invalid permalink in #{filename}" end end @@ -125,16 +125,12 @@ def to_liquid(attrs = nil) # # Returns the type of self. def type - if is_a?(Page) - :pages - end + :pages if is_a?(Page) end # returns the owner symbol for hook triggering def hook_owner - if is_a?(Page) - :pages - end + :pages if is_a?(Page) end # Determine whether the document is an asset file. @@ -181,7 +177,7 @@ def place_in_layout? # # Returns true if the layout is invalid, false if otherwise def invalid_layout?(layout) - !data["layout"].nil? && layout.nil? && !(self.is_a? Jekyll::Excerpt) + !data["layout"].nil? && layout.nil? && !(is_a? Jekyll::Excerpt) end # Recursively render layouts @@ -210,7 +206,7 @@ def do_layout(payload, layouts) renderer.payload = payload end.run - Jekyll.logger.debug "Post-Render Hooks:", self.relative_path + Jekyll.logger.debug "Post-Render Hooks:", relative_path Jekyll::Hooks.trigger hook_owner, :post_render, self ensure @_renderer = nil # this will allow the modifications above to disappear diff --git a/lib/jekyll/deprecator.rb b/lib/jekyll/deprecator.rb index 327358c2d4f..748c8be71e1 100644 --- a/lib/jekyll/deprecator.rb +++ b/lib/jekyll/deprecator.rb @@ -34,9 +34,7 @@ def no_subcommand(args) end def arg_is_present?(args, deprecated_argument, message) - if args.include?(deprecated_argument) - deprecation_message(message) - end + deprecation_message(message) if args.include?(deprecated_argument) end def deprecation_message(message) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index a4f989b88c6..dbc1a6d82a0 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -204,11 +204,11 @@ def permalink # # Returns the computed URL for the document. def url - @url ||= URL.new({ + @url ||= URL.new( :template => url_template, :placeholders => url_placeholders, - :permalink => permalink, - }).to_s + :permalink => permalink + ).to_s end def [](key) @@ -315,7 +315,7 @@ def <=>(other) # method returns true, and if the site's Publisher will publish the document. # False otherwise. def write? - collection && collection.write? && site.publisher.publish?(self) + collection&.write? && site.publisher.publish?(self) end # The Document excerpt_separator, from the YAML Front-Matter or site @@ -335,16 +335,12 @@ def generate_excerpt? def next_doc pos = collection.docs.index { |post| post.equal?(self) } - if pos && pos < collection.docs.length - 1 - collection.docs[pos + 1] - end + collection.docs[pos + 1] if pos && pos < collection.docs.length - 1 end def previous_doc pos = collection.docs.index { |post| post.equal?(self) } - if pos && pos > 0 - collection.docs[pos - 1] - end + collection.docs[pos - 1] if pos && pos.positive? end def trigger_hooks(hook_name, *args) @@ -400,28 +396,26 @@ def categories_from_path(special_dir) end def populate_categories - merge_data!({ + merge_data!( "categories" => ( Array(data["categories"]) + Utils.pluralized_array_from_hash( data, "category", "categories" ) - ).map(&:to_s).flatten.uniq, - }) + ).map(&:to_s).flatten.uniq + ) end def populate_tags - merge_data!({ - "tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten, - }) + merge_data!( + "tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten + ) end private def merge_categories!(other) if other.key?("categories") && !other["categories"].nil? - if other["categories"].is_a?(String) - other["categories"] = other["categories"].split - end + other["categories"] = other["categories"].split if other["categories"].is_a?(String) other["categories"] = (data["categories"] || []) | other["categories"] end end @@ -493,9 +487,7 @@ def modify_date(date) end def generate_excerpt - if generate_excerpt? - data["excerpt"] ||= Jekyll::Excerpt.new(self) - end + data["excerpt"] ||= Jekyll::Excerpt.new(self) if generate_excerpt? end end end diff --git a/lib/jekyll/drops/collection_drop.rb b/lib/jekyll/drops/collection_drop.rb index 858a721a6f6..ff28039bafb 100644 --- a/lib/jekyll/drops/collection_drop.rb +++ b/lib/jekyll/drops/collection_drop.rb @@ -7,9 +7,8 @@ class CollectionDrop < Drop mutable false - def_delegator :@obj, :write?, :output - def_delegators :@obj, :label, :docs, :files, :directory, - :relative_directory + def_delegator :@obj, :write?, :output + def_delegators :@obj, :label, :docs, :files, :directory, :relative_directory private def_delegator :@obj, :metadata, :fallback_data diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index be842737b19..412c279145e 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -173,7 +173,7 @@ def each end def merge(other, &block) - self.dup.tap do |me| + dup.tap do |me| if block.nil? me.merge!(other) else diff --git a/lib/jekyll/drops/site_drop.rb b/lib/jekyll/drops/site_drop.rb index 1cb636d8825..3ec2dc51379 100644 --- a/lib/jekyll/drops/site_drop.rb +++ b/lib/jekyll/drops/site_drop.rb @@ -8,8 +8,7 @@ class SiteDrop < Drop mutable false def_delegator :@obj, :site_data, :data - def_delegators :@obj, :time, :pages, :static_files, :documents, - :tags, :categories + def_delegators :@obj, :time, :pages, :static_files, :documents, :tags, :categories private def_delegator :@obj, :config, :fallback_data diff --git a/lib/jekyll/drops/unified_payload_drop.rb b/lib/jekyll/drops/unified_payload_drop.rb index 52647f98bf6..24aefde2012 100644 --- a/lib/jekyll/drops/unified_payload_drop.rb +++ b/lib/jekyll/drops/unified_payload_drop.rb @@ -17,6 +17,7 @@ def site end private + def fallback_data @fallback_data ||= {} end diff --git a/lib/jekyll/drops/url_drop.rb b/lib/jekyll/drops/url_drop.rb index 0571558bf4e..f0641e23cd5 100644 --- a/lib/jekyll/drops/url_drop.rb +++ b/lib/jekyll/drops/url_drop.rb @@ -80,6 +80,7 @@ def y_day end private + def fallback_data {} end diff --git a/lib/jekyll/entry_filter.rb b/lib/jekyll/entry_filter.rb index d016e0c2043..44b6cdbd2d5 100644 --- a/lib/jekyll/entry_filter.rb +++ b/lib/jekyll/entry_filter.rb @@ -31,9 +31,7 @@ def relative_to_source(entry) def filter(entries) entries.reject do |e| - unless included?(e) - special?(e) || backup?(e) || excluded?(e) || symlink?(e) - end + special?(e) || backup?(e) || excluded?(e) || symlink?(e) unless included?(e) end end diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 41bcb18a58a..6f4ac3d8ed0 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -8,10 +8,11 @@ class Excerpt attr_accessor :content, :ext attr_writer :output - def_delegators :@doc, :site, :name, :ext, :extname, - :collection, :related_posts, - :coffeescript_file?, :yaml_file?, - :url, :next_doc, :previous_doc + def_delegators :@doc, + :site, :name, :ext, :extname, + :collection, :related_posts, + :coffeescript_file?, :yaml_file?, + :url, :next_doc, :previous_doc private :coffeescript_file?, :yaml_file? @@ -55,7 +56,7 @@ def relative_path # # Returns true if the string passed in def include?(something) - (output && output.include?(something)) || content.include?(something) + (output&.include?(something)) || content.include?(something) end # The UID for this doc (useful in feeds). @@ -76,7 +77,7 @@ def to_liquid # Returns the shorthand String identifier of this doc. def inspect - "" + "" end def output @@ -160,19 +161,18 @@ def liquid_block?(tag_name) Liquid::Template.tags[tag_name].superclass == Liquid::Block rescue NoMethodError Jekyll.logger.error "Error:", - "A Liquid tag in the excerpt of #{doc.relative_path} couldn't be " \ - "parsed." + "A Liquid tag in the excerpt of #{doc.relative_path} couldn't be parsed." raise end def print_build_warning Jekyll.logger.warn "Warning:", "Excerpt modified in #{doc.relative_path}!" Jekyll.logger.warn "", - "Found a Liquid block containing separator '#{doc.excerpt_separator}' and has " \ - "been modified with the appropriate closing tag." + "Found a Liquid block containing separator '#{doc.excerpt_separator}'" \ + " and has been modified with the appropriate closing tag." Jekyll.logger.warn "", - "Feel free to define a custom excerpt or excerpt_separator in the document's " \ - "Front Matter if the generated excerpt is unsatisfactory." + "Feel free to define a custom excerpt or excerpt_separator in the" \ + " document's Front Matter if the generated excerpt is unsatisfactory." end end end diff --git a/lib/jekyll/external.rb b/lib/jekyll/external.rb index cedd4881c3b..15b30a5f51a 100644 --- a/lib/jekyll/external.rb +++ b/lib/jekyll/external.rb @@ -58,13 +58,13 @@ def require_with_graceful_fail(names) Jekyll.logger.debug "Requiring:", name.to_s require name rescue LoadError => e - Jekyll.logger.error "Dependency Error:", <<-MSG -Yikes! It looks like you don't have #{name} or one of its dependencies installed. -In order to use Jekyll as currently configured, you'll need to install this gem. + Jekyll.logger.error "Dependency Error:", <<~MSG + Yikes! It looks like you don't have #{name} or one of its dependencies installed. + In order to use Jekyll as currently configured, you'll need to install this gem. -The full error message from Ruby is: '#{e.message}' + The full error message from Ruby is: '#{e.message}' -If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/! + If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/! MSG raise Jekyll::Errors::MissingDependencyException, name end diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 1708d5fa9f3..2a390f06503 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -225,9 +225,7 @@ def to_integer(input) # # Returns the filtered array of objects def sort(input, property = nil, nils = "first") - if input.nil? - raise ArgumentError, "Cannot sort a null object." - end + raise ArgumentError, "Cannot sort a null object." if input.nil? if property.nil? input.sort else @@ -367,7 +365,6 @@ def parse_condition(exp) condition end - end end diff --git a/lib/jekyll/filters/date_filters.rb b/lib/jekyll/filters/date_filters.rb index 7bdf0fffd1b..d804a1db7f7 100644 --- a/lib/jekyll/filters/date_filters.rb +++ b/lib/jekyll/filters/date_filters.rb @@ -64,6 +64,7 @@ def date_to_rfc822(date) end private + # month_type: Notations that evaluate to 'Month' via `Time#strftime` ("%b", "%B") # type: nil (default) or "ordinal" # style: nil (default) or "US" @@ -96,7 +97,7 @@ def time(input) date = Liquid::Utils.to_date(input) unless date.respond_to?(:to_time) raise Errors::InvalidDateError, - "Invalid Date: '#{input.inspect}' is not a valid datetime." + "Invalid Date: '#{input.inspect}' is not a valid datetime." end date.to_time.dup.localtime end diff --git a/lib/jekyll/filters/url_filters.rb b/lib/jekyll/filters/url_filters.rb index 67abe137caa..55835167f63 100644 --- a/lib/jekyll/filters/url_filters.rb +++ b/lib/jekyll/filters/url_filters.rb @@ -57,7 +57,6 @@ def ensure_leading_slash(input) return input if input.nil? || input.empty? || input.start_with?("/") "/#{input}" end - end end end diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 7d96b8cade7..95c46900e30 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -122,9 +122,7 @@ def applies_path?(scope, path) def path_is_subpath?(path, parent_path) path.ascend do |ascended_path| - if ascended_path.to_s == parent_path.to_s - return true - end + return true if ascended_path.to_s == parent_path.to_s end false diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb index 64496b53119..23b2776b06d 100644 --- a/lib/jekyll/hooks.rb +++ b/lib/jekyll/hooks.rb @@ -77,9 +77,7 @@ def self.register_one(owner, event, priority, &block) "following hooks #{@registry[owner].keys.inspect}" end - unless block.respond_to? :call - raise Uncallable, "Hooks must respond to :call" - end + raise Uncallable, "Hooks must respond to :call" unless block.respond_to? :call insert_hook owner, event, priority, &block end diff --git a/lib/jekyll/liquid_extensions.rb b/lib/jekyll/liquid_extensions.rb index 4551ac19bbd..87e06ef7c7e 100644 --- a/lib/jekyll/liquid_extensions.rb +++ b/lib/jekyll/liquid_extensions.rb @@ -2,7 +2,6 @@ module Jekyll module LiquidExtensions - # Lookup a Liquid variable in the given context. # # context - the Liquid context in question. @@ -19,6 +18,5 @@ def lookup_variable(context, variable) lookup || variable end - end end diff --git a/lib/jekyll/liquid_renderer/table.rb b/lib/jekyll/liquid_renderer/table.rb index b2d91fecd6f..b60802681b4 100644 --- a/lib/jekyll/liquid_renderer/table.rb +++ b/lib/jekyll/liquid_renderer/table.rb @@ -1,96 +1,98 @@ # frozen_string_literal: true module Jekyll - class LiquidRenderer::Table - def initialize(stats) - @stats = stats - end + class LiquidRenderer + class Table + def initialize(stats) + @stats = stats + end - def to_s(num_of_rows = 50) - data = data_for_table(num_of_rows) - widths = table_widths(data) - generate_table(data, widths) - end + def to_s(num_of_rows = 50) + data = data_for_table(num_of_rows) + widths = table_widths(data) + generate_table(data, widths) + end - private + private - def generate_table(data, widths) - str = String.new("\n") + def generate_table(data, widths) + str = +"\n" - table_head = data.shift - str << generate_row(table_head, widths) - str << generate_table_head_border(table_head, widths) + table_head = data.shift + str << generate_row(table_head, widths) + str << generate_table_head_border(table_head, widths) - data.each do |row_data| - str << generate_row(row_data, widths) + data.each do |row_data| + str << generate_row(row_data, widths) + end + + str << "\n" + str end - str << "\n" - str - end + def generate_table_head_border(row_data, widths) + str = +"" - def generate_table_head_border(row_data, widths) - str = String.new("") + row_data.each_index do |cell_index| + str << "-" * widths[cell_index] + str << "-+-" unless cell_index == row_data.length - 1 + end - row_data.each_index do |cell_index| - str << "-" * widths[cell_index] - str << "-+-" unless cell_index == row_data.length - 1 + str << "\n" + str end - str << "\n" - str - end + def generate_row(row_data, widths) + str = +"" - def generate_row(row_data, widths) - str = String.new("") + row_data.each_with_index do |cell_data, cell_index| + str << if cell_index.zero? + cell_data.ljust(widths[cell_index], " ") + else + cell_data.rjust(widths[cell_index], " ") + end - row_data.each_with_index do |cell_data, cell_index| - str << if cell_index.zero? - cell_data.ljust(widths[cell_index], " ") - else - cell_data.rjust(widths[cell_index], " ") - end + str << " | " unless cell_index == row_data.length - 1 + end - str << " | " unless cell_index == row_data.length - 1 + str << "\n" + str end - str << "\n" - str - end - - def table_widths(data) - widths = [] + def table_widths(data) + widths = [] - data.each do |row| - row.each_with_index do |cell, index| - widths[index] = [cell.length, widths[index]].compact.max + data.each do |row| + row.each_with_index do |cell, index| + widths[index] = [cell.length, widths[index]].compact.max + end end + + widths end - widths - end + def data_for_table(num_of_rows) + sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] } + sorted = sorted.slice(0, num_of_rows) - def data_for_table(num_of_rows) - sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] } - sorted = sorted.slice(0, num_of_rows) + table = [%w(Filename Count Bytes Time)] - table = [%w(Filename Count Bytes Time)] + sorted.each do |filename, file_stats| + row = [] + row << filename + row << file_stats[:count].to_s + row << format_bytes(file_stats[:bytes]) + row << format("%.3f", file_stats[:time]) + table << row + end - sorted.each do |filename, file_stats| - row = [] - row << filename - row << file_stats[:count].to_s - row << format_bytes(file_stats[:bytes]) - row << format("%.3f", file_stats[:time]) - table << row + table end - table - end - - def format_bytes(bytes) - bytes /= 1024.0 - format("%.2fK", bytes) + def format_bytes(bytes) + bytes /= 1024.0 + format("%.2fK", bytes) + end end end end diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 9843b10165f..965786a0768 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -95,11 +95,11 @@ def template # # Returns the String url. def url - @url ||= URL.new({ + @url ||= URL.new( :template => template, :placeholders => url_placeholders, - :permalink => permalink, - }).to_s + :permalink => permalink + ).to_s end # Returns a hash of URL placeholder names (as symbols) mapping to the diff --git a/lib/jekyll/plugin.rb b/lib/jekyll/plugin.rb index 2a9dbeed41b..1157e12a688 100644 --- a/lib/jekyll/plugin.rb +++ b/lib/jekyll/plugin.rb @@ -13,7 +13,7 @@ class Plugin # def self.inherited(const) - return catch_inheritance(const) do |const_| + catch_inheritance(const) do |const_| catch_inheritance(const_) end end @@ -23,9 +23,7 @@ def self.inherited(const) def self.catch_inheritance(const) const.define_singleton_method :inherited do |const_| (@children ||= Set.new).add const_ - if block_given? - yield const_ - end + yield const_ if block_given? end end @@ -48,9 +46,7 @@ def self.descendants # Returns the Symbol priority. def self.priority(priority = nil) @priority ||= nil - if priority && PRIORITIES.key?(priority) - @priority = priority - end + @priority = priority if priority && PRIORITIES.key?(priority) @priority || :normal end @@ -62,9 +58,7 @@ def self.priority(priority = nil) # # Returns the safety Boolean. def self.safe(safe = nil) - unless defined?(@safe) && safe.nil? - @safe = safe - end + @safe = safe unless defined?(@safe) && safe.nil? @safe || false end @@ -74,7 +68,7 @@ def self.safe(safe = nil) # # Returns -1, 0, 1. def self.<=>(other) - PRIORITIES[other.priority] <=> PRIORITIES[self.priority] + PRIORITIES[other.priority] <=> PRIORITIES[priority] end # Spaceship is priority [higher -> lower] diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index fed76a16303..78a76e97921 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -76,9 +76,7 @@ def retrieve_dirs(_base, dir, dot_dirs) dot_dirs.each do |file| dir_path = site.in_source_dir(dir, file) rel_path = File.join(dir, file) - unless @site.dest.chomp("/") == dir_path - @site.reader.read_directories(rel_path) - end + @site.reader.read_directories(rel_path) unless @site.dest.chomp("/") == dir_path end end diff --git a/lib/jekyll/readers/data_reader.rb b/lib/jekyll/readers/data_reader.rb index 445d548802b..8d5803cbec8 100644 --- a/lib/jekyll/readers/data_reader.rb +++ b/lib/jekyll/readers/data_reader.rb @@ -54,16 +54,14 @@ def read_data_to(dir, data) def read_data_file(path) case File.extname(path).downcase when ".csv" - CSV.read(path, { - :headers => true, - :encoding => site.config["encoding"], - }).map(&:to_hash) + CSV.read(path, + :headers => true, + :encoding => site.config["encoding"]).map(&:to_hash) when ".tsv" - CSV.read(path, { - :col_sep => "\t", - :headers => true, - :encoding => site.config["encoding"], - }).map(&:to_hash) + CSV.read(path, + :col_sep => "\t", + :headers => true, + :encoding => site.config["encoding"]).map(&:to_hash) else SafeYAML.load_file(path) end diff --git a/lib/jekyll/readers/layout_reader.rb b/lib/jekyll/readers/layout_reader.rb index 706dfed8c43..f1dbe5993a3 100644 --- a/lib/jekyll/readers/layout_reader.rb +++ b/lib/jekyll/readers/layout_reader.rb @@ -63,9 +63,7 @@ def layout_directory_inside_source def layout_directory_in_cwd dir = Jekyll.sanitized_path(Dir.pwd, site.config["layouts_dir"]) - if File.directory?(dir) && !site.safe - dir - end + dir if File.directory?(dir) && !site.safe end end end diff --git a/lib/jekyll/readers/post_reader.rb b/lib/jekyll/readers/post_reader.rb index b0dc30326b5..050bd9308b8 100644 --- a/lib/jekyll/readers/post_reader.rb +++ b/lib/jekyll/readers/post_reader.rb @@ -62,10 +62,9 @@ def read_content(dir, magic_dir, matcher) @site.reader.get_entries(dir, magic_dir).map do |entry| next unless entry =~ matcher path = @site.in_source_dir(File.join(dir, magic_dir, entry)) - Document.new(path, { - :site => @site, - :collection => @site.posts, - }) + Document.new(path, + :site => @site, + :collection => @site.posts) end.reject(&:nil?) end end diff --git a/lib/jekyll/readers/theme_assets_reader.rb b/lib/jekyll/readers/theme_assets_reader.rb index 2706690c5ce..afccf8130d6 100644 --- a/lib/jekyll/readers/theme_assets_reader.rb +++ b/lib/jekyll/readers/theme_assets_reader.rb @@ -8,7 +8,7 @@ def initialize(site) end def read - return unless site.theme && site.theme.assets_path + return unless site.theme&.assets_path Find.find(site.theme.assets_path) do |path| next if File.directory?(path) @@ -21,6 +21,7 @@ def read end private + def read_theme_asset(path) base = site.theme.root dir = File.dirname(path.sub("#{site.theme.root}/", "")) @@ -28,18 +29,18 @@ def read_theme_asset(path) if Utils.has_yaml_header?(path) append_unless_exists site.pages, - Jekyll::Page.new(site, base, dir, name) + Jekyll::Page.new(site, base, dir, name) else append_unless_exists site.static_files, - Jekyll::StaticFile.new(site, base, "/#{dir}", name) + Jekyll::StaticFile.new(site, base, "/#{dir}", name) end end def append_unless_exists(haystack, new_item) if haystack.any? { |file| file.relative_path == new_item.relative_path } Jekyll.logger.debug "Theme:", - "Ignoring #{new_item.relative_path} in theme due to existing file " \ - "with that path in site." + "Ignoring #{new_item.relative_path} in theme due to existing file " \ + "with that path in site." return end diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 864bb0c8072..444b7884438 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -28,9 +28,7 @@ def regenerate?(document) regenerate_document?(document) else source_path = document.respond_to?(:path) ? document.path : nil - dest_path = if document.respond_to?(:destination) - document.destination(@site.dest) - end + dest_path = document.destination(@site.dest) if document.respond_to?(:destination) source_modified_or_dest_missing?(source_path, dest_path) end end @@ -89,9 +87,7 @@ def modified?(path) return true if path.nil? # Check for path in cache - if cache.key? path - return cache[path] - end + return cache[path] if cache.key? path if metadata[path] # If we have seen this file before, @@ -183,9 +179,7 @@ def existing_file_modified?(path) # If one of this file dependencies have been modified, # set the regeneration bit for both the dependency and the file to true metadata[path]["deps"].each do |dependency| - if modified?(dependency) - return cache[dependency] = cache[path] = true - end + return cache[dependency] = cache[path] = true if modified?(dependency) end if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path)) diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index acd9a4ee426..030b9a3cf58 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -101,8 +101,8 @@ def convert(content) converter.convert output rescue StandardError => e Jekyll.logger.error "Conversion error:", - "#{converter.class} encountered an error while "\ - "converting '#{document.relative_path}':" + "#{converter.class} encountered an error while "\ + "converting '#{document.relative_path}':" Jekyll.logger.error("", e.to_s) raise e end @@ -121,13 +121,13 @@ def render_liquid(content, payload, info, path = nil) template = site.liquid_renderer.file(path).parse(content) template.warnings.each do |e| Jekyll.logger.warn "Liquid Warning:", - LiquidRenderer.format_error(e, path || document.relative_path) + LiquidRenderer.format_error(e, path || document.relative_path) end template.render!(payload, info) # rubocop: disable RescueException rescue Exception => e Jekyll.logger.error "Liquid Exception:", - LiquidRenderer.format_error(e, path || document.relative_path) + LiquidRenderer.format_error(e, path || document.relative_path) raise e end # rubocop: enable RescueException @@ -213,9 +213,7 @@ def add_regenerator_dependencies(layout) # Returns nothing def assign_pages! payload["page"] = document.to_liquid - payload["paginator"] = if document.respond_to?(:pager) - document.pager.to_liquid - end + payload["paginator"] = (document.pager.to_liquid if document.respond_to?(:pager)) end # Set related posts to payload if document is a post. @@ -235,9 +233,7 @@ def assign_highlighter_options! def assign_layout_data! layout = layouts[document.data["layout"]] - if layout - payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) - end + payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) if layout end def permalink_ext diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 6264c102bba..5c4ac78e83c 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -44,8 +44,8 @@ def config=(config) @config = config.clone %w(safe lsi highlighter baseurl exclude include future unpublished - show_drafts limit_posts keep_files).each do |opt| - self.send("#{opt}=", config[opt]) + show_drafts limit_posts keep_files).each do |opt| + send("#{opt}=", config[opt]) end # keep using `gems` to avoid breaking change @@ -98,9 +98,7 @@ def reset @liquid_renderer.reset @site_cleaner = nil - if limit_posts < 0 - raise ArgumentError, "limit_posts must be a non-negative number" - end + raise ArgumentError, "limit_posts must be a non-negative number" if limit_posts.negative? Jekyll::Hooks.trigger :site, :after_reset, self end @@ -124,7 +122,7 @@ def ensure_not_in_dest Pathname.new(source).ascend do |path| if path == dest_pathname raise Errors::FatalException, - "Destination directory cannot be or contain the Source directory." + "Destination directory cannot be or contain the Source directory." end end end @@ -174,7 +172,7 @@ def generate start = Time.now generator.generate(self) Jekyll.logger.debug "Generating:", - "#{generator.class} finished in #{Time.now - start} seconds." + "#{generator.class} finished in #{Time.now - start} seconds." end end @@ -234,7 +232,7 @@ def post_attr_hash(post_attr) # array of posts ) then sort each array in reverse order. hash = Hash.new { |h, key| h[key] = [] } posts.docs.each do |p| - p.data[post_attr].each { |t| hash[t] << p } if p.data[post_attr] + p.data[post_attr]&.each { |t| hash[t] << p } end hash.each_value { |posts| posts.sort!.reverse! } hash @@ -303,10 +301,10 @@ def instantiate_subclasses(klass) def relative_permalinks_are_deprecated if config["relative_permalinks"] Jekyll.logger.abort_with "Since v3.0, permalinks for pages" \ - " in subfolders must be relative to the" \ - " site source directory, not the parent" \ - " directory. Check https://jekyllrb.com/docs/upgrading/"\ - " for more info." + " in subfolders must be relative to the" \ + " site source directory, not the parent" \ + " directory. Check https://jekyllrb.com/docs/upgrading/"\ + " for more info." end end @@ -409,9 +407,9 @@ def collections_path # # Returns nothing def limit_posts! - if limit_posts > 0 + if limit_posts.positive? limit = posts.docs.length < limit_posts ? posts.docs.length : limit_posts - self.posts.docs = posts.docs[-limit, limit] + posts.docs = posts.docs[-limit, limit] end end @@ -444,12 +442,12 @@ def configure_theme def configure_include_paths @includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s)) - @includes_load_paths << theme.includes_path if theme && theme.includes_path + @includes_load_paths << theme.includes_path if theme&.includes_path end def configure_file_read_opts self.file_read_opts = {} - self.file_read_opts[:encoding] = config["encoding"] if config["encoding"] + file_read_opts[:encoding] = config["encoding"] if config["encoding"] self.file_read_opts = Jekyll::Utils.merged_file_read_opts(self, {}) end diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index ea89b6d2be9..01c950d8a93 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -133,10 +133,10 @@ def url @url ||= if @collection.nil? relative_path else - ::Jekyll::URL.new({ + ::Jekyll::URL.new( :template => @collection.url_template, - :placeholders => placeholders, - }) + :placeholders => placeholders + ) end.to_s.chomp("/") end @@ -152,6 +152,7 @@ def defaults end private + def copy_file(dest_path) if @site.safe || Jekyll.env == "production" FileUtils.cp(path, dest_path) diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index bbec66171f6..1d27bcd884f 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -16,9 +16,7 @@ def add(severity, message = nil, progname = nil) severity ||= UNKNOWN @logdev = logdevice(severity) - if @logdev.nil? || severity < @level - return true - end + return true if @logdev.nil? || severity < @level progname ||= @progname if message.nil? if block_given? diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index e2ef3adb038..78e4f5ed081 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -18,13 +18,13 @@ def initialize(tag_name, markup, tokens) @lang = Regexp.last_match(1).downcase @highlight_options = parse_options(Regexp.last_match(2)) else - raise SyntaxError, <<-MSG -Syntax Error in tag 'highlight' while parsing the following markup: + raise SyntaxError, <<~MSG + Syntax Error in tag 'highlight' while parsing the following markup: - #{markup} + #{markup} -Valid syntax: highlight [linenos] -MSG + Valid syntax: highlight [linenos] + MSG end end @@ -75,7 +75,7 @@ def parse_options(input) input.scan(OPTIONS_REGEX) do |opt| key, value = opt.split("=") # If a quoted list, convert to array - if value && value.include?('"') + if value&.include?('"') value.delete!('"') value = value.split end @@ -96,14 +96,14 @@ def render_pygments(code, is_safe) ) if highlighted_code.nil? - Jekyll.logger.error <<-MSG -There was an error highlighting your code: + Jekyll.logger.error <<~MSG + There was an error highlighting your code: -#{code} + #{code} -While attempting to convert the above code, Pygments.rb returned an unacceptable value. -This is usually a timeout problem solved by running `jekyll build` again. -MSG + While attempting to convert the above code, Pygments.rb returned an unacceptable value. + This is usually a timeout problem solved by running `jekyll build` again. + MSG raise ArgumentError, "Pygments.rb returned an unacceptable value "\ "when attempting to highlight some code." end diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index db31af7c1bb..389b6be9c79 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -55,31 +55,31 @@ def parse_params(context) def validate_file_name(file) if file =~ INVALID_SEQUENCES || file !~ VALID_FILENAME_CHARS - raise ArgumentError, <<-MSG -Invalid syntax for include tag. File contains invalid characters or sequences: + raise ArgumentError, <<~MSG + Invalid syntax for include tag. File contains invalid characters or sequences: - #{file} + #{file} -Valid syntax: + Valid syntax: - #{syntax_example} + #{syntax_example} -MSG + MSG end end def validate_params unless @params =~ FULL_VALID_SYNTAX - raise ArgumentError, <<-MSG -Invalid syntax for include tag: + raise ArgumentError, <<~MSG + Invalid syntax for include tag: - #{@params} + #{@params} -Valid syntax: + Valid syntax: - #{syntax_example} + #{syntax_example} -MSG + MSG end end @@ -138,7 +138,7 @@ def render(context) end def add_include_to_dependency(site, path, context) - if context.registers[:page] && context.registers[:page].key?("path") + if context.registers[:page]&.key?("path") site.regenerator.add_dependency( site.in_source_dir(context.registers[:page]["path"]), path diff --git a/lib/jekyll/tags/link.rb b/lib/jekyll/tags/link.rb index 9dc035f7453..124830e2719 100644 --- a/lib/jekyll/tags/link.rb +++ b/lib/jekyll/tags/link.rb @@ -5,7 +5,7 @@ module Tags class Link < Liquid::Tag class << self def tag_name - self.name.split("::").last.downcase + name.split("::").last.downcase end end @@ -27,11 +27,11 @@ def render(context) return item.url if item.relative_path == "/#{relative_path}" end - raise ArgumentError, <<-MSG -Could not find document '#{relative_path}' in tag '#{self.class.tag_name}'. + raise ArgumentError, <<~MSG + Could not find document '#{relative_path}' in tag '#{self.class.tag_name}'. -Make sure the document exists and the path is correct. -MSG + Make sure the document exists and the path is correct. + MSG end end end diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index db0b3fa06f6..b12d8d0a702 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -13,7 +13,7 @@ def initialize(name) all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER) unless all raise Jekyll::Errors::InvalidPostNameError, - "'#{name}' does not contain valid date and/or title." + "'#{name}' does not contain valid date and/or title." end escaped_slug = Regexp.escape(slug) @@ -22,8 +22,10 @@ def initialize(name) end def post_date - @post_date ||= Utils.parse_date(date, - "\"#{date}\" does not contain valid date and/or title.") + @post_date ||= Utils.parse_date( + date, + "'#{date}' does not contain valid date and/or title." + ) end def ==(other) @@ -38,6 +40,7 @@ def deprecated_equality(other) end private + # Construct the directory-aware post slug for a Jekyll::Post # # other - the Jekyll::Post @@ -60,13 +63,11 @@ def initialize(tag_name, post, tokens) begin @post = PostComparer.new(@orig_post) rescue StandardError => e - raise Jekyll::Errors::PostURLError, <<-MSG -Could not parse name of post "#{@orig_post}" in tag 'post_url'. - -Make sure the post exists and the name is correct. - -#{e.class}: #{e.message} -MSG + raise Jekyll::Errors::PostURLError, <<~MSG + Could not parse name of post "#{@orig_post}" in tag 'post_url'. + Make sure the post exists and the name is correct. + #{e.class}: #{e.message} + MSG end end @@ -90,11 +91,10 @@ def render(context) return p.url end - raise Jekyll::Errors::PostURLError, <<-MSG -Could not find post "#{@orig_post}" in tag 'post_url'. - -Make sure the post exists and the name is correct. -MSG + raise Jekyll::Errors::PostURLError, <<~MSG + Could not find post "#{@orig_post}" in tag 'post_url'. + Make sure the post exists and the name is correct. + MSG end end end diff --git a/lib/jekyll/theme.rb b/lib/jekyll/theme.rb index a21b4bdfea1..e649010890d 100644 --- a/lib/jekyll/theme.rb +++ b/lib/jekyll/theme.rb @@ -3,7 +3,7 @@ module Jekyll class Theme extend Forwardable - attr_reader :name + attr_reader :name def_delegator :gemspec, :version, :version def initialize(name) @@ -23,19 +23,19 @@ def root end def includes_path - @includes_path ||= path_for "_includes".freeze + @includes_path ||= path_for "_includes" end def layouts_path - @layouts_path ||= path_for "_layouts".freeze + @layouts_path ||= path_for "_layouts" end def sass_path - @sass_path ||= path_for "_sass".freeze + @sass_path ||= path_for "_sass" end def assets_path - @assets_path ||= path_for "assets".freeze + @assets_path ||= path_for "assets" end def configure_sass @@ -66,7 +66,7 @@ def gemspec @gemspec ||= Gem::Specification.find_by_name(name) rescue Gem::LoadError raise Jekyll::Errors::MissingDependencyException, - "The #{name} theme could not be found." + "The #{name} theme could not be found." end end end diff --git a/lib/jekyll/theme_builder.rb b/lib/jekyll/theme_builder.rb index 36ef71611d4..ac97e63aac7 100644 --- a/lib/jekyll/theme_builder.rb +++ b/lib/jekyll/theme_builder.rb @@ -1,119 +1,121 @@ # frozen_string_literal: true -class Jekyll::ThemeBuilder - SCAFFOLD_DIRECTORIES = %w( - assets _layouts _includes _sass - ).freeze - - attr_reader :name, :path, :code_of_conduct +module Jekyll + class ThemeBuilder + SCAFFOLD_DIRECTORIES = %w( + assets _layouts _includes _sass + ).freeze + + attr_reader :name, :path, :code_of_conduct + + def initialize(theme_name, opts) + @name = theme_name.to_s.tr(" ", "_").squeeze("_") + @path = Pathname.new(File.expand_path(name, Dir.pwd)) + @code_of_conduct = !!opts["code_of_conduct"] + end - def initialize(theme_name, opts) - @name = theme_name.to_s.tr(" ", "_").squeeze("_") - @path = Pathname.new(File.expand_path(name, Dir.pwd)) - @code_of_conduct = !!opts["code_of_conduct"] - end + def create! + create_directories + create_starter_files + create_gemspec + create_accessories + initialize_git_repo + end - def create! - create_directories - create_starter_files - create_gemspec - create_accessories - initialize_git_repo - end + def user_name + @user_name ||= `git config user.name`.chomp + end - def user_name - @user_name ||= `git config user.name`.chomp - end + def user_email + @user_email ||= `git config user.email`.chomp + end - def user_email - @user_email ||= `git config user.email`.chomp - end + private - private + def root + @root ||= Pathname.new(File.expand_path("../", __dir__)) + end - def root - @root ||= Pathname.new(File.expand_path("../", __dir__)) - end + def template_file(filename) + [ + root.join("theme_template", "#{filename}.erb"), + root.join("theme_template", filename.to_s), + ].find(&:exist?) + end - def template_file(filename) - [ - root.join("theme_template", "#{filename}.erb"), - root.join("theme_template", filename.to_s), - ].find(&:exist?) - end + def template(filename) + erb.render(template_file(filename).read) + end - def template(filename) - erb.render(template_file(filename).read) - end + def erb + @erb ||= ERBRenderer.new(self) + end - def erb - @erb ||= ERBRenderer.new(self) - end + def mkdir_p(directories) + Array(directories).each do |directory| + full_path = path.join(directory) + Jekyll.logger.info "create", full_path.to_s + FileUtils.mkdir_p(full_path) + end + end - def mkdir_p(directories) - Array(directories).each do |directory| - full_path = path.join(directory) + def write_file(filename, contents) + full_path = path.join(filename) Jekyll.logger.info "create", full_path.to_s - FileUtils.mkdir_p(full_path) + File.write(full_path, contents) end - end - - def write_file(filename, contents) - full_path = path.join(filename) - Jekyll.logger.info "create", full_path.to_s - File.write(full_path, contents) - end - def create_directories - mkdir_p(SCAFFOLD_DIRECTORIES) - end + def create_directories + mkdir_p(SCAFFOLD_DIRECTORIES) + end - def create_starter_files - %w(page post default).each do |layout| - write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html")) + def create_starter_files + %w(page post default).each do |layout| + write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html")) + end end - end - def create_gemspec - write_file("Gemfile", template("Gemfile")) - write_file("#{name}.gemspec", template("theme.gemspec")) - end + def create_gemspec + write_file("Gemfile", template("Gemfile")) + write_file("#{name}.gemspec", template("theme.gemspec")) + end - def create_accessories - accessories = %w(README.md LICENSE.txt) - accessories << "CODE_OF_CONDUCT.md" if code_of_conduct - accessories.each do |filename| - write_file(filename, template(filename)) + def create_accessories + accessories = %w(README.md LICENSE.txt) + accessories << "CODE_OF_CONDUCT.md" if code_of_conduct + accessories.each do |filename| + write_file(filename, template(filename)) + end end - end - def initialize_git_repo - Jekyll.logger.info "initialize", path.join(".git").to_s - Dir.chdir(path.to_s) { `git init` } - write_file(".gitignore", template("gitignore")) - end + def initialize_git_repo + Jekyll.logger.info "initialize", path.join(".git").to_s + Dir.chdir(path.to_s) { `git init` } + write_file(".gitignore", template("gitignore")) + end - class ERBRenderer - extend Forwardable + class ERBRenderer + extend Forwardable - def_delegator :@theme_builder, :name, :theme_name - def_delegator :@theme_builder, :user_name, :user_name - def_delegator :@theme_builder, :user_email, :user_email + def_delegator :@theme_builder, :name, :theme_name + def_delegator :@theme_builder, :user_name, :user_name + def_delegator :@theme_builder, :user_email, :user_email - def initialize(theme_builder) - @theme_builder = theme_builder - end + def initialize(theme_builder) + @theme_builder = theme_builder + end - def jekyll_version_with_minor - Jekyll::VERSION.split(".").take(2).join(".") - end + def jekyll_version_with_minor + Jekyll::VERSION.split(".").take(2).join(".") + end - def theme_directories - SCAFFOLD_DIRECTORIES - end + def theme_directories + SCAFFOLD_DIRECTORIES + end - def render(contents) - ERB.new(contents).result binding + def render(contents) + ERB.new(contents).result binding + end end end end diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 87f20e138eb..39c0b3cd1e6 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -98,8 +98,8 @@ def generate_url_from_drop(template) winner = pool.find { |key| @placeholders.key?(key) } if winner.nil? raise NoMethodError, - "The URL template doesn't have #{pool.join(" or ")} keys. "\ - "Check your permalink template!" + "The URL template doesn't have #{pool.join(" or ")} keys. "\ + "Check your permalink template!" end value = @placeholders[winner] diff --git a/lib/jekyll/utils/exec.rb b/lib/jekyll/utils/exec.rb index fee8b2d2e5b..5838ecba9e6 100644 --- a/lib/jekyll/utils/exec.rb +++ b/lib/jekyll/utils/exec.rb @@ -21,7 +21,6 @@ def run(*args) [stdin, stdout, stderr].each(&:close) [process.value, out + err] end - end end end diff --git a/lib/jekyll/utils/internet.rb b/lib/jekyll/utils/internet.rb index f723469b49a..945267f1e5d 100644 --- a/lib/jekyll/utils/internet.rb +++ b/lib/jekyll/utils/internet.rb @@ -3,7 +3,6 @@ module Jekyll module Utils module Internet - # Public: Determine whether the present device has a connection to # the Internet. This allows plugin writers which require the outside # world to have a neat fallback mechanism for offline building. @@ -18,7 +17,9 @@ module Internet # end # # Returns true if a DNS call can successfully be made, or false if not. + module_function + def connected? !dns("example.com").nil? end @@ -31,7 +32,6 @@ def dns(domain) rescue Resolv::ResolvError, Resolv::ResolvTimeout nil end - end end end diff --git a/lib/jekyll/utils/platforms.rb b/lib/jekyll/utils/platforms.rb index 6665527a726..e0e2e331a11 100644 --- a/lib/jekyll/utils/platforms.rb +++ b/lib/jekyll/utils/platforms.rb @@ -31,7 +31,7 @@ def vanilla_windows? # -- alias_method :really_windows?, \ - :vanilla_windows? + :vanilla_windows? # @@ -68,6 +68,7 @@ def linux? # private + def proc_version @proc_version ||= begin Pathutil.new( diff --git a/lib/jekyll/utils/thread_event.rb b/lib/jekyll/utils/thread_event.rb index 5afb50d93eb..801022e4721 100644 --- a/lib/jekyll/utils/thread_event.rb +++ b/lib/jekyll/utils/thread_event.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "thread" - module Jekyll module Utils # Based on the pattern and code from @@ -25,9 +23,7 @@ def set def wait @lock.synchronize do - unless @flag - @cond.wait(@lock) - end + @cond.wait(@lock) unless @flag end end end diff --git a/lib/jekyll/utils/win_tz.rb b/lib/jekyll/utils/win_tz.rb index 239650f71fe..965cbc95be3 100644 --- a/lib/jekyll/utils/win_tz.rb +++ b/lib/jekyll/utils/win_tz.rb @@ -21,7 +21,7 @@ def calculate(timezone) # is denoted as: # EST+5 (or) EST+05:00 # Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html - sign = difference < 0 ? "-" : "+" + sign = difference.negative? ? "-" : "+" offset = sign == "-" ? "+" : "-" unless difference.zero? # # convert the difference (in seconds) to hours, as a rational number, and perform diff --git a/lib/jekyll/version.rb b/lib/jekyll/version.rb index 0a6a8a2d3d7..5934f0a34d3 100644 --- a/lib/jekyll/version.rb +++ b/lib/jekyll/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Jekyll - VERSION = "3.8.2".freeze + VERSION = "3.8.2" end From 035ea729ff5668dfc96e7f56a86d214e5a633291 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 2 Jun 2018 06:50:34 -0400 Subject: [PATCH 271/337] Update history to reflect merge of #7050 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 20e4bf01a7e..401263ca44e 100644 --- a/History.markdown +++ b/History.markdown @@ -50,6 +50,7 @@ * Load Rouge for TestKramdown (#7007) * Useless privates removed (#6768) * Allow i18n v0.9.5 and higher (#7044) + * Update Rubocop's config (#7050) ### Bug Fixes From 0e360623cbffd75676882c2e83660d716e5d5bcb Mon Sep 17 00:00:00 2001 From: Keith Mifsud Date: Sat, 2 Jun 2018 23:41:27 +0545 Subject: [PATCH 272/337] Listed the keyll-target-blank plugin in plugins list. (#7046) Merge pull request 7046 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index 1c3332e3fb9..2b3f758bbcc 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -787,6 +787,7 @@ You can find a few useful plugins at the following locations: - [Jekyll::Paginate::Content](https://github.com/ibrado/jekyll-paginate-content): Content paginator in the style of jekyll-paginator-v2 that splits pages, posts, and collection entries into several pages. Specify a separator or use HTML <h1> etc. headers. Automatic splitting, single-page view, pager/trail, self-adjusting links, multipage TOC, SEO support. - [Premonition](https://github.com/amedia/premonition): Adds block-styled side content to your page. For example summary, notes, hints or warning boxes. - [jekyll-fontello](https://github.com/ericcornelissen/jekyll-fontello): A Jekyll plugin that automatically downloads your webfont from Fontello. +- [Target Blank](https://github.com/keithmifsud/jekyll-target-blank): A Jekyll plugin to automatically open external links in a new browser tab or window. #### Converters From c6415ce08158698a43c14fcb56fc1875b4ced153 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 2 Jun 2018 13:56:29 -0400 Subject: [PATCH 273/337] Update history to reflect merge of #7046 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 401263ca44e..59e97f07a72 100644 --- a/History.markdown +++ b/History.markdown @@ -22,6 +22,7 @@ * added the CAT plugin to the plugin list (#7011) * Updated to supported version (#7031) * Clarify definition of 'draft' (#7037) + * Listed the jekyll-target-blank plugin in plugins list. (#7046) ### Minor Enhancements From 5687a092554599e8c2cf1247764a7eaf87f3d05f Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Jun 2018 21:39:43 -0500 Subject: [PATCH 274/337] Release :gem: 3.8.3 --- History.markdown | 2 +- docs/_config.yml | 2 +- docs/_docs/history.md | 9 +++++++++ .../2018-06-04-jekyll-3-8-3-released.markdown | 13 +++++++++++++ docs/latest_version.txt | 2 +- lib/jekyll/version.rb | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 docs/_posts/2018-06-04-jekyll-3-8-3-released.markdown diff --git a/History.markdown b/History.markdown index b50563f8e3b..7c5bdb82e44 100644 --- a/History.markdown +++ b/History.markdown @@ -1,4 +1,4 @@ -## HEAD +## 3.8.3 / 2018-06-05 ### Bug Fixes diff --git a/docs/_config.yml b/docs/_config.yml index e608b1b6e8d..27ad51ffc8d 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,5 +1,5 @@ --- -version: 3.8.2 +version: 3.8.3 name: Jekyll • Simple, blog-aware, static sites description: Transform your plain text into static websites and blogs url: https://jekyllrb.com diff --git a/docs/_docs/history.md b/docs/_docs/history.md index 4a9faf7f29a..1e6c14d8716 100644 --- a/docs/_docs/history.md +++ b/docs/_docs/history.md @@ -4,6 +4,15 @@ permalink: "/docs/history/" note: This file is autogenerated. Edit /History.markdown instead. --- +## 3.8.3 / 2018-06-05 +{: #v3-8-3} + +### Bug Fixes +{: #bug-fixes-v3-8-3} + +- Fix --unpublished not affecting collection documents ([#7027]({{ site.repository }}/issues/7027)) + + ## 3.8.2 / 2018-05-18 {: #v3-8-2} diff --git a/docs/_posts/2018-06-04-jekyll-3-8-3-released.markdown b/docs/_posts/2018-06-04-jekyll-3-8-3-released.markdown new file mode 100644 index 00000000000..5678b0ad8b3 --- /dev/null +++ b/docs/_posts/2018-06-04-jekyll-3-8-3-released.markdown @@ -0,0 +1,13 @@ +--- +title: 'Jekyll 3.8.3 Released' +date: 2018-06-05 09:00:00 -0500 +author: pathawks +version: 3.8.3 +categories: [release] +--- + +This release fixes a regression in 3.8 where collections with `published: false` +do not show when using the `--unpublished` flag. + +Thanks to @philipbelesky for reporting and fixing this issue; collections with +`published: false` now behave the same way as Posts. diff --git a/docs/latest_version.txt b/docs/latest_version.txt index a08ffae0cae..269aa9c86de 100644 --- a/docs/latest_version.txt +++ b/docs/latest_version.txt @@ -1 +1 @@ -3.8.2 +3.8.3 diff --git a/lib/jekyll/version.rb b/lib/jekyll/version.rb index 0a6a8a2d3d7..9a62ec6f3af 100644 --- a/lib/jekyll/version.rb +++ b/lib/jekyll/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Jekyll - VERSION = "3.8.2".freeze + VERSION = "3.8.3".freeze end From 48e2de862d8396e6ff2f30e2231ac67c5f233b61 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Tue, 5 Jun 2018 08:23:52 -0500 Subject: [PATCH 275/337] Release :gem: 3.8.3 From 4baa0093edad6dc22eed43e2c33a82116e5bd354 Mon Sep 17 00:00:00 2001 From: Stephan Fischer Date: Tue, 5 Jun 2018 18:09:24 +0200 Subject: [PATCH 276/337] [Doc] Fixing a small typo (#7058) Merge pull request 7058 --- docs/_tutorials/using-jekyll-with-bundler.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_tutorials/using-jekyll-with-bundler.md b/docs/_tutorials/using-jekyll-with-bundler.md index 321f550516f..3aa34bbb0c6 100644 --- a/docs/_tutorials/using-jekyll-with-bundler.md +++ b/docs/_tutorials/using-jekyll-with-bundler.md @@ -90,7 +90,7 @@ If you're storing your new site in version control, you'll want to ignore the `./vendor/` and `./.bundle/` folders since they contain user- or platform-specific information. New users will be able to install the correct dependencies based on `Gemfile` and `Gemfile.lock`, which should both be checked -in. You can use this `.gitigonre` to get started, if you want. +in. You can use this `.gitignore` to get started, if you want. **.gitignore** From e47dad9d205648c9b3a1523489948415e59d8bd1 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Tue, 5 Jun 2018 12:09:26 -0400 Subject: [PATCH 277/337] Update history to reflect merge of #7058 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index f4d904819b8..35796fe27a2 100644 --- a/History.markdown +++ b/History.markdown @@ -23,6 +23,7 @@ * Updated to supported version (#7031) * Clarify definition of 'draft' (#7037) * Listed the jekyll-target-blank plugin in plugins list. (#7046) + * Typo (#7058) ### Minor Enhancements From 10b23f7466e1c3b144fd3a08a0e7783973434669 Mon Sep 17 00:00:00 2001 From: Patrick Favre-Bulle Date: Tue, 5 Jun 2018 19:27:02 +0200 Subject: [PATCH 278/337] Add Hints for some Improved Travis Config in Doc (#7049) Merge pull request 7049 --- .../_docs/continuous-integration/travis-ci.md | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/_docs/continuous-integration/travis-ci.md b/docs/_docs/continuous-integration/travis-ci.md index cbff5267e2e..cfca495c05e 100644 --- a/docs/_docs/continuous-integration/travis-ci.md +++ b/docs/_docs/continuous-integration/travis-ci.md @@ -90,7 +90,7 @@ Your `.travis.yml` file should look like this: ```yaml language: ruby rvm: -- 2.3.3 + - 2.4.1 before_script: - chmod +x ./script/cibuild # or do this locally and commit @@ -110,6 +110,12 @@ env: - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer sudo: false # route your build to the container-based infrastructure for a faster build + +cache: bundler # caching bundler gem packages will speed up build + +# Optional: disable email notifications about the outcome of your builds +notifications: + email: false ``` Ok, now for an explanation of each line: @@ -123,12 +129,13 @@ access to Bundler, RubyGems, and a Ruby runtime. ```yaml rvm: -- 2.3.3 + - 2.4.1 ``` RVM is a popular Ruby Version Manager (like rbenv, chruby, etc). This directive tells Travis the Ruby version to use when running your test -script. +script. Use a [version which is pre-installed on the Travis build docker][5] +image to speed up the build. ```yaml before_script: @@ -210,6 +217,23 @@ does need `sudo` access, modify the line to `sudo: required`. sudo: false ``` +To speed up the build, you should cache the gem packages created by `bundler`. +Travis has a pre-defined [cache strategy for this tool][6] which should have +all the default configs to do exactly that. + +```yaml +cache: bundler +``` + +Optionally, if you are not interested in the build email notifications you +can disable them with this configuration. Travis supports a wide array of +notification services, you may find [another one more useful (e.g. slack)][7]. + +```yaml +notifications: + email: false +``` + ### Troubleshooting **Travis error:** *"You are trying to install in deployment mode after changing @@ -227,3 +251,6 @@ fix or [ask for help][4] if you run into trouble and need some help. [3]: https://github.com/jekyll/jekyll/edit/master/docs/_docs/continuous-integration/travis-ci.md [4]: https://jekyllrb.com/help/ +[5]: https://docs.travis-ci.com/user/languages/ruby/#Specifying-Ruby-versions-and-implementations +[6]: https://docs.travis-ci.com/user/caching/#Caching-directories-(Bundler%2C-dependencies) +[7]: https://docs.travis-ci.com/user/notifications/ From baf70295f957a6b42542b260bf86168a2c955b33 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Tue, 5 Jun 2018 13:27:04 -0400 Subject: [PATCH 279/337] Update history to reflect merge of #7049 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 35796fe27a2..464efdcfb2b 100644 --- a/History.markdown +++ b/History.markdown @@ -24,6 +24,7 @@ * Clarify definition of 'draft' (#7037) * Listed the jekyll-target-blank plugin in plugins list. (#7046) * Typo (#7058) + * Add Hints for some Improved Travis Config in Doc (#7049) ### Minor Enhancements From cd996387a50dfc3599bbe7365815513a3bbc7eac Mon Sep 17 00:00:00 2001 From: chrisfinazzo Date: Mon, 11 Jun 2018 22:05:38 -0400 Subject: [PATCH 280/337] Remove Gemnasium badge --- README.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.markdown b/README.markdown index fe5e91f7b13..787d2c6cba7 100644 --- a/README.markdown +++ b/README.markdown @@ -5,11 +5,9 @@ [![Windows Build status](https://img.shields.io/appveyor/ci/jekyll/jekyll/master.svg?label=Windows%20build)][appveyor] [![Maintainability](https://api.codeclimate.com/v1/badges/8ba0cb5b17bb9848e128/maintainability)](codeclimate) [![Test Coverage](https://api.codeclimate.com/v1/badges/8ba0cb5b17bb9848e128/test_coverage)](coverage) -[![Dependency Status](https://img.shields.io/gemnasium/jekyll/jekyll.svg)][gemnasium] [![Security](https://hakiri.io/github/jekyll/jekyll/master.svg)][hakiri] [ruby-gems]: https://rubygems.org/gems/jekyll -[gemnasium]: https://gemnasium.com/jekyll/jekyll [codeclimate]: https://codeclimate.com/github/jekyll/jekyll [coverage]: https://codeclimate.com/github/jekyll/jekyll/coverage [hakiri]: https://hakiri.io/github/jekyll/jekyll/master From bbc9c99cf98b49c23600d9264a9d2cb09083f78b Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 17 Jun 2018 11:36:54 -0400 Subject: [PATCH 281/337] Remember to release docs gem (#7066) Merge pull request 7066 --- rake/release.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rake/release.rake b/rake/release.rake index ce7bf41ca94..7064f6751bd 100644 --- a/rake/release.rake +++ b/rake/release.rake @@ -18,6 +18,8 @@ task :release => :build do sh "git push origin #{current_branch}" sh "git push origin v#{version}" sh "gem push pkg/#{name}-#{version}.gem" + puts "Do not forget to build and release the docs gem as well." + puts "https://github.com/jekyll/jekyll-docs#releasing" end desc "Build #{name} v#{version} into pkg/" From 55ea4c840ba7f3d7279c679d677e16e62f0fd3eb Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 17 Jun 2018 11:36:56 -0400 Subject: [PATCH 282/337] Update history to reflect merge of #7066 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 464efdcfb2b..ba971abb7c6 100644 --- a/History.markdown +++ b/History.markdown @@ -54,6 +54,7 @@ * Useless privates removed (#6768) * Allow i18n v0.9.5 and higher (#7044) * Update Rubocop's config (#7050) + * Remember to release docs gem (#7066) ## 3.8.3 / 2018-06-05 From f0cbbbb304384ab7da646a622d1803c5c43d188e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pobo=C5=99il?= Date: Wed, 20 Jun 2018 17:43:48 +0200 Subject: [PATCH 283/337] Added plugin json-get. (#7086) Merge pull request 7086 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index 2b3f758bbcc..32cdb4a5b73 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -938,6 +938,7 @@ You can find a few useful plugins at the following locations: - [jekyll-pre-commit](https://github.com/mpchadwick/jekyll-pre-commit): A framework for running checks against your posts using a git pre-commit hook before you publish them. - [jekyll-pwa-plugin](https://github.com/lavas-project/jekyll-pwa): A plugin provides PWA support for Jekyll. It generates a service worker in Jekyll build process and makes precache and runtime cache available in the runtime with Google Workbox. - [jekyll-algolia](https://community.algolia.com/jekyll-algolia/): Add fast and relevant search to your Jekyll site through the Algolia API. +- [jekyll-get](https://github.com/18F/jekyll-get): Download data from external JSON API sources to use in generating a site.
Submit your gem plugins
From 8b63fbed6b06f3b36b1a4e797f2b5410d117aac6 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 20 Jun 2018 11:43:50 -0400 Subject: [PATCH 284/337] Update history to reflect merge of #7086 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index ba971abb7c6..647e544332a 100644 --- a/History.markdown +++ b/History.markdown @@ -25,6 +25,7 @@ * Listed the jekyll-target-blank plugin in plugins list. (#7046) * Typo (#7058) * Add Hints for some Improved Travis Config in Doc (#7049) + * Added plugin json-get. (#7086) ### Minor Enhancements From 1d461224ddf39f7a26edb4ebd40b0ffadf19dcee Mon Sep 17 00:00:00 2001 From: Anne Gentle Date: Thu, 21 Jun 2018 04:25:50 -0500 Subject: [PATCH 285/337] Update travis-ci.md (#7089) Merge pull request 7089 --- docs/_docs/continuous-integration/travis-ci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/continuous-integration/travis-ci.md b/docs/_docs/continuous-integration/travis-ci.md index cfca495c05e..b2fa78625cf 100644 --- a/docs/_docs/continuous-integration/travis-ci.md +++ b/docs/_docs/continuous-integration/travis-ci.md @@ -76,7 +76,7 @@ with Ruby and requires RubyGems to install, we use the Ruby language build environment. Below is a sample `.travis.yml` file, followed by an explanation of each line. -**Note:** You will need a Gemfile as well, [Travis will automatically install](https://docs.travis-ci.com/user/languages/ruby/#Dependency-Management) the dependencies based on the referenced gems: +**Note:** You will need a Gemfile as well, [Travis will automatically install](https://docs.travis-ci.com/user/languages/ruby/#Dependency-Management) the dependencies based on the referenced gems. Here is an example `Gemfile` with two referenced gems, "jekyll" and "html-proofer": ```ruby source "https://rubygems.org" From 76919eea3b3da8fe8f23150bf62fdb5ac178b282 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 21 Jun 2018 05:25:52 -0400 Subject: [PATCH 286/337] Update history to reflect merge of #7089 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 647e544332a..a0ef5b8d569 100644 --- a/History.markdown +++ b/History.markdown @@ -26,6 +26,7 @@ * Typo (#7058) * Add Hints for some Improved Travis Config in Doc (#7049) * Added plugin json-get. (#7086) + * Update travis-ci.md to point out "this is an example Gemfile" (#7089) ### Minor Enhancements From 76422b03b7725d196898ab15196e2c0ebb0679b5 Mon Sep 17 00:00:00 2001 From: Steven Westmoreland Date: Sat, 23 Jun 2018 08:27:30 -0500 Subject: [PATCH 287/337] Adding `jekyll-info` plugin (#7091) Merge pull request 7091 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index 32cdb4a5b73..ba18ce30d18 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -788,6 +788,7 @@ You can find a few useful plugins at the following locations: - [Premonition](https://github.com/amedia/premonition): Adds block-styled side content to your page. For example summary, notes, hints or warning boxes. - [jekyll-fontello](https://github.com/ericcornelissen/jekyll-fontello): A Jekyll plugin that automatically downloads your webfont from Fontello. - [Target Blank](https://github.com/keithmifsud/jekyll-target-blank): A Jekyll plugin to automatically open external links in a new browser tab or window. +- [jekyll-info](https://github.com/swestmoreland/jekyll-info): A plugin to provide information about your Jekyll site’s configuration. #### Converters From 3204445d6f2edce50fe9372684395be60e7b11a3 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 23 Jun 2018 09:27:32 -0400 Subject: [PATCH 288/337] Update history to reflect merge of #7091 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index a0ef5b8d569..6f7d45a2b2d 100644 --- a/History.markdown +++ b/History.markdown @@ -27,6 +27,7 @@ * Add Hints for some Improved Travis Config in Doc (#7049) * Added plugin json-get. (#7086) * Update travis-ci.md to point out "this is an example Gemfile" (#7089) + * Adding `jekyll-info` plugin (#7091) ### Minor Enhancements From 0b6962cfe976819b577059e8535fde5b3d3c7e58 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 23 Jun 2018 16:57:35 -0400 Subject: [PATCH 289/337] Use assert_include (#7093) Merge pull request 7093 --- test/test_generated_site.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 7ce093536ff..65b82fe8b3a 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -20,15 +20,15 @@ class TestGeneratedSite < JekyllUnitTest end should "insert site.posts into the index" do - assert @index.include?("#{@site.posts.size} Posts") + assert_includes @index, "#{@site.posts.size} Posts" end should "insert variable from layout into the index" do - assert @index.include?("variable from layout") + assert_includes @index, "variable from layout" end should "render latest post's content" do - assert @index.include?(@site.posts.last.content) + assert_includes @index, @site.posts.last.content end should "hide unpublished posts" do From 0728ccf08b08759d75b6bac40091151a80556565 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sat, 23 Jun 2018 16:57:36 -0400 Subject: [PATCH 290/337] Update history to reflect merge of #7093 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 6f7d45a2b2d..15537802fe6 100644 --- a/History.markdown +++ b/History.markdown @@ -58,6 +58,7 @@ * Allow i18n v0.9.5 and higher (#7044) * Update Rubocop's config (#7050) * Remember to release docs gem (#7066) + * Use assert_include (#7093) ## 3.8.3 / 2018-06-05 From cb84017bbe1eae2bd8accfd83d3cbb5ce3e80437 Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 25 Jun 2018 21:43:33 -0400 Subject: [PATCH 291/337] Update rubocop version to 0.57.x (#7078) Merge pull request 7078 --- .rubocop.yml | 2 ++ Gemfile | 2 +- lib/jekyll/drops/drop.rb | 6 +----- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9edab2bd064..81e11e29765 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -98,6 +98,8 @@ Security/YAMLLoad: Exclude: - !ruby/regexp /features\/.*.rb/ - !ruby/regexp /test\/.*.rb$/ +Style/AccessModifierDeclarations: + Enabled: false Style/Alias: EnforcedStyle: prefer_alias_method Style/AndOr: diff --git a/Gemfile b/Gemfile index ce43b6798f9..34e9be49859 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 0.56.0" + gem "rubocop", "~> 0.57.2" 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__) diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 412c279145e..208b266b370 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -15,11 +15,7 @@ class Drop < Liquid::Drop # # Returns the mutability of the class def self.mutable(is_mutable = nil) - @is_mutable = if is_mutable - is_mutable - else - false - end + @is_mutable = is_mutable || false end def self.mutable? From caae9d2ecaa130eeab916e1df2daba45bcd8adf2 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 25 Jun 2018 21:43:35 -0400 Subject: [PATCH 292/337] Update history to reflect merge of #7078 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 15537802fe6..c61043a4197 100644 --- a/History.markdown +++ b/History.markdown @@ -59,6 +59,7 @@ * Update Rubocop's config (#7050) * Remember to release docs gem (#7066) * Use assert_include (#7093) + * Update rubocop version to 0.57.x (#7078) ## 3.8.3 / 2018-06-05 From e418d9b2f4f52f688de031da1ef997ea46fffd2b Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Fri, 29 Jun 2018 12:36:37 -0700 Subject: [PATCH 293/337] Example of CircleCI deployment through CircleCI v2 (#7024) Merge pull request 7024 --- docs/_docs/continuous-integration/circleci.md | 71 ++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/docs/_docs/continuous-integration/circleci.md b/docs/_docs/continuous-integration/circleci.md index b4aadc616b4..baf5f78ea17 100644 --- a/docs/_docs/continuous-integration/circleci.md +++ b/docs/_docs/continuous-integration/circleci.md @@ -61,7 +61,7 @@ test: ## Complete Example circle.yml File -When you put it all together, here's an example of what that `circle.yml` file could look like: +When you put it all together, here's an example of what that `circle.yml` file could look like in v1: ```yaml machine: @@ -83,6 +83,75 @@ deployment: - rsync -va --delete ./_site username@my-website:/var/html ``` +for CircleCI v2, a Docker-based system which new projects will follow, set the `S3_BUCKET_NAME` environment variable (an example of the required config file is shown below). + +```yaml +defaults: &defaults + working_directory: ~/repo +version: 2 +jobs: + build: + <<: *defaults + docker: + - image: circleci/ruby:2.5 + environment: + BUNDLE_PATH: ~/repo/vendor/bundle + steps: + - checkout + - restore_cache: + keys: + - rubygems-v1-{{ checksum "Gemfile.lock" }} + - rubygems-v1-fallback + - run: + name: Bundle Install + command: bundle check || bundle install + - run: + name: HTMLProofer tests + command: | + bundle exec htmlproofer ./_site \ + --allow-hash-href \ + --check-favicon \ + --check-html \ + --disable-external + - save_cache: + key: rubygems-v1-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + - run: + name: Jekyll build + command: bundle exec jekyll build + - persist_to_workspace: + root: ./ + paths: + - _site + deploy: + <<: *defaults + docker: + - image: circleci/python:3.6.3 + environment: + S3_BUCKET_NAME: <> + steps: + - attach_workspace: + at: ./ + - run: + name: Install AWS CLI + command: pip install awscli --upgrade --user + - run: + name: Upload to s3 + command: ~/.local/bin/aws s3 sync ./_site s3://$S3_BUCKET_NAME/ --delete --acl public-read +workflows: + version: 2 + test-deploy: + jobs: + - build + - deploy: + requires: + - build + filters: + branches: + only: master +``` + ## Questions? This entire guide is open-source. Go ahead and [edit it][7] if you have a fix or [ask for help][8] if you run into trouble and need some help. CircleCI also has an [online community][9] for help. From 4d96e4b7bde82c3d68510828152b81a5d679a2bf Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Fri, 29 Jun 2018 15:36:39 -0400 Subject: [PATCH 294/337] Update history to reflect merge of #7024 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index c61043a4197..58d812be7eb 100644 --- a/History.markdown +++ b/History.markdown @@ -61,6 +61,10 @@ * Use assert_include (#7093) * Update rubocop version to 0.57.x (#7078) +### -docs + + * Example of CircleCI deployment through CircleCI v2 (#7024) + ## 3.8.3 / 2018-06-05 ### Bug Fixes From 43f4fc6c70a5f1f1aac1b2438a9c7fb47bad8aac Mon Sep 17 00:00:00 2001 From: Boris van Hoytema Date: Fri, 6 Jul 2018 20:47:03 +0200 Subject: [PATCH 295/337] GitHub enables you to use themes from other repos (#7112) Merge pull request 7112 --- docs/_docs/themes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/themes.md b/docs/_docs/themes.md index b9fdf5ecaf4..d4b8aa6d2b5 100644 --- a/docs/_docs/themes.md +++ b/docs/_docs/themes.md @@ -201,7 +201,7 @@ To install a gem-based theme: You can have multiple themes listed in your site's `Gemfile`, but only one theme can be selected in your site's `_config.yml`. {: .note .info } -If you're publishing your Jekyll site on [GitHub Pages](https://pages.github.com/), note that GitHub Pages supports only some gem-based themes. See [Supported Themes](https://pages.github.com/themes/) in GitHub's documentation to see which themes are supported. +If you're publishing your Jekyll site on [GitHub Pages](https://pages.github.com/), note that GitHub Pages supports only [some gem-based themes](https://pages.github.com/themes/). GitHub Pages also supports [using any theme hosted on GitHub](https://help.github.com/articles/adding-a-jekyll-theme-to-your-github-pages-site/#adding-a-jekyll-theme-in-your-sites-_configyml-file) using the `remote_theme` configuration as if it were a gem-based theme. ## Creating a gem-based theme From bfd58fa94932f71d32fc8593103e0b358cd6f968 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Fri, 6 Jul 2018 14:47:05 -0400 Subject: [PATCH 296/337] Update history to reflect merge of #7112 [ci skip] --- History.markdown | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/History.markdown b/History.markdown index 58d812be7eb..63f1220a6da 100644 --- a/History.markdown +++ b/History.markdown @@ -28,6 +28,7 @@ * Added plugin json-get. (#7086) * Update travis-ci.md to point out "this is an example Gemfile" (#7089) * Adding `jekyll-info` plugin (#7091) + * GitHub enables you to use themes from other repos (#7112) ### Minor Enhancements @@ -59,10 +60,7 @@ * Update Rubocop's config (#7050) * Remember to release docs gem (#7066) * Use assert_include (#7093) - * Update rubocop version to 0.57.x (#7078) - -### -docs - + * Update rubocop version to 0.57.x ### -docs (#7078) * Example of CircleCI deployment through CircleCI v2 (#7024) ## 3.8.3 / 2018-06-05 From 70f4d4908de10239b4774210a0e720b7df3b32f9 Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Sat, 7 Jul 2018 13:01:41 +0200 Subject: [PATCH 297/337] Fix: Escape Liquid --- docs/_docs/continuous-integration/circleci.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_docs/continuous-integration/circleci.md b/docs/_docs/continuous-integration/circleci.md index baf5f78ea17..ce58a0092ae 100644 --- a/docs/_docs/continuous-integration/circleci.md +++ b/docs/_docs/continuous-integration/circleci.md @@ -100,7 +100,7 @@ jobs: - checkout - restore_cache: keys: - - rubygems-v1-{{ checksum "Gemfile.lock" }} + - rubygems-v1-{% raw %}{{ checksum "Gemfile.lock" }}{% endraw %} - rubygems-v1-fallback - run: name: Bundle Install @@ -114,7 +114,7 @@ jobs: --check-html \ --disable-external - save_cache: - key: rubygems-v1-{{ checksum "Gemfile.lock" }} + key: rubygems-v1-{% raw %}{{ checksum "Gemfile.lock" }}{% endraw %} paths: - vendor/bundle - run: From 385bf36724e87a597feacf9c041292f005ededca Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Mon, 9 Jul 2018 03:04:41 +0900 Subject: [PATCH 298/337] Updates to v1.4 (#7105) Merge pull request 7105 --- CODE_OF_CONDUCT.markdown | 67 +++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/CODE_OF_CONDUCT.markdown b/CODE_OF_CONDUCT.markdown index 8425dfc7a93..7d1d32140b4 100644 --- a/CODE_OF_CONDUCT.markdown +++ b/CODE_OF_CONDUCT.markdown @@ -1,49 +1,46 @@ # Code of Conduct -As contributors and maintainers of this project, and in the interest of -fostering an open and welcoming community, we pledge to respect all people who -contribute through reporting issues, posting feature requests, updating -documentation, submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project a harassment-free -experience for everyone, regardless of level of experience, gender, gender -identity and expression, sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment -* Publishing other's private information, such as physical or electronic - addresses, without explicit permission -* Other unethical or unprofessional conduct +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. -By adopting this Code of Conduct, project maintainers commit themselves to -fairly and consistently applying these principles to every aspect of managing -this project. Project maintainers who do not follow or enforce the Code of -Conduct may be permanently removed from the project team. +## Enforcement -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting a project maintainer. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by opening an issue or contacting a project maintainer. All complaints -will be reviewed and investigated and will result in a response that is deemed -necessary and appropriate to the circumstances. Maintainers are obligated to -maintain confidentiality with regard to the reporter of an incident. +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 1.3.0, available at -[http://contributor-covenant.org/version/1/3/0/][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html][version] -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/3/0/ +[homepage]: https://www.contributor-covenant.org/ +[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html From 565567ac08ac1c3db5129aa55e3c6996f2070c82 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 8 Jul 2018 14:04:43 -0400 Subject: [PATCH 299/337] Update history to reflect merge of #7105 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 63f1220a6da..f8aa4ecdba2 100644 --- a/History.markdown +++ b/History.markdown @@ -29,6 +29,7 @@ * Update travis-ci.md to point out "this is an example Gemfile" (#7089) * Adding `jekyll-info` plugin (#7091) * GitHub enables you to use themes from other repos (#7112) + * Updates to CODE OF CONDUCT (v1.4.0) (#7105) ### Minor Enhancements From d57715031a3c8fea19e7eaa4b46376f42111ee43 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Mon, 9 Jul 2018 03:12:11 +0900 Subject: [PATCH 300/337] =?UTF-8?q?Instructions=20to=20view=20theme?= =?UTF-8?q?=E2=80=99s=20files=20under=20Linux=20(#7095)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge pull request 7095 --- docs/_docs/themes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/_docs/themes.md b/docs/_docs/themes.md index d4b8aa6d2b5..b8f469e5d7f 100644 --- a/docs/_docs/themes.md +++ b/docs/_docs/themes.md @@ -52,6 +52,8 @@ To locate a theme's files on your computer: open $(bundle show minima) # On Windows explorer /usr/local/lib/ruby/gems/2.3.0/gems/minima-2.1.0 + # On Linux + xdg-open $(bundle show minima) ``` A Finder or Explorer window opens showing the theme's files and directories. The Minima theme gem contains these files: From caa0846e7bef0e95312a0122041b7c41b7bd201c Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 8 Jul 2018 14:12:13 -0400 Subject: [PATCH 301/337] Update history to reflect merge of #7095 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index f8aa4ecdba2..632d7b58993 100644 --- a/History.markdown +++ b/History.markdown @@ -30,6 +30,7 @@ * Adding `jekyll-info` plugin (#7091) * GitHub enables you to use themes from other repos (#7112) * Updates to CODE OF CONDUCT (v1.4.0) (#7105) + * Instructions to view theme’s files under Linux (#7095) ### Minor Enhancements From f4fcfbdaa02e11777fa776ed9e29341f4efefb79 Mon Sep 17 00:00:00 2001 From: Kelly-Ann Green Date: Mon, 9 Jul 2018 01:25:32 -0400 Subject: [PATCH 302/337] Update item_property to return numbers as numbers instead of strings (#6608) Merge pull request 6608 --- lib/jekyll/filters.rb | 25 ++++++++++++++++--------- test/test_filters.rb | 16 ++++++++++++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 2a390f06503..ed8c31638ec 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -299,16 +299,16 @@ def inspect(input) # We also utilize the Schwartzian transform to make this more efficient. def sort_input(input, property, order) input.map { |item| [item_property(item, property), item] } - .sort! do |apple_info, orange_info| - apple_property = apple_info.first - orange_property = orange_info.first + .sort! do |a_info, b_info| + a_property = a_info.first + b_property = b_info.first - if !apple_property.nil? && orange_property.nil? + if !a_property.nil? && b_property.nil? - order - elsif apple_property.nil? && !orange_property.nil? + elsif a_property.nil? && !b_property.nil? + order else - apple_property <=> orange_property + a_property <=> b_property || a_property.to_s <=> b_property.to_s end end .map!(&:last) @@ -317,15 +317,22 @@ def sort_input(input, property, order) def item_property(item, property) if item.respond_to?(:to_liquid) property.to_s.split(".").reduce(item.to_liquid) do |subvalue, attribute| - subvalue[attribute] + parse_sort_input(subvalue[attribute]) end elsif item.respond_to?(:data) - item.data[property.to_s] + parse_sort_input(item.data[property.to_s]) else - item[property.to_s] + parse_sort_input(item[property.to_s]) end end + # return numeric values as numbers for proper sorting + def parse_sort_input(property) + number_like = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z! + return property.to_f if property =~ number_like + property + end + def as_liquid(item) case item when Hash diff --git a/test/test_filters.rb b/test/test_filters.rb index a3dd142ad3e..ef9cbaaab1f 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -1074,10 +1074,6 @@ def to_liquid end should "return sorted strings" do assert_equal %w(10 2), @filter.sort(%w(10 2)) - assert_equal( - [{ "a" => "10" }, { "a" => "2" }], - @filter.sort([{ "a" => "10" }, { "a" => "2" }], "a") - ) assert_equal %w(FOO Foo foo), @filter.sort(%w(foo Foo FOO)) assert_equal %w(_foo foo foo_), @filter.sort(%w(foo_ _foo foo)) # Cyrillic @@ -1090,6 +1086,18 @@ def to_liquid assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], @filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") end + should "return sorted by property array with numeric strings sorted as numbers" do + assert_equal([{ "a" => ".5" }, { "a" => "0.65" }, { "a" => "10" }], + @filter.sort([{ "a" => "10" }, { "a" => ".5" }, { "a" => "0.65" }], "a")) + end + should "return sorted by property array with numeric strings first" do + assert_equal([{ "a" => ".5" }, { "a" => "0.6" }, { "a" => "twelve" }], + @filter.sort([{ "a" => "twelve" }, { "a" => ".5" }, { "a" => "0.6" }], "a")) + end + should "return sorted by property array with numbers and strings " do + assert_equal([{ "a" => "1" }, { "a" => "1abc" }, { "a" => "20" }], + @filter.sort([{ "a" => "20" }, { "a" => "1" }, { "a" => "1abc" }], "a")) + end should "return sorted by property array with nils first" do ary = [{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }] assert_equal [{ "b" => 1 }, { "a" => 1 }, { "a" => 2 }], @filter.sort(ary, "a") From c124937e69b9dbd6a401a9ce650686bd14c70092 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 9 Jul 2018 01:25:34 -0400 Subject: [PATCH 303/337] Update history to reflect merge of #6608 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 632d7b58993..3dd1f881e10 100644 --- a/History.markdown +++ b/History.markdown @@ -38,6 +38,7 @@ * Memoize computing excerpt's relative_path (#6951) * Liquefied link tag (#6269) * Suggest re-running command with --trace on fail (#6551) + * Update item_property to return numbers as numbers instead of strings (#6608) ### Major Enhancements From 4c7dbb691572d24e312c0345929e12bca934bdba Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 9 Jul 2018 11:10:35 -0500 Subject: [PATCH 304/337] Fix tests to have "expected value" as the first argument passed to `assert_equal` (#7104) * assert_equal(exp, act) * improve clarity of PageWithoutAFile test * Hoist invariant out of loop --- test/test_document.rb | 4 ++-- test/test_excerpt_drop.rb | 4 ++-- test/test_filters.rb | 3 ++- test/test_front_matter_defaults.rb | 8 ++++---- test/test_page_without_a_file.rb | 16 ++++++++++------ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/test_document.rb b/test/test_document.rb index ce8dbeda78d..b652b454aef 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -126,11 +126,11 @@ def setup_document_with_dates(filename) end should "output the collection name in the #to_liquid method" do - assert_equal @document.to_liquid["collection"], "methods" + assert_equal "methods", @document.to_liquid["collection"] end should "output its relative path as path in Liquid" do - assert_equal @document.to_liquid["path"], "_methods/configuration.md" + assert_equal "_methods/configuration.md", @document.to_liquid["path"] end end diff --git a/test/test_excerpt_drop.rb b/test/test_excerpt_drop.rb index 1eb6687266d..e9e387de1ab 100644 --- a/test/test_excerpt_drop.rb +++ b/test/test_excerpt_drop.rb @@ -28,7 +28,7 @@ class TestExcerptDrop < JekyllUnitTest should "inherit the layout for the drop but not the excerpt" do assert_nil @excerpt.data["layout"] - assert_equal @excerpt_drop["layout"], @doc_drop["layout"] + assert_equal @doc_drop["layout"], @excerpt_drop["layout"] end should "be inspectable" do @@ -36,7 +36,7 @@ class TestExcerptDrop < JekyllUnitTest end should "inherit values from the document" do - assert_equal @excerpt_drop.keys.sort, @doc_drop.keys.sort + assert_equal @doc_drop.keys.sort, @excerpt_drop.keys.sort end end end diff --git a/test/test_filters.rb b/test/test_filters.rb index ef9cbaaab1f..f0f37c4e95c 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -687,10 +687,11 @@ def select; end should "convert drop with drops to json" do @filter.site.read actual = @filter.jsonify(@filter.site.to_liquid) - assert_equal JSON.parse(actual)["jekyll"], { + expected = { "environment" => "development", "version" => Jekyll::VERSION, } + assert_equal expected, JSON.parse(actual)["jekyll"] end # rubocop:disable Style/StructInheritance diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index 2f996a9f303..dab4385c94b 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -22,7 +22,7 @@ class TestFrontMatterDefaults < JekyllUnitTest end should "affect only the specified path and type" do - assert_equal @affected.data["key"], "val" + assert_equal "val", @affected.data["key"] assert_nil @not_affected.data["key"] end @@ -50,7 +50,7 @@ class TestFrontMatterDefaults < JekyllUnitTest end should "affect only the specified path and type" do - assert_equal @affected.data["key"], "val" + assert_equal "val", @affected.data["key"] assert_nil @not_affected.data["key"] end @@ -78,7 +78,7 @@ class TestFrontMatterDefaults < JekyllUnitTest end should "affect only the specified path" do - assert_equal @affected.data["key"], "val" + assert_equal "val", @affected.data["key"] assert_nil @not_affected.data["key"] end end @@ -102,7 +102,7 @@ class TestFrontMatterDefaults < JekyllUnitTest end should "affect only the specified path and all types" do - assert_equal @affected.data["key"], "val" + assert_equal "val", @affected.data["key"] assert_nil @not_affected.data["key"] end end diff --git a/test/test_page_without_a_file.rb b/test/test_page_without_a_file.rb index d52d82fd7fd..50624890c4e 100644 --- a/test/test_page_without_a_file.rb +++ b/test/test_page_without_a_file.rb @@ -41,6 +41,10 @@ def render_and_write should "have basic attributes defined in it" do regular_page = setup_page("properties.html", :klass => Page) + # assert a couple of attributes accessible in a regular Jekyll::Page instance + assert_equal "All the properties.\n", regular_page["content"] + assert_equal "properties.html", regular_page["name"] + basic_attrs = %w(dir name path url) attrs = { "content" => "All the properties.\n", @@ -56,13 +60,13 @@ def render_and_write "url" => "/properties.html", } attrs.each do |prop, value| - # assert the props being accessible in a Jekyll::Page instance - assert_equal "All the properties.\n", regular_page["content"] - assert_equal "properties.html", regular_page["name"] - - # assert differences with Jekyll::PageWithoutAFile instance + # assert that all attributes (of a Jekyll::PageWithoutAFile instance) other than + # "dir", "name", "path", "url" are `nil`. + # For example, @page[dir] should be "/" but @page[content] or @page[layout], should + # simply be nil. + # if basic_attrs.include?(prop) - assert_equal @page[prop], value, "For :" + assert_equal value, @page[prop], "For Jekyll::PageWithoutAFile attribute '#{prop}':" else assert_nil @page[prop] end From 3650baa5dbd6ccff1f5735ca0d406a4697a654bf Mon Sep 17 00:00:00 2001 From: Derek Smart Date: Mon, 9 Jul 2018 12:12:37 -0400 Subject: [PATCH 305/337] add jekyll-xml-source (#7114) Merge pull request 7114 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index ba18ce30d18..2a2f2647347 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -940,6 +940,7 @@ You can find a few useful plugins at the following locations: - [jekyll-pwa-plugin](https://github.com/lavas-project/jekyll-pwa): A plugin provides PWA support for Jekyll. It generates a service worker in Jekyll build process and makes precache and runtime cache available in the runtime with Google Workbox. - [jekyll-algolia](https://community.algolia.com/jekyll-algolia/): Add fast and relevant search to your Jekyll site through the Algolia API. - [jekyll-get](https://github.com/18F/jekyll-get): Download data from external JSON API sources to use in generating a site. +- [jekyll-xml-source](https://github.com/mcred/jekyll-xml-source): Download XML and RSS from external sites for use in site data.
Submit your gem plugins
From a1ea95d445b39e6887882422a96c1ae79acc262d Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 9 Jul 2018 12:12:39 -0400 Subject: [PATCH 306/337] Update history to reflect merge of #7114 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 3dd1f881e10..f57e2bbf46e 100644 --- a/History.markdown +++ b/History.markdown @@ -31,6 +31,7 @@ * GitHub enables you to use themes from other repos (#7112) * Updates to CODE OF CONDUCT (v1.4.0) (#7105) * Instructions to view theme’s files under Linux (#7095) + * add jekyll-xml-source (#7114) ### Minor Enhancements From 8846741ed21c5c9c19cbd62b295a8382ebd682a6 Mon Sep 17 00:00:00 2001 From: Alex Wood Date: Mon, 9 Jul 2018 23:06:54 -0400 Subject: [PATCH 307/337] Fix #7082 Add call to unused method (#7122) Merge pull request 7122 --- lib/jekyll/commands/serve.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index ecf6fe67cdb..a5b58897a89 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -91,7 +91,10 @@ def init_with_program(prog) def process(opts) opts = configuration_from_options(opts) destination = opts["destination"] - register_reload_hooks(opts) if opts["livereload"] + if opts["livereload"] + validate_options(opts) + register_reload_hooks(opts) + end setup(destination) start_up_webrick(opts, destination) From 5950a7c11370b5af3cea52a745053febf26bef0a Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 9 Jul 2018 23:06:56 -0400 Subject: [PATCH 308/337] Update history to reflect merge of #7122 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index f57e2bbf46e..6b3b974d03b 100644 --- a/History.markdown +++ b/History.markdown @@ -67,6 +67,10 @@ * Update rubocop version to 0.57.x ### -docs (#7078) * Example of CircleCI deployment through CircleCI v2 (#7024) +### Bug Fixes + + * Add call to unused method `validate_options` in `commands/serve.rb` (#7122) + ## 3.8.3 / 2018-06-05 ### Bug Fixes From 402ee84abb3799097eb7ac16c4dfa4f77c2c1a59 Mon Sep 17 00:00:00 2001 From: Nicolas Hoizey Date: Wed, 11 Jul 2018 13:14:14 +0000 Subject: [PATCH 309/337] Add the jekyll-firstimage filter plugin (#7127) Merge pull request 7127 --- docs/_docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_docs/plugins.md b/docs/_docs/plugins.md index 2a2f2647347..f44d7383822 100644 --- a/docs/_docs/plugins.md +++ b/docs/_docs/plugins.md @@ -828,6 +828,7 @@ You can find a few useful plugins at the following locations: - [replace_regex](https://github.com/sparanoid/replace_regex): A Liquid filter to perform regex replace. - [Jekyll Money](https://rubygems.org/gems/jekyll-money): A Jekyll plugin for dealing with money. Because we all have to at some point. - [jekyll-random](https://github.com/codecalm/jekyll-random) by [codecalm](https://nodecalm.net): A Jekyll plugin that generates pseudo-random data. Very useful when you want to generate a large amount of random data. +- [jekyll-firstimage](https://github.com/nhoizey/jekyll-firstimage) adds a Liquid filter finding the first image in a HTML content string, including responsive images srcset. #### Tags From 0e0960e2c33d26e4da831c83fb082b93a9b09d53 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 11 Jul 2018 09:14:16 -0400 Subject: [PATCH 310/337] Update history to reflect merge of #7127 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 6b3b974d03b..0ccf4be54e6 100644 --- a/History.markdown +++ b/History.markdown @@ -32,6 +32,7 @@ * Updates to CODE OF CONDUCT (v1.4.0) (#7105) * Instructions to view theme’s files under Linux (#7095) * add jekyll-xml-source (#7114) + * Add the jekyll-firstimage filter plugin (#7127) ### Minor Enhancements From 180179303515cf82ed99503fedfe6f3f5497657b Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Wed, 11 Jul 2018 16:01:17 +0200 Subject: [PATCH 311/337] Use .markdown for page templates (#7126) Merge pull request 7126 --- docs/_docs/themes.md | 4 ++-- lib/site_template/{about.md => about.markdown} | 0 lib/site_template/{index.md => index.markdown} | 0 test/test_new_command.rb | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename lib/site_template/{about.md => about.markdown} (100%) rename lib/site_template/{index.md => index.markdown} (100%) diff --git a/docs/_docs/themes.md b/docs/_docs/themes.md index b8f469e5d7f..a2fcc4c9a48 100644 --- a/docs/_docs/themes.md +++ b/docs/_docs/themes.md @@ -19,8 +19,8 @@ In the case of Minima, you see only the following files in your Jekyll site dire ├── _config.yml ├── _posts │ └── 2016-12-04-welcome-to-jekyll.markdown -├── about.md -└── index.md +├── about.markdown +└── index.markdown ``` The `Gemfile` and `Gemfile.lock` files are used by Bundler to keep track of the required gems and gem versions you need to build your Jekyll site. diff --git a/lib/site_template/about.md b/lib/site_template/about.markdown similarity index 100% rename from lib/site_template/about.md rename to lib/site_template/about.markdown diff --git a/lib/site_template/index.md b/lib/site_template/index.markdown similarity index 100% rename from lib/site_template/index.md rename to lib/site_template/index.markdown diff --git a/test/test_new_command.rb b/test/test_new_command.rb index 632ad3d57c6..6bb6ed3c2f3 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -57,7 +57,7 @@ def site_template capture_output { Jekyll::Commands::New.process(@args) } new_site_files = dir_contents(@full_path).reject do |f| - File.extname(f) == ".markdown" + f.end_with?("welcome-to-jekyll.markdown") end assert_same_elements static_template_files, new_site_files From dcbc4433878ac9496f19e838197f17d56c0d1221 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 11 Jul 2018 10:01:20 -0400 Subject: [PATCH 312/337] Update history to reflect merge of #7126 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 0ccf4be54e6..9a32843dfa2 100644 --- a/History.markdown +++ b/History.markdown @@ -41,6 +41,7 @@ * Liquefied link tag (#6269) * Suggest re-running command with --trace on fail (#6551) * Update item_property to return numbers as numbers instead of strings (#6608) + * Use .markdown for page templates (#7126) ### Major Enhancements From 5d1f85928ad6f764b3f0a71611462752f1203703 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 11 Jul 2018 13:32:39 -0400 Subject: [PATCH 313/337] Use a real theme in the example (#7125) Merge pull request 7125 --- docs/_docs/themes.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/_docs/themes.md b/docs/_docs/themes.md index a2fcc4c9a48..460686157d6 100644 --- a/docs/_docs/themes.md +++ b/docs/_docs/themes.md @@ -166,20 +166,21 @@ For example, search for [jekyll theme on RubyGems](https://rubygems.org/search?u To install a gem-based theme: -1. Add the theme to your site's `Gemfile`: +1. Add the theme gem to your site's `Gemfile`: ```ruby # ./Gemfile - gem "jekyll-theme-awesome" + # This is an example, declare the theme gem you want to use here + gem "jekyll-theme-minimal" ``` - Or if you've started with the `jekyll new` command, replace `gem "minima", "~> 2.0"` with your theme-gem: + Or if you've started with the `jekyll new` command, replace `gem "minima", "~> 2.0"` with the gem you want, e.g: ```diff # ./Gemfile - gem "minima", "~> 2.0" - + gem "jekyll-theme-awesome" + + gem "jekyll-theme-minimal" ``` 2. Install the theme: @@ -191,7 +192,7 @@ To install a gem-based theme: 3. Add the following to your site's `_config.yml` to activate the theme: ```yaml - theme: jekyll-theme-awesome + theme: jekyll-theme-minimal ``` 4. Build your site: From 06125425820eadbc412faaea087161fd8ef75da9 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Wed, 11 Jul 2018 13:32:41 -0400 Subject: [PATCH 314/337] Update history to reflect merge of #7125 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 9a32843dfa2..39f23f52be2 100644 --- a/History.markdown +++ b/History.markdown @@ -33,6 +33,7 @@ * Instructions to view theme’s files under Linux (#7095) * add jekyll-xml-source (#7114) * Add the jekyll-firstimage filter plugin (#7127) + * Use a real theme in the example (#7125) ### Minor Enhancements From 9adac3a11ea405b5395247ae224cf40553a7abb6 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Thu, 12 Jul 2018 19:51:23 +0530 Subject: [PATCH 315/337] Fix Rubocop offences in test files (#7128) Merge pull request 7128 --- .rubocop.yml | 7 + test/helper.rb | 29 +- test/test_coffeescript.rb | 52 +- test/test_collections.rb | 40 +- test/test_command.rb | 4 +- test/test_commands_serve.rb | 52 +- test/test_configuration.rb | 108 ++-- test/test_convertible.rb | 4 +- test/test_doctor_command.rb | 16 +- test/test_document.rb | 110 ++-- test/test_drop.rb | 6 +- test/test_entry_filter.rb | 2 +- test/test_excerpt.rb | 11 +- test/test_filters.rb | 132 ++--- test/test_front_matter_defaults.rb | 66 +-- test/test_generated_site.rb | 12 +- test/test_kramdown.rb | 31 +- test/test_layout_reader.rb | 4 +- test/test_liquid_extensions.rb | 4 +- test/test_page.rb | 10 +- test/test_page_without_a_file.rb | 10 +- test/test_plugin_manager.rb | 36 +- test/test_regenerator.rb | 34 +- test/test_related_posts.rb | 6 +- test/test_sass.rb | 8 +- test/test_site.rb | 84 ++- test/test_site_drop.rb | 6 +- test/test_static_file.rb | 10 +- test/test_tags.rb | 923 ++++++++++++++--------------- test/test_utils.rb | 12 +- 30 files changed, 899 insertions(+), 930 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 81e11e29765..630941352ee 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,7 @@ AllCops: TargetRubyVersion: 2.3 Include: - lib/**/*.rb + - test/**/*.rb Exclude: - bin/**/* - exe/**/* @@ -82,6 +83,9 @@ Metrics/PerceivedComplexity: Max: 8 Naming/FileName: Enabled: false +Naming/HeredocDelimiterNaming: + Exclude: + - test/**/*.rb Naming/MemoizedInstanceVariableName: Exclude: - lib/jekyll/page_without_a_file.rb @@ -104,6 +108,9 @@ Style/Alias: EnforcedStyle: prefer_alias_method Style/AndOr: Severity: error +Style/ClassAndModuleChildren: + Exclude: + - test/**/*.rb Style/FrozenStringLiteralComment: EnforcedStyle: always Style/Documentation: diff --git a/test/helper.rb b/test/helper.rb index 9e01b7de2e1..29185427a9c 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -111,13 +111,13 @@ def after_teardown end def fixture_document(relative_path) - site = fixture_site({ + site = fixture_site( "collections" => { "methods" => { "output" => true, }, - }, - }) + } + ) site.read matching_doc = site.collections["methods"].docs.find do |doc| doc.relative_path == relative_path @@ -138,13 +138,13 @@ def build_configs(overrides, base_hash = default_configuration) end def site_configuration(overrides = {}) - full_overrides = build_configs(overrides, build_configs({ - "destination" => dest_dir, - "incremental" => false, - })) - Configuration.from(full_overrides.merge({ - "source" => source_dir, - })) + full_overrides = build_configs(overrides, build_configs( + "destination" => dest_dir, + "incremental" => false + )) + Configuration.from(full_overrides.merge( + "source" => source_dir + )) end def clear_dest @@ -197,7 +197,6 @@ def <<(str); end end module TestWEBrick - module_function def mount_server(&block) @@ -205,7 +204,7 @@ def mount_server(&block) begin server.mount("/", Jekyll::Commands::Serve::Servlet, document_root, - document_root_options) + document_root_options) server.start addr = server.listeners[0].addr @@ -235,11 +234,11 @@ def document_root end def document_root_options - WEBrick::Config::FileHandler.merge({ + WEBrick::Config::FileHandler.merge( :FancyIndexing => true, :NondisclosureName => [ ".ht*", "~*", - ], - }) + ] + ) end end diff --git a/test/test_coffeescript.rb b/test/test_coffeescript.rb index a60e0595430..6c6c376b214 100644 --- a/test/test_coffeescript.rb +++ b/test/test_coffeescript.rb @@ -9,33 +9,33 @@ class TestCoffeeScript < JekyllUnitTest @site = fixture_site @site.process @test_coffeescript_file = dest_dir("js/coffeescript.js") - @js_output = <<-JS -(function() { - $(function() { - var cube, cubes, list, num, square; - list = [1, 2, 3, 4, 5]; - square = function(x) { - return x * x; - }; - cube = function(x) { - return square(x) * x; - }; - cubes = (function() { - var i, len, results; - results = []; - for (i = 0, len = list.length; i < len; i++) { - num = list[i]; - results.push(math.cube(num)); - } - return results; - })(); - if (typeof elvis !== "undefined" && elvis !== null) { - return alert("I knew it!"); - } - }); + @js_output = <<~JS + (function() { + $(function() { + var cube, cubes, list, num, square; + list = [1, 2, 3, 4, 5]; + square = function(x) { + return x * x; + }; + cube = function(x) { + return square(x) * x; + }; + cubes = (function() { + var i, len, results; + results = []; + for (i = 0, len = list.length; i < len; i++) { + num = list[i]; + results.push(math.cube(num)); + } + return results; + })(); + if (typeof elvis !== "undefined" && elvis !== null) { + return alert("I knew it!"); + } + }); -}).call(this); -JS + }).call(this); + JS end should "write a JS file in place" do diff --git a/test/test_collections.rb b/test/test_collections.rb index 33d3f912963..7af86dd8c87 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -94,13 +94,13 @@ class TestCollections < JekyllUnitTest context "a collection with permalink" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "methods" => { "permalink" => "/awesome/:path/", }, - }, - }) + } + ) @site.process @collection = @site.collections["methods"] end @@ -112,9 +112,9 @@ class TestCollections < JekyllUnitTest context "with a collection" do setup do - @site = fixture_site({ - "collections" => ["methods"], - }) + @site = fixture_site( + "collections" => ["methods"] + ) @site.process @collection = @site.collections["methods"] end @@ -154,35 +154,35 @@ class TestCollections < JekyllUnitTest should "not include the underscored files in the list of docs" do refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md" refute_includes @collection.docs.map(&:relative_path), - "_methods/site/_dont_include_me_either.md" + "_methods/site/_dont_include_me_either.md" end end context "with a collection with metadata" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "methods" => { "foo" => "bar", "baz" => "whoo", }, - }, - }) + } + ) @site.process @collection = @site.collections["methods"] end should "extract the configuration collection information as metadata" do - assert_equal @collection.metadata, { "foo" => "bar", "baz" => "whoo" } + assert_equal @collection.metadata, "foo" => "bar", "baz" => "whoo" end end context "in safe mode" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => ["methods"], - "safe" => true, - }) + "safe" => true + ) @site.process @collection = @site.collections["methods"] end @@ -202,10 +202,10 @@ class TestCollections < JekyllUnitTest context "with dots in the filenames" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => ["with.dots"], - "safe" => true, - }) + "safe" => true + ) @site.process @collection = @site.collections["with.dots"] end @@ -231,14 +231,14 @@ class TestCollections < JekyllUnitTest context "a collection with included dotfiles" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "methods" => { "permalink" => "/awesome/:path/", }, }, - "include" => %w(.htaccess .gitignore), - }) + "include" => %w(.htaccess .gitignore) + ) @site.process @collection = @site.collections["methods"] end diff --git a/test/test_command.rb b/test/test_command.rb index 33e13798cc6..d202628c4f2 100644 --- a/test/test_command.rb +++ b/test/test_command.rb @@ -15,7 +15,9 @@ class TestCommand < JekyllUnitTest context "when fatal error occurs" do should "exit with non-zero error code" do site = Object.new - def site.process; raise Jekyll::Errors::FatalException; end + def site.process + raise Jekyll::Errors::FatalException + end error = assert_raises(SystemExit) { Command.process_site(site) } refute_equal 0, error.status end diff --git a/test/test_commands_serve.rb b/test/test_commands_serve.rb index ce9f1c65c8a..b589de2f37a 100644 --- a/test/test_commands_serve.rb +++ b/test/test_commands_serve.rb @@ -5,7 +5,6 @@ require "helper" require "httpclient" require "openssl" -require "thread" require "tmpdir" class TestCommandsServe < JekyllUnitTest @@ -126,9 +125,9 @@ def serve(opts) should "apply the max and min delay options" do skip_if_windows "EventMachine support on Windows is limited" opts = serve(@standard_options.merge( - "livereload_max_delay" => "1066", - "livereload_min_delay" => "3" - )) + "livereload_max_delay" => "1066", + "livereload_min_delay" => "3" + )) content = @client.get_content( "http://#{opts["host"]}:#{opts["port"]}/#{opts["baseurl"]}/hello.html" ) @@ -191,14 +190,14 @@ def serve(opts) end should "use user destinations" do - assert_equal "foo", custom_opts({ "destination" => "foo" })[ + assert_equal "foo", custom_opts("destination" => "foo")[ :DocumentRoot ] end should "use user port" do # WHAT?!?!1 Over 9000? That's impossible. - assert_equal 9001, custom_opts({ "port" => 9001 })[ + assert_equal 9001, custom_opts("port" => 9001)[ :Port ] end @@ -237,21 +236,20 @@ def serve(opts) expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) end should "set the site url by default to `http://localhost:4000`" do - @merc.execute(:serve, { "watch" => false, "url" => "https://jekyllrb.com/" }) + @merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/") assert_equal 1, Jekyll.sites.count assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"] end should "take `host`, `port` and `ssl` into consideration if set" do - @merc.execute(:serve, { - "watch" => false, - "host" => "example.com", - "port" => "9999", - "url" => "https://jekyllrb.com/", - "ssl_cert" => "foo", - "ssl_key" => "bar", - }) + @merc.execute(:serve, + "watch" => false, + "host" => "example.com", + "port" => "9999", + "url" => "https://jekyllrb.com/", + "ssl_cert" => "foo", + "ssl_key" => "bar") assert_equal 1, Jekyll.sites.count assert_equal "https://example.com:9999", Jekyll.sites.first.config["url"] @@ -262,7 +260,7 @@ def serve(opts) should "not update the site url" do expect(Jekyll).to receive(:env).and_return("production") expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) - @merc.execute(:serve, { "watch" => false, "url" => "https://jekyllrb.com/" }) + @merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/") assert_equal 1, Jekyll.sites.count assert_equal "https://jekyllrb.com/", Jekyll.sites.first.config["url"] @@ -271,7 +269,7 @@ def serve(opts) context "verbose" do should "debug when verbose" do - assert_equal custom_opts({ "verbose" => true })[:Logger].level, 5 + assert_equal custom_opts("verbose" => true)[:Logger].level, 5 end should "warn when not verbose" do @@ -282,15 +280,15 @@ def serve(opts) context "enabling SSL" do should "raise if enabling without key or cert" do assert_raises RuntimeError do - custom_opts({ - "ssl_key" => "foo", - }) + custom_opts( + "ssl_key" => "foo" + ) end assert_raises RuntimeError do - custom_opts({ - "ssl_key" => "foo", - }) + custom_opts( + "ssl_key" => "foo" + ) end end @@ -299,12 +297,12 @@ def serve(opts) expect(OpenSSL::X509::Certificate).to receive(:new).and_return("c1") allow(File).to receive(:read).and_return("foo") - result = custom_opts({ + result = custom_opts( "ssl_cert" => "foo", "source" => "bar", "enable_ssl" => true, - "ssl_key" => "bar", - }) + "ssl_key" => "bar" + ) assert result[:SSLEnable] assert_equal result[:SSLPrivateKey], "c2" @@ -317,7 +315,7 @@ def serve(opts) allow(Jekyll::Commands::Serve).to receive(:start_up_webrick) expect(Jekyll).to receive(:configuration).once.and_call_original - @merc.execute(:serve, { "watch" => false }) + @merc.execute(:serve, "watch" => false) end end end diff --git a/test/test_configuration.rb b/test/test_configuration.rb index 17c0d21985d..3f19949a846 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -15,7 +15,7 @@ class TestConfiguration < JekyllUnitTest end should "merge input over defaults" do - result = Configuration.from({ "source" => "blah" }) + result = Configuration.from("source" => "blah") refute_equal result["source"], Configuration::DEFAULTS["source"] assert_equal result["source"], "blah" end @@ -28,11 +28,9 @@ class TestConfiguration < JekyllUnitTest result = Configuration.from({}) assert_equal( result["collections"], - { - "posts" => { - "output" => true, - "permalink" => "/:categories/:year/:month/:day/:title:output_ext", - }, + "posts" => { + "output" => true, + "permalink" => "/:categories/:year/:month/:day/:title:output_ext", } ) end @@ -72,7 +70,7 @@ class TestConfiguration < JekyllUnitTest assert_instance_of Hash, result["collections"] assert_equal( result["collections"], - { "posts" => { "output" => true }, "methods" => {} } + "posts" => { "output" => true }, "methods" => {} ) end @@ -81,17 +79,15 @@ class TestConfiguration < JekyllUnitTest .add_default_collections assert_equal( result["collections"], - { - "posts" => { - "output" => true, - "permalink" => "/:categories/:year/:month/:day/:title/", - }, + "posts" => { + "output" => true, + "permalink" => "/:categories/:year/:month/:day/:title/", } ) result = Configuration[{ "permalink" => nil, "collections" => {} }] .add_default_collections - assert_equal result["collections"], { "posts" => { "output" => true } } + assert_equal result["collections"], "posts" => { "output" => true } end should "forces posts to output" do @@ -186,7 +182,7 @@ class TestConfiguration < JekyllUnitTest allow(SafeYAML) .to receive(:load_file) .with("not_empty.yml") - .and_return({ "foo" => "bar", "include" => "", "exclude" => "" }) + .and_return("foo" => "bar", "include" => "", "exclude" => "") Jekyll.logger.log_level = :warn read_config = @config.read_config_files(["empty.yml", "not_empty.yml"]) Jekyll.logger.log_level = :info @@ -301,11 +297,11 @@ class TestConfiguration < JekyllUnitTest allow($stderr) .to receive(:puts) .with(Colorator.red( - "Fatal: ".rjust(20) + \ - "The configuration file '#{@user_config}' could not be found." - )) + "Fatal: ".rjust(20) + \ + "The configuration file '#{@user_config}' could not be found." + )) assert_raises LoadError do - Jekyll.configuration({ "config" => [@user_config] }) + Jekyll.configuration("config" => [@user_config]) end end @@ -334,14 +330,14 @@ class TestConfiguration < JekyllUnitTest allow(SafeYAML) .to receive(:load_file) .with(@paths[:other]) - .and_return({ "baseurl" => "http://example.com" }) + .and_return("baseurl" => "http://example.com") allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") assert_equal \ - site_configuration({ + site_configuration( "baseurl" => "http://example.com", - "config" => @paths[:other], - }), - Jekyll.configuration(test_config.merge({ "config" => @paths[:other] })) + "config" => @paths[:other] + ), + Jekyll.configuration(test_config.merge("config" => @paths[:other])) end should "load different config if specified with symbol key" do @@ -349,33 +345,33 @@ class TestConfiguration < JekyllUnitTest allow(SafeYAML) .to receive(:load_file) .with(@paths[:other]) - .and_return({ "baseurl" => "http://example.com" }) + .and_return("baseurl" => "http://example.com") allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") assert_equal \ - site_configuration({ + site_configuration( "baseurl" => "http://example.com", - "config" => @paths[:other], - }), - Jekyll.configuration(test_config.merge({ :config => @paths[:other] })) + "config" => @paths[:other] + ), + Jekyll.configuration(test_config.merge(:config => @paths[:other])) end should "load default config if path passed is empty" do allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") assert_equal \ - site_configuration({ "config" => [@paths[:empty]] }), - Jekyll.configuration(test_config.merge({ "config" => [@paths[:empty]] })) + site_configuration("config" => [@paths[:empty]]), + Jekyll.configuration(test_config.merge("config" => [@paths[:empty]])) end should "successfully load a TOML file" do Jekyll.logger.log_level = :warn assert_equal \ - site_configuration({ + site_configuration( "baseurl" => "/you-beautiful-blog-you", "title" => "My magnificent site, wut", - "config" => [@paths[:toml]], - }), - Jekyll.configuration(test_config.merge({ "config" => [@paths[:toml]] })) + "config" => [@paths[:toml]] + ), + Jekyll.configuration(test_config.merge("config" => [@paths[:toml]])) Jekyll.logger.log_level = :info end @@ -389,12 +385,12 @@ class TestConfiguration < JekyllUnitTest allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}") assert_equal( - site_configuration({ - "config" => [@paths[:default], @paths[:other], @paths[:toml]], - }), + site_configuration( + "config" => [@paths[:default], @paths[:other], @paths[:toml]] + ), Jekyll.configuration( test_config.merge( - { "config" => [@paths[:default], @paths[:other], @paths[:toml]] } + "config" => [@paths[:default], @paths[:other], @paths[:toml]] ) ) ) @@ -404,11 +400,11 @@ class TestConfiguration < JekyllUnitTest allow(SafeYAML) .to receive(:load_file) .with(@paths[:default]) - .and_return({ "baseurl" => "http://example.dev" }) + .and_return("baseurl" => "http://example.dev") allow(SafeYAML) .to receive(:load_file) .with(@paths[:other]) - .and_return({ "baseurl" => "http://example.com" }) + .and_return("baseurl" => "http://example.com") allow($stdout) .to receive(:puts) .with("Configuration file: #{@paths[:default]}") @@ -416,12 +412,12 @@ class TestConfiguration < JekyllUnitTest .to receive(:puts) .with("Configuration file: #{@paths[:other]}") assert_equal \ - site_configuration({ + site_configuration( "baseurl" => "http://example.com", - "config" => [@paths[:default], @paths[:other]], - }), + "config" => [@paths[:default], @paths[:other]] + ), Jekyll.configuration( - test_config.merge({ "config" => [@paths[:default], @paths[:other]] }) + test_config.merge("config" => [@paths[:default], @paths[:other]]) ) end end @@ -437,41 +433,41 @@ class TestConfiguration < JekyllUnitTest conf = Configuration[default_configuration].tap do |c| c["collections"] = ["docs"] end - assert_equal conf.add_default_collections, conf.merge({ + assert_equal conf.add_default_collections, conf.merge( "collections" => { "docs" => {}, "posts" => { "output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext", }, - }, - }) + } + ) end should "force collections.posts.output = true" do conf = Configuration[default_configuration].tap do |c| c["collections"] = { "posts" => { "output" => false } } end - assert_equal conf.add_default_collections, conf.merge({ + assert_equal conf.add_default_collections, conf.merge( "collections" => { "posts" => { "output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext", }, - }, - }) + } + ) end should "set collections.posts.permalink if it's not set" do conf = Configuration[default_configuration] - assert_equal conf.add_default_collections, conf.merge({ + assert_equal conf.add_default_collections, conf.merge( "collections" => { "posts" => { "output" => true, "permalink" => "/:categories/:year/:month/:day/:title:output_ext", }, - }, - }) + } + ) end should "leave collections.posts.permalink alone if it is set" do @@ -481,14 +477,14 @@ class TestConfiguration < JekyllUnitTest "posts" => { "permalink" => posts_permalink }, } end - assert_equal conf.add_default_collections, conf.merge({ + assert_equal conf.add_default_collections, conf.merge( "collections" => { "posts" => { "output" => true, "permalink" => posts_permalink, }, - }, - }) + } + ) end end diff --git a/test/test_convertible.rb b/test/test_convertible.rb index 5b73e252815..a3bea6baf48 100644 --- a/test/test_convertible.rb +++ b/test/test_convertible.rb @@ -8,8 +8,8 @@ class TestConvertible < JekyllUnitTest setup do @convertible = OpenStruct.new( "site" => Site.new(Jekyll.configuration( - "source" => File.expand_path("fixtures", __dir__) - )) + "source" => File.expand_path("fixtures", __dir__) + )) ) @convertible.extend Jekyll::Convertible @base = File.expand_path("fixtures", __dir__) diff --git a/test/test_doctor_command.rb b/test/test_doctor_command.rb index 182878689cc..ac453810304 100644 --- a/test/test_doctor_command.rb +++ b/test/test_doctor_command.rb @@ -10,10 +10,10 @@ class TestDoctorCommand < JekyllUnitTest end should "return success on a valid site/page" do - @site = Site.new(Jekyll.configuration({ - "source" => File.join(source_dir, "/_urls_differ_by_case_valid"), - "destination" => dest_dir, - })) + @site = Site.new(Jekyll.configuration( + "source" => File.join(source_dir, "/_urls_differ_by_case_valid"), + "destination" => dest_dir + )) @site.process output = capture_stderr do ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) @@ -23,10 +23,10 @@ class TestDoctorCommand < JekyllUnitTest end should "return warning for pages only differing by case" do - @site = Site.new(Jekyll.configuration({ - "source" => File.join(source_dir, "/_urls_differ_by_case_invalid"), - "destination" => dest_dir, - })) + @site = Site.new(Jekyll.configuration( + "source" => File.join(source_dir, "/_urls_differ_by_case_invalid"), + "destination" => dest_dir + )) @site.process output = capture_stderr do ret = Jekyll::Commands::Doctor.urls_only_differ_by_case(@site) diff --git a/test/test_document.rb b/test/test_document.rb index b652b454aef..7f449c754e1 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -10,10 +10,9 @@ def assert_equal_value(key, one, other) def setup_encoded_document(filename) site = fixture_site("collections" => ["encodings"]) site.process - Document.new(site.in_source_dir(File.join("_encodings", filename)), { - :site => site, - :collection => site.collections["encodings"], - }).tap(&:read) + Document.new(site.in_source_dir(File.join("_encodings", filename)), + :site => site, + :collection => site.collections["encodings"]).tap(&:read) end def setup_document_with_dates(filename) @@ -21,19 +20,18 @@ def setup_document_with_dates(filename) site.process docs = nil with_env("TZ", "UTC") do - docs = Document.new(site.in_source_dir(File.join("_dates", filename)), { - :site => site, - :collection => site.collections["dates"], - }).tap(&:read) + docs = Document.new(site.in_source_dir(File.join("_dates", filename)), + :site => site, + :collection => site.collections["dates"]).tap(&:read) end docs end context "a document in a collection" do setup do - @site = fixture_site({ - "collections" => ["methods"], - }) + @site = fixture_site( + "collections" => ["methods"] + ) @site.process @document = @site.collections["methods"].docs.detect do |d| d.relative_path == "_methods/configuration.md" @@ -112,7 +110,7 @@ def setup_document_with_dates(filename) context "with YAML ending in three dots" do setup do - @site = fixture_site({ "collections" => ["methods"] }) + @site = fixture_site("collections" => ["methods"]) @site.process @document = @site.collections["methods"].docs.detect do |d| d.relative_path == "_methods/yaml_with_dots.md" @@ -136,7 +134,7 @@ def setup_document_with_dates(filename) context "a document as part of a collection with front matter defaults" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => ["slides"], "defaults" => [{ "scope" => { "path" => "", "type" => "slides" }, @@ -145,8 +143,8 @@ def setup_document_with_dates(filename) "key" => "myval", }, }, - },], - }) + },] + ) @site.process @document = @site.collections["slides"].docs.select { |d| d.is_a?(Document) }.first end @@ -166,7 +164,7 @@ def setup_document_with_dates(filename) context "a document as part of a collection with overridden default values" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => ["slides"], "defaults" => [{ "scope" => { "path" => "", "type" => "slides" }, @@ -176,8 +174,8 @@ def setup_document_with_dates(filename) "test2" => "default1", }, }, - },], - }) + },] + ) @site.process @document = @site.collections["slides"].docs[1] end @@ -194,7 +192,7 @@ def setup_document_with_dates(filename) context "a document as part of a collection with valid path" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => ["slides"], "defaults" => [{ "scope" => { "path" => "_slides", "type" => "slides" }, @@ -203,8 +201,8 @@ def setup_document_with_dates(filename) "key" => "value123", }, }, - },], - }) + },] + ) @site.process @document = @site.collections["slides"].docs.first end @@ -218,7 +216,7 @@ def setup_document_with_dates(filename) context "a document as part of a collection with invalid path" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => ["slides"], "defaults" => [{ "scope" => { "path" => "somepath", "type" => "slides" }, @@ -227,8 +225,8 @@ def setup_document_with_dates(filename) "key" => "myval", }, }, - },], - }) + },] + ) @site.process @document = @site.collections["slides"].docs.first end @@ -242,9 +240,9 @@ def setup_document_with_dates(filename) context "a document in a collection with a custom permalink" do setup do - @site = fixture_site({ - "collections" => ["slides"], - }) + @site = fixture_site( + "collections" => ["slides"] + ) @site.process @document = @site.collections["slides"].docs[2] @dest_file = dest_dir("slide/3/index.html") @@ -261,15 +259,15 @@ def setup_document_with_dates(filename) context "a document in a collection with custom filename permalinks" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, "permalink" => "/slides/test/:name", }, }, - "permalink" => "pretty", - }) + "permalink" => "pretty" + ) @site.process @document = @site.collections["slides"].docs[0] @dest_file = dest_dir("slides/test/example-slide-1.html") @@ -290,13 +288,13 @@ def setup_document_with_dates(filename) context "a document in a collection with pretty permalink style" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, }, - }, - }) + } + ) @site.permalink_style = :pretty @site.process @document = @site.collections["slides"].docs[0] @@ -314,13 +312,13 @@ def setup_document_with_dates(filename) context "a document in a collection with cased file name" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, }, - }, - }) + } + ) @site.permalink_style = :pretty @site.process @document = @site.collections["slides"].docs[7] @@ -334,13 +332,13 @@ def setup_document_with_dates(filename) context "a document in a collection with cased file name" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, }, - }, - }) + } + ) @site.process @document = @site.collections["slides"].docs[6] @dest_file = dest_dir("slides/example-slide-7.php") @@ -365,14 +363,14 @@ def setup_document_with_dates(filename) context "documents in a collection with custom title permalinks" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, "permalink" => "/slides/:title", }, - }, - }) + } + ) @site.process @document = @site.collections["slides"].docs[3] @document_without_slug = @site.collections["slides"].docs[4] @@ -410,9 +408,9 @@ def setup_document_with_dates(filename) context "document with a permalink with dots & a trailing slash" do setup do - @site = fixture_site({ "collections" => { + @site = fixture_site("collections" => { "with.dots" => { "output" => true }, - }, }) + }) @site.process @document = @site.collections["with.dots"].docs.last @dest_file = dest_dir("with.dots", "permalink.with.slash.tho", "index.html") @@ -433,13 +431,13 @@ def setup_document_with_dates(filename) context "documents in a collection" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, }, - }, - }) + } + ) @site.process @files = @site.collections["slides"].docs end @@ -465,13 +463,13 @@ def setup_document_with_dates(filename) context "a static file in a collection" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "slides" => { "output" => true, }, - }, - }) + } + ) @site.process @document = @site.collections["slides"].files.find do |doc| doc.relative_path == "_slides/octojekyll.png" @@ -498,13 +496,13 @@ def setup_document_with_dates(filename) context "a document in a collection with non-alphabetic file name" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "methods" => { "output" => true, }, - }, - }) + } + ) @site.process @document = @site.collections["methods"].docs.find do |doc| doc.relative_path == "_methods/escape-+ #%20[].md" @@ -527,13 +525,13 @@ def setup_document_with_dates(filename) context "a document in a collection with dash-separated numeric file name" do setup do - @site = fixture_site({ + @site = fixture_site( "collections" => { "methods" => { "output" => true, }, - }, - }) + } + ) @site.process @document = @site.collections["methods"].docs.find do |doc| doc.relative_path == "_methods/3940394-21-9393050-fifif1323-test.md" diff --git a/test/test_drop.rb b/test/test_drop.rb index 5c46d81dc77..aa9387db861 100644 --- a/test/test_drop.rb +++ b/test/test_drop.rb @@ -17,9 +17,9 @@ def fallback_data class TestDrop < JekyllUnitTest context "Drops" do setup do - @site = fixture_site({ - "collections" => ["methods"], - }) + @site = fixture_site( + "collections" => ["methods"] + ) @site.process @document = @site.collections["methods"].docs.detect do |d| d.relative_path == "_methods/configuration.md" diff --git a/test/test_entry_filter.rb b/test/test_entry_filter.rb index c9025092318..7e84df70737 100644 --- a/test/test_entry_filter.rb +++ b/test/test_entry_filter.rb @@ -10,7 +10,7 @@ class TestEntryFilter < JekyllUnitTest should "filter entries" do ent1 = %w(foo.markdown bar.markdown baz.markdown #baz.markdown# - .baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx) + .baz.markdow foo.markdown~ .htaccess _posts _pages ~$benbalter.docx) entries = EntryFilter.new(@site).filter(ent1) assert_equal %w(foo.markdown bar.markdown baz.markdown .htaccess), entries diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 24647decada..986ef6b4617 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -4,10 +4,9 @@ class TestExcerpt < JekyllUnitTest def setup_post(file) - Document.new(@site.in_source_dir(File.join("_posts", file)), { - :site => @site, - :collection => @site.posts, - }).tap(&:read) + Document.new(@site.in_source_dir(File.join("_posts", file)), + :site => @site, + :collection => @site.posts).tap(&:read) end def do_render(document) @@ -81,9 +80,9 @@ def do_render(document) context "#relative_path" do should "return its document's relative path with '/#excerpt' appended" do assert_equal "#{@excerpt.doc.relative_path}/#excerpt", - @excerpt.relative_path + @excerpt.relative_path assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown/#excerpt", - @excerpt.relative_path + @excerpt.relative_path end end diff --git a/test/test_filters.rb b/test/test_filters.rb index f0f37c4e95c..c8909f25555 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -9,7 +9,7 @@ class JekyllFilter def initialize(opts = {}) @site = Jekyll::Site.new(opts.merge("skip_config_files" => true)) - @context = Liquid::Context.new(@site.site_payload, {}, { :site => @site }) + @context = Liquid::Context.new(@site.site_payload, {}, :site => @site) end end @@ -37,12 +37,12 @@ def select; end context "filters" do setup do @sample_time = Time.utc(2013, 3, 27, 11, 22, 33) - @filter = make_filter_mock({ + @filter = make_filter_mock( "timezone" => "UTC", "url" => "http://example.com", "baseurl" => "/base", - "dont_show_posts_before" => @sample_time, - }) + "dont_show_posts_before" => @sample_time + ) @sample_date = Date.parse("2013-03-02") @time_as_string = "September 11, 2001 12:46:30 -0000" @time_as_numeric = 1_399_680_607 @@ -88,7 +88,7 @@ def select; end end should "escapes special characters when configured to do so" do - kramdown = make_filter_mock({ :kramdown => { :entity_output => :symbolic } }) + kramdown = make_filter_mock(:kramdown => { :entity_output => :symbolic }) assert_equal( "“This filter’s test…”", kramdown.smartify(%q{"This filter's test..."}) @@ -406,82 +406,82 @@ def select; end should "ensure the leading slash for the baseurl" do page_url = "about/my_favorite_page/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "base", - }) + "baseurl" => "base" + ) assert_equal "http://example.com/base/#{page_url}", filter.absolute_url(page_url) end should "be ok with a blank but present 'url'" do page_url = "about/my_favorite_page/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "", - "baseurl" => "base", - }) + "baseurl" => "base" + ) assert_equal "/base/#{page_url}", filter.absolute_url(page_url) end should "be ok with a nil 'url'" do page_url = "about/my_favorite_page/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => nil, - "baseurl" => "base", - }) + "baseurl" => "base" + ) assert_equal "/base/#{page_url}", filter.absolute_url(page_url) end should "be ok with a nil 'baseurl'" do page_url = "about/my_favorite_page/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => nil, - }) + "baseurl" => nil + ) assert_equal "http://example.com/#{page_url}", filter.absolute_url(page_url) end should "not prepend a forward slash if input is empty" do page_url = "" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/base", - }) + "baseurl" => "/base" + ) assert_equal "http://example.com/base", filter.absolute_url(page_url) end should "not append a forward slash if input is '/'" do page_url = "/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/base", - }) + "baseurl" => "/base" + ) assert_equal "http://example.com/base/", filter.absolute_url(page_url) end should "not append a forward slash if input is '/' and nil 'baseurl'" do page_url = "/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => nil, - }) + "baseurl" => nil + ) assert_equal "http://example.com/", filter.absolute_url(page_url) end should "not append a forward slash if both input and baseurl are simply '/'" do page_url = "/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/", - }) + "baseurl" => "/" + ) assert_equal "http://example.com/", filter.absolute_url(page_url) end should "normalize international URLs" do page_url = "" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://ümlaut.example.org/", - "baseurl" => nil, - }) + "baseurl" => nil + ) assert_equal "http://xn--mlaut-jva.example.org/", filter.absolute_url(page_url) end @@ -492,19 +492,19 @@ def select; end should "transform the input URL to a string" do page_url = "/my-page.html" - filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) }) + filter = make_filter_mock("url" => Value.new(proc { "http://example.org" })) assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url) end should "not raise a TypeError when passed a hash" do - assert @filter.absolute_url({ "foo" => "bar" }) + assert @filter.absolute_url("foo" => "bar") end context "with a document" do setup do - @site = fixture_site({ - "collections" => ["methods"], - }) + @site = fixture_site( + "collections" => ["methods"] + ) @site.process @document = @site.collections["methods"].docs.detect do |d| d.relative_path == "_methods/configuration.md" @@ -531,7 +531,7 @@ def select; end should "ensure the leading slash for the baseurl" do page_url = "about/my_favorite_page/" - filter = make_filter_mock({ "baseurl" => "base" }) + filter = make_filter_mock("baseurl" => "base") assert_equal "/base/#{page_url}", filter.relative_url(page_url) end @@ -542,51 +542,51 @@ def select; end should "be ok with a nil 'baseurl'" do page_url = "about/my_favorite_page/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => nil, - }) + "baseurl" => nil + ) assert_equal "/#{page_url}", filter.relative_url(page_url) end should "not prepend a forward slash if input is empty" do page_url = "" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/base", - }) + "baseurl" => "/base" + ) assert_equal "/base", filter.relative_url(page_url) end should "not prepend a forward slash if baseurl ends with a single '/'" do page_url = "/css/main.css" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/base/", - }) + "baseurl" => "/base/" + ) assert_equal "/base/css/main.css", filter.relative_url(page_url) end should "not return valid URI if baseurl ends with multiple '/'" do page_url = "/css/main.css" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/base//", - }) + "baseurl" => "/base//" + ) refute_equal "/base/css/main.css", filter.relative_url(page_url) end should "not prepend a forward slash if both input and baseurl are simply '/'" do page_url = "/" - filter = make_filter_mock({ + filter = make_filter_mock( "url" => "http://example.com", - "baseurl" => "/", - }) + "baseurl" => "/" + ) assert_equal "/", filter.relative_url(page_url) end should "not return the url by reference" do - filter = make_filter_mock({ :baseurl => nil }) + filter = make_filter_mock(:baseurl => nil) page = Page.new(filter.site, test_dir("fixtures"), "", "front_matter.erb") assert_equal "/front_matter.erb", page.url url = filter.relative_url(page.url) @@ -596,7 +596,7 @@ def select; end should "transform the input baseurl to a string" do page_url = "/my-page.html" - filter = make_filter_mock({ "baseurl" => Value.new(proc { "/baseurl/" }) }) + filter = make_filter_mock("baseurl" => Value.new(proc { "/baseurl/" })) assert_equal "/baseurl#{page_url}", filter.relative_url(page_url) end @@ -640,7 +640,7 @@ def select; end context "jsonify filter" do should "convert hash to json" do - assert_equal "{\"age\":18}", @filter.jsonify({ :age => 18 }) + assert_equal "{\"age\":18}", @filter.jsonify(:age => 18) end should "convert array to json" do @@ -705,7 +705,7 @@ def to_liquid { "name" => name, :v => 1, - :thing => M.new({ :kay => "jewelers" }), + :thing => M.new(:kay => "jewelers"), :stuff => true, } end @@ -973,7 +973,7 @@ def to_liquid @filter.site.tap(&:read) posts = @filter.site.site_payload["site"]["posts"] results = @filter.where_exp(posts, "post", - "post.date > site.dont_show_posts_before") + "post.date > site.dont_show_posts_before") assert_equal posts.select { |p| p.date > @sample_time }.count, results.length end end @@ -1085,19 +1085,19 @@ def to_liquid end should "return sorted by property array" do assert_equal [{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], - @filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") + @filter.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a") end should "return sorted by property array with numeric strings sorted as numbers" do assert_equal([{ "a" => ".5" }, { "a" => "0.65" }, { "a" => "10" }], - @filter.sort([{ "a" => "10" }, { "a" => ".5" }, { "a" => "0.65" }], "a")) + @filter.sort([{ "a" => "10" }, { "a" => ".5" }, { "a" => "0.65" }], "a")) end should "return sorted by property array with numeric strings first" do assert_equal([{ "a" => ".5" }, { "a" => "0.6" }, { "a" => "twelve" }], - @filter.sort([{ "a" => "twelve" }, { "a" => ".5" }, { "a" => "0.6" }], "a")) + @filter.sort([{ "a" => "twelve" }, { "a" => ".5" }, { "a" => "0.6" }], "a")) end should "return sorted by property array with numbers and strings " do assert_equal([{ "a" => "1" }, { "a" => "1abc" }, { "a" => "20" }], - @filter.sort([{ "a" => "20" }, { "a" => "1" }, { "a" => "1abc" }], "a")) + @filter.sort([{ "a" => "20" }, { "a" => "1" }, { "a" => "1abc" }], "a")) end should "return sorted by property array with nils first" do ary = [{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }] @@ -1106,13 +1106,13 @@ def to_liquid end should "return sorted by property array with nils last" do assert_equal [{ "a" => 1 }, { "a" => 2 }, { "b" => 1 }], - @filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last") + @filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last") end should "return sorted by subproperty array" do assert_equal [{ "a" => { "b" => 1 } }, { "a" => { "b" => 2 } }, { "a" => { "b" => 3 } },], - @filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } }, - { "a" => { "b" => 3 } },], "a.b") + @filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } }, + { "a" => { "b" => 3 } },], "a.b") end end @@ -1140,7 +1140,7 @@ def to_liquid context "inspect filter" do should "return a HTML-escaped string representation of an object" do - assert_equal "{"<a>"=>1}", @filter.inspect({ "" => 1 }) + assert_equal "{"<a>"=>1}", @filter.inspect("" => 1) end should "quote strings" do diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index dab4385c94b..ee12f205598 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -5,7 +5,7 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with full front matter defaults" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { "path" => "contacts", @@ -14,8 +14,8 @@ class TestFrontMatterDefaults < JekyllUnitTest "values" => { "key" => "val", }, - },], - }) + },] + ) @output = capture_output { @site.process } @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } @@ -33,7 +33,7 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with full front matter defaults (glob)" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { "path" => "contacts/*.html", @@ -42,8 +42,8 @@ class TestFrontMatterDefaults < JekyllUnitTest "values" => { "key" => "val", }, - },], - }) + },] + ) @output = capture_output { @site.process } @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } @@ -61,7 +61,7 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter type pages and an extension" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { "path" => "index.html", @@ -69,8 +69,8 @@ class TestFrontMatterDefaults < JekyllUnitTest "values" => { "key" => "val", }, - },], - }) + },] + ) @site.process @affected = @site.pages.find { |page| page.relative_path == "index.html" } @@ -85,7 +85,7 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter defaults with no type" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { "path" => "win", @@ -93,8 +93,8 @@ class TestFrontMatterDefaults < JekyllUnitTest "values" => { "key" => "val", }, - },], - }) + },] + ) @site.process @affected = @site.posts.docs.find { |page| page.relative_path =~ %r!win\/! } @@ -109,7 +109,7 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter defaults with no path and a deprecated type" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { "type" => "page", @@ -117,8 +117,8 @@ class TestFrontMatterDefaults < JekyllUnitTest "values" => { "key" => "val", }, - },], - }) + },] + ) @site.process @affected = @site.pages @@ -134,7 +134,7 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter defaults with no path" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { "type" => "pages", @@ -142,8 +142,8 @@ class TestFrontMatterDefaults < JekyllUnitTest "values" => { "key" => "val", }, - },], - }) + },] + ) @site.process @affected = @site.pages @not_affected = @site.posts.docs @@ -158,15 +158,15 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter defaults with no path or type" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "scope" => { }, "values" => { "key" => "val", }, - },], - }) + },] + ) @site.process @affected = @site.pages @not_affected = @site.posts @@ -180,13 +180,13 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter defaults with no scope" do setup do - @site = fixture_site({ + @site = fixture_site( "defaults" => [{ "values" => { "key" => "val", }, - },], - }) + },] + ) @site.process @affected = @site.pages @not_affected = @site.posts @@ -200,15 +200,15 @@ class TestFrontMatterDefaults < JekyllUnitTest context "A site with front matter defaults with quoted date" do setup do - @site = Site.new(Jekyll.configuration({ - "source" => source_dir, - "destination" => dest_dir, - "defaults" => [{ - "values" => { - "date" => "2015-01-01 00:00:01", - }, - },], - })) + @site = Site.new(Jekyll.configuration( + "source" => source_dir, + "destination" => dest_dir, + "defaults" => [{ + "values" => { + "date" => "2015-01-01 00:00:01", + }, + },] + )) end should "not raise error" do diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 65b82fe8b3a..56c2bf4ee14 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -70,12 +70,12 @@ class TestGeneratedSite < JekyllUnitTest time_regexp = "\\d+:\\d+" # # adding a pipe character at the beginning preserves formatting with newlines - expected_output = Regexp.new <<-OUTPUT -| - /css/screen.css last edited at #{time_regexp} with extname .css - - /pgp.key last edited at #{time_regexp} with extname .key - - /products.yml last edited at #{time_regexp} with extname .yml - - /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css -OUTPUT + expected_output = Regexp.new <<~OUTPUT + | - /css/screen.css last edited at #{time_regexp} with extname .css + - /pgp.key last edited at #{time_regexp} with extname .key + - /products.yml last edited at #{time_regexp} with extname .yml + - /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css + OUTPUT assert_match expected_output, File.read(dest_dir("static_files.html")) end end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index 62b70ddddc4..d95955f4d6b 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -40,18 +40,18 @@ class TestKramdown < JekyllUnitTest @kramdown_config_keys.each do |key| assert kramdown_config.key?(key.to_sym), - "Expected #{kramdown_config} to include key #{key.to_sym.inspect}" + "Expected #{kramdown_config} to include key #{key.to_sym.inspect}" end @syntax_highlighter_opts_config_keys.each do |key| assert kramdown_config["syntax_highlighter_opts"].key?(key.to_sym), - "Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \ - "key #{key.to_sym.inspect}" + "Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \ + "key #{key.to_sym.inspect}" end assert_equal kramdown_config["smart_quotes"], kramdown_config[:smart_quotes] assert_equal kramdown_config["syntax_highlighter_opts"]["css"], - kramdown_config[:syntax_highlighter_opts][:css] + kramdown_config[:syntax_highlighter_opts][:css] end should "run Kramdown" do @@ -82,7 +82,7 @@ class TestKramdown < JekyllUnitTest markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) assert_match %r!

(«|«)Pit(›|›)hy(»|»)<\/p>!, \ - markdown.convert(%("Pit'hy")).strip + markdown.convert(%("Pit'hy")).strip end end @@ -142,16 +142,17 @@ class TestKramdown < JekyllUnitTest should "move coderay to syntax_highlighter_opts" do original = Kramdown::Document.method(:new) - markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, { - "higlighter" => nil, - "markdown" => "kramdown", - "kramdown" => { - "syntax_highlighter" => "coderay", - "coderay" => { - "hello" => "world", - }, - }, - })) + markdown = Converters::Markdown.new( + Utils.deep_merge_hashes(@config, + "higlighter" => nil, + "markdown" => "kramdown", + "kramdown" => { + "syntax_highlighter" => "coderay", + "coderay" => { + "hello" => "world", + }, + }) + ) expect(Kramdown::Document).to receive(:new) do |arg1, hash| assert_equal hash["syntax_highlighter_opts"]["hello"], "world" diff --git a/test/test_layout_reader.rb b/test/test_layout_reader.rb index 96d2045a148..3c88586aa98 100644 --- a/test/test_layout_reader.rb +++ b/test/test_layout_reader.rb @@ -5,8 +5,8 @@ class TestLayoutReader < JekyllUnitTest context "reading layouts" do setup do - config = Jekyll::Configuration::DEFAULTS.merge({ "source" => source_dir, - "destination" => dest_dir, }) + config = Jekyll::Configuration::DEFAULTS.merge("source" => source_dir, + "destination" => dest_dir) @site = fixture_site(config) end diff --git a/test/test_liquid_extensions.rb b/test/test_liquid_extensions.rb index e281e10e5fd..30637b33315 100644 --- a/test/test_liquid_extensions.rb +++ b/test/test_liquid_extensions.rb @@ -22,11 +22,11 @@ def render(context) end should "extract the var properly" do - assert_equal @template.render({ "page" => { "name" => "tobi" } }), "hi tobi" + assert_equal @template.render("page" => { "name" => "tobi" }), "hi tobi" end should "return the variable name if the value isn't there" do - assert_equal @template.render({ "page" => { "title" => "tobi" } }), "hi page.name" + assert_equal @template.render("page" => { "title" => "tobi" }), "hi page.name" end end end diff --git a/test/test_page.rb b/test/test_page.rb index ed4c2c31a9a..a34a5694530 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -22,11 +22,11 @@ def do_render(page) context "A Page" do setup do clear_dest - @site = Site.new(Jekyll.configuration({ - "source" => source_dir, - "destination" => dest_dir, - "skip_config_files" => true, - })) + @site = Site.new(Jekyll.configuration( + "source" => source_dir, + "destination" => dest_dir, + "skip_config_files" => true + )) end context "processing pages" do diff --git a/test/test_page_without_a_file.rb b/test/test_page_without_a_file.rb index 50624890c4e..2933bfc8846 100644 --- a/test/test_page_without_a_file.rb +++ b/test/test_page_without_a_file.rb @@ -21,11 +21,11 @@ def render_and_write context "A PageWithoutAFile" do setup do clear_dest - @site = Site.new(Jekyll.configuration({ - "source" => source_dir, - "destination" => dest_dir, - "skip_config_files" => true, - })) + @site = Site.new(Jekyll.configuration( + "source" => source_dir, + "destination" => dest_dir, + "skip_config_files" => true + )) end context "with default site configuration" do diff --git a/test/test_plugin_manager.rb b/test/test_plugin_manager.rb index 213bcef6b12..b5d1a81cae6 100644 --- a/test/test_plugin_manager.rb +++ b/test/test_plugin_manager.rb @@ -24,7 +24,7 @@ def with_no_gemfile should "not require from bundler" do with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do refute Jekyll::PluginManager.require_from_bundler, - "Gemfile plugins were required but shouldn't have been" + "Gemfile plugins were required but shouldn't have been" assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"] end end @@ -35,7 +35,7 @@ def with_no_gemfile with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do with_no_gemfile do refute Jekyll::PluginManager.require_from_bundler, - "Gemfile plugins were required but shouldn't have been" + "Gemfile plugins were required but shouldn't have been" assert_nil ENV["JEKYLL_NO_BUNDLER_REQUIRE"] end end @@ -68,9 +68,9 @@ def with_no_gemfile end should "require plugin files" do - site = double({ :safe => false, - :config => { "plugins_dir" => "_plugins" }, - :in_source_dir => "/tmp/", }) + site = double(:safe => false, + :config => { "plugins_dir" => "_plugins" }, + :in_source_dir => "/tmp/") plugin_manager = PluginManager.new(site) expect(Jekyll::External).to receive(:require_with_graceful_fail) @@ -80,7 +80,7 @@ def with_no_gemfile context "site is marked as safe" do should "allow plugins if they are whitelisted" do - site = double({ :safe => true, :config => { "whitelist" => ["jemoji"] } }) + site = double(:safe => true, :config => { "whitelist" => ["jemoji"] }) plugin_manager = PluginManager.new(site) assert plugin_manager.plugin_allowed?("jemoji") @@ -88,7 +88,7 @@ def with_no_gemfile end should "not require plugin files" do - site = double({ :safe => true }) + site = double(:safe => true) plugin_manager = PluginManager.new(site) expect(Jekyll::External).to_not receive(:require_with_graceful_fail) @@ -98,12 +98,12 @@ def with_no_gemfile context "plugins_dir is set to the default" do should "call site's in_source_dir" do - site = double({ + site = double( :config => { "plugins_dir" => Jekyll::Configuration::DEFAULTS["plugins_dir"], }, - :in_source_dir => "/tmp/", - }) + :in_source_dir => "/tmp/" + ) plugin_manager = PluginManager.new(site) expect(site).to receive(:in_source_dir).with("_plugins") @@ -113,7 +113,7 @@ def with_no_gemfile context "plugins_dir is set to a different dir" do should "expand plugin path" do - site = double({ :config => { "plugins_dir" => "some_other_plugins_path" } }) + site = double(:config => { "plugins_dir" => "some_other_plugins_path" }) plugin_manager = PluginManager.new(site) expect(File).to receive(:expand_path).with("some_other_plugins_path") @@ -123,7 +123,7 @@ def with_no_gemfile context "`paginate` config is activated" do should "print deprecation warning if jekyll-paginate is not present" do - site = double({ :config => { "paginate" => true } }) + site = double(:config => { "paginate" => true }) plugin_manager = PluginManager.new(site) expect(Jekyll::Deprecator).to( @@ -133,9 +133,9 @@ def with_no_gemfile end should "print no deprecation warning if jekyll-paginate is present" do - site = double({ - :config => { "paginate" => true, "plugins" => ["jekyll-paginate"] }, - }) + site = double( + :config => { "paginate" => true, "plugins" => ["jekyll-paginate"] } + ) plugin_manager = PluginManager.new(site) expect(Jekyll::Deprecator).to_not receive(:deprecation_message) @@ -144,10 +144,10 @@ def with_no_gemfile end should "conscientious require" do - site = double({ + site = double( :config => { "theme" => "test-dependency-theme" }, - :in_dest_dir => "/tmp/_site/", - }) + :in_dest_dir => "/tmp/_site/" + ) plugin_manager = PluginManager.new(site) expect(site).to receive(:theme).and_return(true) diff --git a/test/test_regenerator.rb b/test/test_regenerator.rb index 3a5d35a8aa8..122bc40f440 100644 --- a/test/test_regenerator.rb +++ b/test/test_regenerator.rb @@ -7,14 +7,14 @@ class TestRegenerator < JekyllUnitTest setup do FileUtils.rm_rf(source_dir(".jekyll-metadata")) - @site = fixture_site({ + @site = fixture_site( "collections" => { "methods" => { "output" => true, }, }, - "incremental" => true, - }) + "incremental" => true + ) @site.read @page = @site.pages.first @@ -93,9 +93,9 @@ class TestRegenerator < JekyllUnitTest context "The site regenerator" do setup do FileUtils.rm_rf(source_dir(".jekyll-metadata")) - @site = fixture_site({ - "incremental" => true, - }) + @site = fixture_site( + "incremental" => true + ) @site.read @post = @site.posts.first @@ -128,11 +128,11 @@ class TestRegenerator < JekyllUnitTest setup do FileUtils.rm_rf(source_dir(".jekyll-metadata")) - @site = Site.new(Jekyll.configuration({ - "source" => source_dir, - "destination" => dest_dir, - "incremental" => true, - })) + @site = Site.new(Jekyll.configuration( + "source" => source_dir, + "destination" => dest_dir, + "incremental" => true + )) @site.process @path = @site.in_source_dir(@site.pages.first.path) @@ -183,7 +183,7 @@ class TestRegenerator < JekyllUnitTest should "not crash when reading corrupted marshal file" do metadata_file = source_dir(".jekyll-metadata") File.open(metadata_file, "w") do |file| - file.puts Marshal.dump({ :foo => "bar" })[0, 5] + file.puts Marshal.dump(:foo => "bar")[0, 5] end @regenerator = Regenerator.new(@site) @@ -310,11 +310,11 @@ class TestRegenerator < JekyllUnitTest context "when incremental regeneration is disabled" do setup do FileUtils.rm_rf(source_dir(".jekyll-metadata")) - @site = Site.new(Jekyll.configuration({ - "source" => source_dir, - "destination" => dest_dir, - "incremental" => false, - })) + @site = Site.new(Jekyll.configuration( + "source" => source_dir, + "destination" => dest_dir, + "incremental" => false + )) @site.process @path = @site.in_source_dir(@site.pages.first.path) diff --git a/test/test_related_posts.rb b/test/test_related_posts.rb index d6a8fe6f1f3..7f9a978f1a5 100644 --- a/test/test_related_posts.rb +++ b/test/test_related_posts.rb @@ -29,9 +29,9 @@ class TestRelatedPosts < JekyllUnitTest end allow_any_instance_of(Jekyll::RelatedPosts).to receive(:display) - @site = fixture_site({ - "lsi" => true, - }) + @site = fixture_site( + "lsi" => true + ) @site.reset @site.read diff --git a/test/test_sass.rb b/test/test_sass.rb index 15b04162f01..686631d6020 100644 --- a/test/test_sass.rb +++ b/test/test_sass.rb @@ -5,10 +5,10 @@ class TestSass < JekyllUnitTest context "importing partials" do setup do - @site = Jekyll::Site.new(Jekyll.configuration({ - "source" => source_dir, - "destination" => dest_dir, - })) + @site = Jekyll::Site.new(Jekyll.configuration( + "source" => source_dir, + "destination" => dest_dir + )) @site.process @test_css_file = dest_dir("css/main.css") end diff --git a/test/test_site.rb b/test/test_site.rb index 0af32fcbeb6..63fb63fde66 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -15,7 +15,7 @@ def read_posts @site.posts.docs.concat(PostReader.new(@site).read_posts("")) posts = Dir[source_dir("_posts", "**", "*")] posts.delete_if do |post| - File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) + File.directory?(post) && post !~ Document::DATE_FILENAME_MATCHER end end @@ -31,15 +31,15 @@ def read_posts end should "have an array for plugins if passed as a string" do - site = Site.new(site_configuration({ "plugins_dir" => "/tmp/plugins" })) + site = Site.new(site_configuration("plugins_dir" => "/tmp/plugins")) array = Utils::Platforms.windows? ? ["C:/tmp/plugins"] : ["/tmp/plugins"] assert_equal array, site.plugins end should "have an array for plugins if passed as an array" do - site = Site.new(site_configuration({ - "plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"], - })) + site = Site.new(site_configuration( + "plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"] + )) array = if Utils::Platforms.windows? ["C:/tmp/plugins", "C:/tmp/otherplugins"] else @@ -49,12 +49,12 @@ def read_posts end should "have an empty array for plugins if nothing is passed" do - site = Site.new(site_configuration({ "plugins_dir" => [] })) + site = Site.new(site_configuration("plugins_dir" => [])) assert_equal [], site.plugins end should "have the default for plugins if nil is passed" do - site = Site.new(site_configuration({ "plugins_dir" => nil })) + site = Site.new(site_configuration("plugins_dir" => nil)) assert_equal [source_dir("_plugins")], site.plugins end @@ -64,19 +64,19 @@ def read_posts end should "expose baseurl passed in from config" do - site = Site.new(site_configuration({ "baseurl" => "/blog" })) + site = Site.new(site_configuration("baseurl" => "/blog")) assert_equal "/blog", site.baseurl end should "only include theme includes_path if the path exists" do - site = fixture_site({ "theme" => "test-theme" }) + site = fixture_site("theme" => "test-theme") assert_equal [source_dir("_includes"), theme_dir("_includes")], - site.includes_load_paths + site.includes_load_paths allow(File).to receive(:directory?).with(theme_dir("_sass")).and_return(true) allow(File).to receive(:directory?).with(theme_dir("_layouts")).and_return(true) allow(File).to receive(:directory?).with(theme_dir("_includes")).and_return(false) - site = fixture_site({ "theme" => "test-theme" }) + site = fixture_site("theme" => "test-theme") assert_equal [source_dir("_includes")], site.includes_load_paths end end @@ -87,9 +87,7 @@ def read_posts end teardown do - if defined?(MyGenerator) - self.class.send(:remove_const, :MyGenerator) - end + self.class.send(:remove_const, :MyGenerator) if defined?(MyGenerator) end should "have an empty tag hash by default" do @@ -279,7 +277,7 @@ def generate(site) posts = Dir[source_dir("**", "_posts", "**", "*")] posts.delete_if do |post| - File.directory?(post) && !(post =~ Document::DATE_FILENAME_MATCHER) + File.directory?(post) && post !~ Document::DATE_FILENAME_MATCHER end categories = %w( 2013 bar baz category foo z_category MixedCase Mixedcase publish_test win @@ -305,9 +303,9 @@ def generate(site) should "raise for bad frontmatter if strict_front_matter is set" do site = Site.new(site_configuration( - "collections" => ["broken"], - "strict_front_matter" => true - )) + "collections" => ["broken"], + "strict_front_matter" => true + )) assert_raises(Psych::SyntaxError) do site.process end @@ -315,9 +313,9 @@ def generate(site) should "not raise for bad frontmatter if strict_front_matter is not set" do site = Site.new(site_configuration( - "collections" => ["broken"], - "strict_front_matter" => false - )) + "collections" => ["broken"], + "strict_front_matter" => false + )) site.process end end @@ -412,9 +410,9 @@ def convert(*_args) bad_processor = "Custom::Markdown" s = Site.new(site_configuration( - "markdown" => bad_processor, - "incremental" => false - )) + "markdown" => bad_processor, + "incremental" => false + )) assert_raises Jekyll::Errors::FatalException do s.process end @@ -433,9 +431,9 @@ def convert(*_args) should "throw FatalException at process time" do bad_processor = "not a processor name" s = Site.new(site_configuration( - "markdown" => bad_processor, - "incremental" => false - )) + "markdown" => bad_processor, + "incremental" => false + )) assert_raises Jekyll::Errors::FatalException do s.process end @@ -489,8 +487,8 @@ def convert(*_args) site.process file_content = SafeYAML.load_file(File.join( - source_dir, "_data", "categories", "dairy.yaml" - )) + source_dir, "_data", "categories", "dairy.yaml" + )) assert_equal site.data["categories"]["dairy"], file_content assert_equal( @@ -504,8 +502,8 @@ def convert(*_args) site.process file_content = SafeYAML.load_file(File.join( - source_dir, "_data", "categories.01", "dairy.yaml" - )) + source_dir, "_data", "categories.01", "dairy.yaml" + )) assert_equal site.data["categories01"]["dairy"], file_content assert_equal( @@ -536,9 +534,9 @@ def convert(*_args) context "manipulating the Jekyll environment" do setup do - @site = Site.new(site_configuration({ - "incremental" => false, - })) + @site = Site.new(site_configuration( + "incremental" => false + )) @site.process @page = @site.pages.find { |p| p.name == "environment.html" } end @@ -550,9 +548,9 @@ def convert(*_args) context "in production" do setup do ENV["JEKYLL_ENV"] = "production" - @site = Site.new(site_configuration({ - "incremental" => false, - })) + @site = Site.new(site_configuration( + "incremental" => false + )) @site.process @page = @site.pages.find { |p| p.name == "environment.html" } end @@ -571,13 +569,13 @@ def convert(*_args) should "set no theme if config is not set" do expect($stderr).not_to receive(:puts) expect($stdout).not_to receive(:puts) - site = fixture_site({ "theme" => nil }) + site = fixture_site("theme" => nil) assert_nil site.theme end should "set no theme if config is a hash" do output = capture_output do - site = fixture_site({ "theme" => {} }) + site = fixture_site("theme" => {}) assert_nil site.theme end expected_msg = "Theme: value of 'theme' in config should be String " \ @@ -589,7 +587,7 @@ def convert(*_args) [:debug, :info, :warn, :error].each do |level| expect(Jekyll.logger.writer).not_to receive(level) end - site = fixture_site({ "theme" => "test-theme" }) + site = fixture_site("theme" => "test-theme") assert_instance_of Jekyll::Theme, site.theme assert_equal "test-theme", site.theme.name end @@ -616,9 +614,9 @@ def convert(*_args) context "incremental build" do setup do - @site = Site.new(site_configuration({ - "incremental" => true, - })) + @site = Site.new(site_configuration( + "incremental" => true + )) @site.read end diff --git a/test/test_site_drop.rb b/test/test_site_drop.rb index 43c52d708a5..01f3bed3ffc 100644 --- a/test/test_site_drop.rb +++ b/test/test_site_drop.rb @@ -5,9 +5,9 @@ class TestSiteDrop < JekyllUnitTest context "a site drop" do setup do - @site = fixture_site({ - "collections" => ["thanksgiving"], - }) + @site = fixture_site( + "collections" => ["thanksgiving"] + ) @site.process @drop = @site.to_liquid.site end diff --git a/test/test_static_file.rb b/test/test_static_file.rb index e306d2a299e..96663bacd69 100644 --- a/test/test_static_file.rb +++ b/test/test_static_file.rb @@ -70,7 +70,7 @@ def setup_static_file_with_defaults(base, dir, name, defaults) "root", "_foo/dir/subdir", "file.html", - { "output" => true } + "output" => true ) assert_equal :foo, static_file.type assert_equal "/foo/dir/subdir/file.html", static_file.url @@ -82,7 +82,7 @@ def setup_static_file_with_defaults(base, dir, name, defaults) "root", "_foo/dir/subdir", "file.html", - { "output" => true, "permalink" => "/:path/" } + "output" => true, "permalink" => "/:path/" ) assert_equal :foo, static_file.type assert_equal "/dir/subdir/file.html", static_file.url @@ -92,7 +92,7 @@ def setup_static_file_with_defaults(base, dir, name, defaults) should "be writable by default" do static_file = setup_static_file("root", "dir/subdir", "file.html") assert(static_file.write?, - "static_file.write? should return true by default") + "static_file.write? should return true by default") end should "use the _config.yml defaults to determine writability" do @@ -107,8 +107,8 @@ def setup_static_file_with_defaults(base, dir, name, defaults) defaults ) assert(!static_file.write?, - "static_file.write? should return false when _config.yml sets " \ - "`published: false`") + "static_file.write? should return false when _config.yml sets " \ + "`published: false`") end should "respect front matter defaults" do diff --git a/test/test_tags.rb b/test/test_tags.rb index 54b8e4b7a63..4141b13b234 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -26,20 +26,20 @@ def create_post(content, override = {}, converter_class = Jekyll::Converters::Ma # rubocop:enable Metrics/AbcSize def fill_post(code, override = {}) - content = < "pygments" }) + fill_post("test", "highlighter" => "pygments") end should "not cause a markdown error" do @@ -202,7 +202,7 @@ def highlight_block_with_opts(options_string) context "post content has highlight with file reference" do setup do - fill_post("./jekyll.gemspec", { "highlighter" => "pygments" }) + fill_post("./jekyll.gemspec", "highlighter" => "pygments") end should "not embed the file" do @@ -216,7 +216,7 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with UTF character" do setup do - fill_post("Æ", { "highlighter" => "pygments" }) + fill_post("Æ", "highlighter" => "pygments") end should "render markdown with pygments line handling" do @@ -230,14 +230,14 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with preceding spaces & lines" do setup do - code = <<-EOS + code = <<~EOS - [,1] [,2] -[1,] FALSE TRUE -[2,] FALSE TRUE -EOS - fill_post(code, { "highlighter" => "pygments" }) + [,1] [,2] + [1,] FALSE TRUE + [2,] FALSE TRUE + EOS + fill_post(code, "highlighter" => "pygments") end should "only strip the preceding newlines" do @@ -252,18 +252,18 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag " \ "with preceding spaces & lines in several places" do setup do - code = <<-EOS + code = <<~EOS - [,1] [,2] + [,1] [,2] -[1,] FALSE TRUE -[2,] FALSE TRUE + [1,] FALSE TRUE + [2,] FALSE TRUE -EOS - fill_post(code, { "highlighter" => "pygments" }) + EOS + fill_post(code, "highlighter" => "pygments") end should "only strip the newlines which precede and succeed the entire block" do @@ -278,7 +278,7 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with " \ "preceding spaces & Windows-style newlines" do setup do - fill_post "\r\n\r\n\r\n [,1] [,2]", { "highlighter" => "pygments" } + fill_post "\r\n\r\n\r\n [,1] [,2]", "highlighter" => "pygments" end should "only strip the preceding newlines" do @@ -292,12 +292,12 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with only preceding spaces" do setup do - code = <<-EOS - [,1] [,2] -[1,] FALSE TRUE -[2,] FALSE TRUE -EOS - fill_post(code, { "highlighter" => "pygments" }) + code = <<~EOS + [,1] [,2] + [1,] FALSE TRUE + [2,] FALSE TRUE + EOS + fill_post(code, "highlighter" => "pygments") end should "only strip the preceding newlines" do @@ -337,17 +337,17 @@ def highlight_block_with_opts(options_string) context "post content has raw tag" do setup do - content = <<-CONTENT ---- -title: This is a test ---- - -```liquid -{% raw %} -{{ site.baseurl }}{% link _collection/name-of-document.md %} -{% endraw %} -``` -CONTENT + content = <<~CONTENT + --- + title: This is a test + --- + + ```liquid + {% raw %} + {{ site.baseurl }}{% link _collection/name-of-document.md %} + {% endraw %} + ``` + CONTENT create_post(content) end @@ -389,13 +389,13 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with preceding spaces & lines" do setup do - fill_post <<-EOS + fill_post <<~EOS - [,1] [,2] -[1,] FALSE TRUE -[2,] FALSE TRUE -EOS + [,1] [,2] + [1,] FALSE TRUE + [2,] FALSE TRUE + EOS end should "only strip the preceding newlines" do @@ -409,17 +409,17 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with " \ "preceding spaces & lines in several places" do setup do - fill_post <<-EOS + fill_post <<~EOS - [,1] [,2] + [,1] [,2] -[1,] FALSE TRUE -[2,] FALSE TRUE + [1,] FALSE TRUE + [2,] FALSE TRUE -EOS + EOS end should "only strip the newlines which precede and succeed the entire block" do @@ -433,27 +433,27 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with linenumbers" do setup do - create_post <<-EOS ---- -title: This is a test ---- + create_post <<~EOS + --- + title: This is a test + --- -This is not yet highlighted -{% highlight php linenos %} -test -{% endhighlight %} + This is not yet highlighted + {% highlight php linenos %} + test + {% endhighlight %} -This should not be highlighted, right? -EOS + This should not be highlighted, right? + EOS end should "should stop highlighting at boundary with rouge" do - expected = <<-EOS -

This is not yet highlighted

\n -
1
-
test
\n -

This should not be highlighted, right?

-EOS + expected = <<~EOS +

This is not yet highlighted

\n +
1
+          
test
\n +

This should not be highlighted, right?

+ EOS assert_match(expected, @result) end end @@ -474,11 +474,11 @@ def highlight_block_with_opts(options_string) context "post content has highlight tag with only preceding spaces" do setup do - fill_post <<-EOS - [,1] [,2] -[1,] FALSE TRUE -[2,] FALSE TRUE -EOS + fill_post <<~EOS + [,1] [,2] + [1,] FALSE TRUE + [2,] FALSE TRUE + EOS end should "only strip the preceding newlines" do @@ -492,19 +492,19 @@ def highlight_block_with_opts(options_string) context "simple post with markdown and pre tags" do setup do - @content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% post_url 2008-11-21-complex %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "not cause an error" do @@ -547,19 +546,18 @@ def highlight_block_with_opts(options_string) context "simple page with post linking containing special characters" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% post_url 2016-11-26-special-chars-(+) %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "not cause an error" do @@ -573,22 +571,21 @@ def highlight_block_with_opts(options_string) context "simple page with nested post linking" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + content = <<~CONTENT + --- + title: Post linking + --- + + - 1 {% post_url 2008-11-21-complex %} + - 2 {% post_url /2008-11-21-complex %} + - 3 {% post_url es/2008-11-21-nested %} + - 4 {% post_url /es/2008-11-21-nested %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "not cause an error" do @@ -608,19 +605,18 @@ def highlight_block_with_opts(options_string) context "simple page with nested post linking and path not used in `post_url`" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + - 1 {% post_url 2008-11-21-nested %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "not cause an error" do @@ -642,60 +638,57 @@ def highlight_block_with_opts(options_string) context "simple page with invalid post name linking" do should "cause an error" do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end end should "cause an error with a bad date" do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end end end context "simple page with linking to a page" do setup do - content = < source_dir, - "destination" => dest_dir, - "read_all" => true, - }) + content = <<~CONTENT + --- + title: linking + --- + + {% link contacts.html %} + {% link info.md %} + {% link /css/screen.css %} + CONTENT + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "read_all" => true) end should "not cause an error" do @@ -717,24 +710,23 @@ def highlight_block_with_opts(options_string) context "simple page with dynamic linking to a page" do setup do - content = < source_dir, - "destination" => dest_dir, - "read_all" => true, - }) + content = <<~CONTENT + --- + title: linking + --- + + {% assign contacts_filename = 'contacts' %} + {% assign contacts_ext = 'html' %} + {% link {{contacts_filename}}.{{contacts_ext}} %} + {% assign info_path = 'info.md' %} + {% link {{\ info_path\ }} %} + {% assign screen_css_path = '/css' %} + {% link {{ screen_css_path }}/screen.css %} + CONTENT + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "read_all" => true) end should "not cause an error" do @@ -756,19 +748,18 @@ def highlight_block_with_opts(options_string) context "simple page with linking" do setup do - content = < source_dir, - "destination" => dest_dir, - "collections" => { "methods" => { "output" => true } }, - "read_collections" => true, - }) + {% link _methods/yaml_with_dots.md %} + CONTENT + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "collections" => { "methods" => { "output" => true } }, + "read_collections" => true) end should "not cause an error" do @@ -782,20 +773,19 @@ def highlight_block_with_opts(options_string) context "simple page with dynamic linking" do setup do - content = < source_dir, - "destination" => dest_dir, - "collections" => { "methods" => { "output" => true } }, - "read_collections" => true, - }) + content = <<~CONTENT + --- + title: linking + --- + + {% assign yaml_with_dots_path = '_methods/yaml_with_dots.md' %} + {% link {{yaml_with_dots_path}} %} + CONTENT + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "collections" => { "methods" => { "output" => true } }, + "read_collections" => true) end should "not cause an error" do @@ -809,20 +799,19 @@ def highlight_block_with_opts(options_string) context "simple page with nested linking" do setup do - content = < source_dir, - "destination" => dest_dir, - "collections" => { "methods" => { "output" => true } }, - "read_collections" => true, - }) + content = <<~CONTENT + --- + title: linking + --- + + - 1 {% link _methods/sanitized_path.md %} + - 2 {% link _methods/site/generate.md %} + CONTENT + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "collections" => { "methods" => { "output" => true } }, + "read_collections" => true) end should "not cause an error" do @@ -840,43 +829,41 @@ def highlight_block_with_opts(options_string) context "simple page with invalid linking" do should "cause an error" do - content = < source_dir, - "destination" => dest_dir, - "collections" => { "methods" => { "output" => true } }, - "read_collections" => true, - }) + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "collections" => { "methods" => { "output" => true } }, + "read_collections" => true) end end end context "simple page with invalid dynamic linking" do should "cause an error" do - content = < source_dir, - "destination" => dest_dir, - "collections" => { "methods" => { "output" => true } }, - "read_collections" => true, - }) + create_post(content, + "source" => source_dir, + "destination" => dest_dir, + "collections" => { "methods" => { "output" => true } }, + "read_collections" => true) end end end @@ -886,21 +873,20 @@ def highlight_block_with_opts(options_string) should "not allow symlink includes" do File.open("tmp/pages-test", "w") { |file| file.write("SYMLINK TEST") } assert_raises IOError do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - "safe" => true, - }) + content = <<~CONTENT + --- + title: Include symlink + --- + + {% include tmp/pages-test %} + + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true, + "safe" => true) end @result ||= "" refute_match(%r!SYMLINK TEST!, @result) @@ -908,21 +894,20 @@ def highlight_block_with_opts(options_string) should "not expose the existence of symlinked files" do ex = assert_raises IOError do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - "safe" => true, - }) + content = <<~CONTENT + --- + title: Include symlink + --- + + {% include tmp/pages-test-does-not-exist %} + + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true, + "safe" => true) end assert_match( "Could not locate the included file 'tmp/pages-test-does-not-exist' " \ @@ -936,21 +921,20 @@ def highlight_block_with_opts(options_string) context "with one parameter" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% include params.html param="value" %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "correctly output include variable" do @@ -964,22 +948,21 @@ def highlight_block_with_opts(options_string) context "with simple syntax but multiline markup" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% include params.html + param="value" %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "correctly output include variable" do @@ -993,22 +976,21 @@ def highlight_block_with_opts(options_string) context "with variable syntax but multiline markup" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + content = <<~CONTENT + --- + title: Include tag parameters + --- + + {% include sig.markdown myparam="test" %} + {% assign path = "params" | append: ".html" %} + {% include {{ path }} + param="value" %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "correctly output include variable" do @@ -1022,57 +1004,54 @@ def highlight_block_with_opts(options_string) context "with invalid parameter syntax" do should "throw a ArgumentError" do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end end end context "with several parameters" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% include params.html param1="new_value" param2="another" %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "list all parameters" do @@ -1087,19 +1066,18 @@ def highlight_block_with_opts(options_string) context "without parameters" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% include params.html %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "include file with empty parameters" do @@ -1109,20 +1087,19 @@ def highlight_block_with_opts(options_string) context "with custom includes directory" do setup do - content = < "_includes_custom", - "permalink" => "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + content = <<~CONTENT + --- + title: custom includes directory + --- + + {% include custom.html %} + CONTENT + create_post(content, + "includes_dir" => "_includes_custom", + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "include file from custom directory" do @@ -1132,19 +1109,18 @@ def highlight_block_with_opts(options_string) context "without parameters within if statement" do setup do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + {% if true %}{% include params.html %}{% endif %} + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end should "include file with empty parameters within if statement" do @@ -1154,23 +1130,22 @@ def highlight_block_with_opts(options_string) context "include missing file" do setup do - @content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(@content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end assert_match( "Could not locate the included file 'missing.html' in any of " \ @@ -1182,7 +1157,7 @@ def highlight_block_with_opts(options_string) context "include tag with variable and liquid filters" do setup do - site = fixture_site({ "pygments" => true }).tap(&:read).tap(&:render) + site = fixture_site("pygments" => true).tap(&:read).tap(&:render) post = site.posts.docs.find do |p| p.basename.eql? "2013-12-17-include-variable-filters.markdown" end @@ -1214,7 +1189,7 @@ def highlight_block_with_opts(options_string) context "relative include tag with variable and liquid filters" do setup do - site = fixture_site({ "pygments" => true }).tap(&:read).tap(&:render) + site = fixture_site("pygments" => true).tap(&:read).tap(&:render) post = site.posts.docs.find do |p| p.basename.eql? "2014-09-02-relative-includes.markdown" end @@ -1249,23 +1224,22 @@ def highlight_block_with_opts(options_string) context "trying to do bad stuff" do context "include missing file" do setup do - @content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(@content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end assert_match "Could not locate the included file 'missing.html' in any of " \ "[\"#{source_dir}\"].", exception.message @@ -1274,23 +1248,22 @@ def highlight_block_with_opts(options_string) context "include existing file above you" do setup do - @content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - }) + create_post(@content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true) end assert_equal( "Invalid syntax for include tag. File contains invalid characters or " \ @@ -1306,21 +1279,20 @@ def highlight_block_with_opts(options_string) should "not allow symlink includes" do File.open("tmp/pages-test", "w") { |file| file.write("SYMLINK TEST") } assert_raises IOError do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - "safe" => true, - }) + content = <<~CONTENT + --- + title: Include symlink + --- + + {% include_relative tmp/pages-test %} + + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true, + "safe" => true) end @result ||= "" refute_match(%r!SYMLINK TEST!, @result) @@ -1328,21 +1300,20 @@ def highlight_block_with_opts(options_string) should "not expose the existence of symlinked files" do ex = assert_raises IOError do - content = < "pretty", - "source" => source_dir, - "destination" => dest_dir, - "read_posts" => true, - "safe" => true, - }) + content = <<~CONTENT + --- + title: Include symlink + --- + + {% include_relative tmp/pages-test-does-not-exist %} + + CONTENT + create_post(content, + "permalink" => "pretty", + "source" => source_dir, + "destination" => dest_dir, + "read_posts" => true, + "safe" => true) end assert_match( "Ensure it exists in one of those directories and is not a symlink "\ diff --git a/test/test_utils.rb b/test/test_utils.rb index 844ef825d35..509f92e861d 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -202,20 +202,20 @@ class TestUtils < JekyllUnitTest should "replace everything else but ASCII characters" do assert_equal "the-config-yml-file", - Utils.slugify("The _config.yml file?", :mode => "ascii") + Utils.slugify("The _config.yml file?", :mode => "ascii") assert_equal "f-rtive-glance", - Utils.slugify("fürtive glance!!!!", :mode => "ascii") + Utils.slugify("fürtive glance!!!!", :mode => "ascii") end should "map accented latin characters to ASCII characters" do assert_equal "the-config-yml-file", - Utils.slugify("The _config.yml file?", :mode => "latin") + Utils.slugify("The _config.yml file?", :mode => "latin") assert_equal "furtive-glance", - Utils.slugify("fürtive glance!!!!", :mode => "latin") + Utils.slugify("fürtive glance!!!!", :mode => "latin") assert_equal "aaceeiioouu", - Utils.slugify("àáçèéíïòóúü", :mode => "latin") + Utils.slugify("àáçèéíïòóúü", :mode => "latin") assert_equal "a-z", - Utils.slugify("Aあわれ鬱господинZ", :mode => "latin") + Utils.slugify("Aあわれ鬱господинZ", :mode => "latin") end should "only replace whitespace if mode is raw" do From e10444abf754116ce834e9b8e300342c394c7a9f Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Thu, 12 Jul 2018 10:21:25 -0400 Subject: [PATCH 316/337] Update history to reflect merge of #7128 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 39f23f52be2..cbb7bebfff4 100644 --- a/History.markdown +++ b/History.markdown @@ -69,6 +69,7 @@ * Use assert_include (#7093) * Update rubocop version to 0.57.x ### -docs (#7078) * Example of CircleCI deployment through CircleCI v2 (#7024) + * Fix Rubocop offences in test files (#7128) ### Bug Fixes From f9ada3ced6974330ee3e34facc49c82144e23a9c Mon Sep 17 00:00:00 2001 From: Scott Killen Date: Fri, 13 Jul 2018 06:33:56 -0400 Subject: [PATCH 317/337] Fix custom 404 page for GitHub pages (#7132) Merge pull request 7132 --- lib/site_template/404.html | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/site_template/404.html b/lib/site_template/404.html index c472b4ea0a7..086a5c9ea98 100644 --- a/lib/site_template/404.html +++ b/lib/site_template/404.html @@ -1,4 +1,5 @@ --- +permalink: /404.html layout: default --- From b69196cad3449ccb4134dba8b42594dae563bdbc Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Fri, 13 Jul 2018 06:33:58 -0400 Subject: [PATCH 318/337] Update history to reflect merge of #7132 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index cbb7bebfff4..9a59584e10d 100644 --- a/History.markdown +++ b/History.markdown @@ -43,6 +43,7 @@ * Suggest re-running command with --trace on fail (#6551) * Update item_property to return numbers as numbers instead of strings (#6608) * Use .markdown for page templates (#7126) + * Fix custom 404 page for GitHub pages (#7132) ### Major Enhancements From 7a4b3fe03da3cb0c6f008ed3ce4ee4e417186b58 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Fri, 13 Jul 2018 11:12:49 -0500 Subject: [PATCH 319/337] Disable Liquid via front matter (#6824) Merge pull request 6824 --- features/post_data.feature | 13 +++++++++++++ lib/jekyll/convertible.rb | 1 + lib/jekyll/document.rb | 1 + test/fixtures/no_liquid.erb | 4 ++++ test/test_convertible.rb | 7 +++++++ 5 files changed, 26 insertions(+) create mode 100644 test/fixtures/no_liquid.erb diff --git a/features/post_data.feature b/features/post_data.feature index 79b92c2677a..c288115d393 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -251,6 +251,19 @@ Feature: Post data And I should see "Post categories: scifi and Movies" in "_site/scifi/movies/2009/03/27/star-wars.html" And I should see "Post categories: SciFi and movies" in "_site/scifi/movies/2013/03/17/star-trek.html" +Scenario: Use page.render_with_liquid variable + Given I have a _posts directory + And I have the following posts: + | title | render_with_liquid | date | content | + | Unrendered Post | false | 2017-07-06 | Hello {{ page.title }} | + | Rendered Post | true | 2017-07-06 | Hello {{ page.title }} | + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should not see "Hello Unrendered Post" in "_site/2017/07/06/unrendered-post.html" + But I should see "Hello {{ page.title }}" in "_site/2017/07/06/unrendered-post.html" + And I should see "Hello Rendered Post" in "_site/2017/07/06/rendered-post.html" + Scenario Outline: Use page.path variable Given I have a /_posts directory And I have the following post in "": diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 5e703505f7b..85532ba9d02 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -160,6 +160,7 @@ def coffeescript_file? # # Returns true if the file has Liquid Tags or Variables, false otherwise. def render_with_liquid? + return false if data["render_with_liquid"] == false Jekyll::Utils.has_liquid_construct?(content) end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index dbc1a6d82a0..8b6e54e3e12 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -159,6 +159,7 @@ def coffeescript_file? # or if the document doesn't contain any Liquid Tags or Variables, # true otherwise. def render_with_liquid? + return false if data["render_with_liquid"] == false !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) end diff --git a/test/fixtures/no_liquid.erb b/test/fixtures/no_liquid.erb new file mode 100644 index 00000000000..bfb7fc46fe7 --- /dev/null +++ b/test/fixtures/no_liquid.erb @@ -0,0 +1,4 @@ +--- +render_with_liquid: false +--- +{% raw %}{% endraw %} diff --git a/test/test_convertible.rb b/test/test_convertible.rb index a3bea6baf48..8c204ebf514 100644 --- a/test/test_convertible.rb +++ b/test/test_convertible.rb @@ -73,5 +73,12 @@ class TestConvertible < JekyllUnitTest end refute_match(%r!Invalid permalink!, out) end + + should "not parse Liquid if disabled in front matter" do + name = "no_liquid.erb" + @convertible.read_yaml(@base, name) + ret = @convertible.content.strip + assert_equal("{% raw %}{% endraw %}", ret) + end end end From 3be9e74942a5aab465d85aeb29bb035248e0d84b Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Fri, 13 Jul 2018 12:12:51 -0400 Subject: [PATCH 320/337] Update history to reflect merge of #6824 [ci skip] --- History.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.markdown b/History.markdown index 9a59584e10d..194b60b3cb0 100644 --- a/History.markdown +++ b/History.markdown @@ -76,6 +76,10 @@ * Add call to unused method `validate_options` in `commands/serve.rb` (#7122) +### feature + + * Disable Liquid via front matter (#6824) + ## 3.8.3 / 2018-06-05 ### Bug Fixes From c7ce7ae0549b8f79c3598c17f61f44779c30f404 Mon Sep 17 00:00:00 2001 From: Ken Salomon Date: Fri, 13 Jul 2018 19:48:00 -0400 Subject: [PATCH 321/337] fix up refute_equal call (#7133) Merge pull request 7133 --- test/test_collections.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_collections.rb b/test/test_collections.rb index 7af86dd8c87..9d4e9b9d394 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -87,7 +87,8 @@ class TestCollections < JekyllUnitTest end should "contain only the default collections" do - refute_equal @site.collections, {} + expected = {} + refute_equal expected, @site.collections refute_nil @site.collections end end From 16e9820dac7c29b5ad835ec7ca1023301f7963d0 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Fri, 13 Jul 2018 19:48:02 -0400 Subject: [PATCH 322/337] Update history to reflect merge of #7133 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 194b60b3cb0..47d54f03b08 100644 --- a/History.markdown +++ b/History.markdown @@ -71,6 +71,7 @@ * Update rubocop version to 0.57.x ### -docs (#7078) * Example of CircleCI deployment through CircleCI v2 (#7024) * Fix Rubocop offences in test files (#7128) + * fix up refute_equal call (#7133) ### Bug Fixes From 506c764e1e40f0202fa912aa3993c73a099fb314 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 16 Jul 2018 01:41:45 +0530 Subject: [PATCH 323/337] fix incorrectly passed arguments to assert_equal (#7134) Merge pull request 7134 --- test/test_ansi.rb | 2 +- test/test_collections.rb | 29 ++++++++-------- test/test_commands_serve.rb | 12 +++---- test/test_configuration.rb | 60 +++++++++++++++------------------- test/test_kramdown.rb | 2 +- test/test_liquid_extensions.rb | 4 +-- test/test_regenerator.rb | 3 +- 7 files changed, 52 insertions(+), 60 deletions(-) diff --git a/test/test_ansi.rb b/test/test_ansi.rb index e780e0dd521..c8aef1db949 100644 --- a/test/test_ansi.rb +++ b/test/test_ansi.rb @@ -15,7 +15,7 @@ class TestAnsi < JekyllUnitTest end should "be able to strip colors" do - assert_equal @subject.strip(@subject.yellow(@subject.red("hello"))), "hello" + assert_equal "hello", @subject.strip(@subject.yellow(@subject.red("hello"))) end should "be able to detect colors" do diff --git a/test/test_collections.rb b/test/test_collections.rb index 9d4e9b9d394..eb1eb0f6371 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -9,11 +9,11 @@ class TestCollections < JekyllUnitTest end should "sanitize the label name" do - assert_equal @collection.label, "....etcpassword" + assert_equal "....etcpassword", @collection.label end should "have a sanitized relative path name" do - assert_equal @collection.relative_directory, "_....etcpassword" + assert_equal "_....etcpassword", @collection.relative_directory end should "have a sanitized full path" do @@ -27,11 +27,11 @@ class TestCollections < JekyllUnitTest end should "sanitize the label name" do - assert_equal @collection.label, "methods" + assert_equal "methods", @collection.label end should "have default URL template" do - assert_equal @collection.url_template, "/:collection/:path:output_ext" + assert_equal "/:collection/:path:output_ext", @collection.url_template end should "contain no docs when initialized" do @@ -39,7 +39,7 @@ class TestCollections < JekyllUnitTest end should "know its relative directory" do - assert_equal @collection.relative_directory, "_methods" + assert_equal "_methods", @collection.relative_directory end should "know the full path to itself on the filesystem" do @@ -48,15 +48,15 @@ class TestCollections < JekyllUnitTest context "when turned into Liquid" do should "have a label attribute" do - assert_equal @collection.to_liquid["label"], "methods" + assert_equal "methods", @collection.to_liquid["label"] end should "have a docs attribute" do - assert_equal @collection.to_liquid["docs"], [] + assert_equal [], @collection.to_liquid["docs"] end should "have a files attribute" do - assert_equal @collection.to_liquid["files"], [] + assert_equal [], @collection.to_liquid["files"] end should "have a directory attribute" do @@ -64,18 +64,18 @@ class TestCollections < JekyllUnitTest end should "have a relative_directory attribute" do - assert_equal @collection.to_liquid["relative_directory"], "_methods" + assert_equal "_methods", @collection.to_liquid["relative_directory"] end should "have a output attribute" do - assert_equal @collection.to_liquid["output"], false + assert_equal false, @collection.to_liquid["output"] end end should "know whether it should be written or not" do - assert_equal @collection.write?, false + assert_equal false, @collection.write? @collection.metadata["output"] = true - assert_equal @collection.write?, true + assert_equal true, @collection.write? @collection.metadata.delete "output" end end @@ -107,7 +107,7 @@ class TestCollections < JekyllUnitTest end should "have custom URL template" do - assert_equal @collection.url_template, "/awesome/:path/" + assert_equal "/awesome/:path/", @collection.url_template end end @@ -174,7 +174,8 @@ class TestCollections < JekyllUnitTest end should "extract the configuration collection information as metadata" do - assert_equal @collection.metadata, "foo" => "bar", "baz" => "whoo" + expected = { "foo" => "bar", "baz" => "whoo" } + assert_equal expected, @collection.metadata end end diff --git a/test/test_commands_serve.rb b/test/test_commands_serve.rb index b589de2f37a..2970efb614f 100644 --- a/test/test_commands_serve.rb +++ b/test/test_commands_serve.rb @@ -154,9 +154,7 @@ def serve(opts) end should "label itself" do - assert_equal( - @merc.name, :serve - ) + assert_equal :serve, @merc.name end should "have aliases" do @@ -269,11 +267,11 @@ def serve(opts) context "verbose" do should "debug when verbose" do - assert_equal custom_opts("verbose" => true)[:Logger].level, 5 + assert_equal 5, custom_opts("verbose" => true)[:Logger].level end should "warn when not verbose" do - assert_equal custom_opts({})[:Logger].level, 3 + assert_equal 3, custom_opts({})[:Logger].level end end @@ -305,8 +303,8 @@ def serve(opts) ) assert result[:SSLEnable] - assert_equal result[:SSLPrivateKey], "c2" - assert_equal result[:SSLCertificate], "c1" + assert_equal "c2", result[:SSLPrivateKey] + assert_equal "c1", result[:SSLCertificate] end end end diff --git a/test/test_configuration.rb b/test/test_configuration.rb index 3f19949a846..d90d970a63e 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -17,7 +17,7 @@ class TestConfiguration < JekyllUnitTest should "merge input over defaults" do result = Configuration.from("source" => "blah") refute_equal result["source"], Configuration::DEFAULTS["source"] - assert_equal result["source"], "blah" + assert_equal "blah", result["source"] end should "return a valid Configuration instance" do @@ -26,13 +26,11 @@ class TestConfiguration < JekyllUnitTest should "add default collections" do result = Configuration.from({}) - assert_equal( - result["collections"], - "posts" => { - "output" => true, - "permalink" => "/:categories/:year/:month/:day/:title:output_ext", - } - ) + expected = { "posts" => { + "output" => true, + "permalink" => "/:categories/:year/:month/:day/:title:output_ext", + }, } + assert_equal expected, result["collections"] end should "NOT backwards-compatibilize" do @@ -68,32 +66,29 @@ class TestConfiguration < JekyllUnitTest should "turn an array into a hash" do result = Configuration[{ "collections" => %w(methods) }].add_default_collections assert_instance_of Hash, result["collections"] - assert_equal( - result["collections"], - "posts" => { "output" => true }, "methods" => {} - ) + expected = { "posts" => { "output" => true }, "methods" => {} } + assert_equal expected, result["collections"] end should "only assign collections.posts.permalink if a permalink is specified" do result = Configuration[{ "permalink" => "pretty", "collections" => {} }] .add_default_collections - assert_equal( - result["collections"], - "posts" => { - "output" => true, - "permalink" => "/:categories/:year/:month/:day/:title/", - } - ) + expected = { "posts" => { + "output" => true, + "permalink" => "/:categories/:year/:month/:day/:title/", + }, } + assert_equal expected, result["collections"] result = Configuration[{ "permalink" => nil, "collections" => {} }] .add_default_collections - assert_equal result["collections"], "posts" => { "output" => true } + expected = { "posts" => { "output" => true } } + assert_equal expected, result["collections"] end should "forces posts to output" do result = Configuration[{ "collections" => { "posts" => { "output" => false } } }] .add_default_collections - assert_equal result["collections"]["posts"]["output"], true + assert_equal true, result["collections"]["posts"]["output"] end end @@ -216,23 +211,19 @@ class TestConfiguration < JekyllUnitTest should "transform string exclude into an array" do assert @config.key?("exclude") assert @config.backwards_compatibilize.key?("exclude") - assert_equal( - @config.backwards_compatibilize["exclude"], - %w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown) - ) + expected = %w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown) + assert_equal expected, @config.backwards_compatibilize["exclude"] end should "transform string include into an array" do assert @config.key?("include") assert @config.backwards_compatibilize.key?("include") - assert_equal( - @config.backwards_compatibilize["include"], - %w(STOP_THE_PRESSES.txt .heloses .git) - ) + expected = %w(STOP_THE_PRESSES.txt .heloses .git) + assert_equal expected, @config.backwards_compatibilize["include"] end should "set highlighter to pygments" do assert @config.key?("pygments") assert !@config.backwards_compatibilize.key?("pygments") - assert_equal @config.backwards_compatibilize["highlighter"], "pygments" + assert_equal "pygments", @config.backwards_compatibilize["highlighter"] end should "adjust directory names" do assert @config.key?("layouts") @@ -500,12 +491,13 @@ class TestConfiguration < JekyllUnitTest ) ) assert_equal( - config["folded_string"], - "This string of text will ignore newlines till the next key.\n" + "This string of text will ignore newlines till the next key.\n", + config["folded_string"] ) + assert_equal( - config["clean_folded_string"], - "This string of text will ignore newlines till the next key." + "This string of text will ignore newlines till the next key.", + config["clean_folded_string"] ) end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index d95955f4d6b..94d6a4df5e5 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -155,7 +155,7 @@ class TestKramdown < JekyllUnitTest ) expect(Kramdown::Document).to receive(:new) do |arg1, hash| - assert_equal hash["syntax_highlighter_opts"]["hello"], "world" + assert_equal "world", hash["syntax_highlighter_opts"]["hello"] original.call(arg1, hash) end diff --git a/test/test_liquid_extensions.rb b/test/test_liquid_extensions.rb index 30637b33315..5886d80d17a 100644 --- a/test/test_liquid_extensions.rb +++ b/test/test_liquid_extensions.rb @@ -22,11 +22,11 @@ def render(context) end should "extract the var properly" do - assert_equal @template.render("page" => { "name" => "tobi" }), "hi tobi" + assert_equal "hi tobi", @template.render("page" => { "name" => "tobi" }) end should "return the variable name if the value isn't there" do - assert_equal @template.render("page" => { "title" => "tobi" }), "hi page.name" + assert_equal "hi page.name", @template.render("page" => { "title" => "tobi" }) end end end diff --git a/test/test_regenerator.rb b/test/test_regenerator.rb index 122bc40f440..39b28baa4e7 100644 --- a/test/test_regenerator.rb +++ b/test/test_regenerator.rb @@ -153,7 +153,8 @@ class TestRegenerator < JekyllUnitTest assert @regenerator.cache[@path] @regenerator.clear_cache - assert_equal @regenerator.cache, {} + expected = {} + assert_equal expected, @regenerator.cache end should "write to the metadata file" do From e49f507e4fcd5d71c8e79f70b931fb72c3416872 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 15 Jul 2018 16:11:46 -0400 Subject: [PATCH 324/337] Update history to reflect merge of #7134 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 47d54f03b08..8fdf79b5176 100644 --- a/History.markdown +++ b/History.markdown @@ -72,6 +72,7 @@ * Example of CircleCI deployment through CircleCI v2 (#7024) * Fix Rubocop offences in test files (#7128) * fix up refute_equal call (#7133) + * Fix incorrectly passed arguments to assert_equal (#7134) ### Bug Fixes From b2c6d03b47979a7e058d4ffd824948e4a2a8f7c8 Mon Sep 17 00:00:00 2001 From: 104fps <36814947+104fps@users.noreply.github.com> Date: Mon, 16 Jul 2018 01:18:43 +0300 Subject: [PATCH 325/337] Update docs about post creation (#7138) Merge pull request 7138 --- .../_posts/0000-00-00-welcome-to-jekyll.markdown.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb b/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb index 8d8f7c162bd..187a4d9b048 100644 --- a/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +++ b/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb @@ -6,7 +6,11 @@ categories: jekyll update --- You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. -To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works. +Jekyll requires blog post files to be named according to the following format: + +`YEAR-MONTH-DAY-title.MARKUP` + +Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works. Jekyll also offers powerful support for code snippets: From 34a1b7aeefca27d0100437d84c9564433bfd5430 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Sun, 15 Jul 2018 18:18:44 -0400 Subject: [PATCH 326/337] Update history to reflect merge of #7138 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 8fdf79b5176..939e2a56206 100644 --- a/History.markdown +++ b/History.markdown @@ -34,6 +34,7 @@ * add jekyll-xml-source (#7114) * Add the jekyll-firstimage filter plugin (#7127) * Use a real theme in the example (#7125) + * Update docs about post creation (#7138) ### Minor Enhancements From af78a1a5682dd116b00d7cba60f4ac343faf0b72 Mon Sep 17 00:00:00 2001 From: Belhassen Chelbi Date: Mon, 16 Jul 2018 03:17:22 +0100 Subject: [PATCH 327/337] Add DEV Community's Jekyll tag to community page --- docs/help/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/help/index.md b/docs/help/index.md index abc7ea2adba..4d0c126b44c 100644 --- a/docs/help/index.md +++ b/docs/help/index.md @@ -43,6 +43,10 @@ Known breaking changes are listed in the upgrading docs. Watch videos from members of the Jekyll community speak about interesting use cases, tricks they've learned or meta Jekyll topics. +### The Dev community + +[DEV’s jekyll tag](https://dev.to/t/jekyll) is a place to share Jekyll projects, articles and tutorials as well as start discussions and ask for feedback on Jekyll-related topics. Developers of all skill-levels are welcome to take part. + ### [Google](https://www.google.com/?q=jekyll) Add **jekyll** to almost any query, and you'll find just what you need. From ca2766c2a146bec5393cc12b0a52340b66829c23 Mon Sep 17 00:00:00 2001 From: Belhassen Chelbi Date: Mon, 16 Jul 2018 14:58:26 +0100 Subject: [PATCH 328/337] Add DEV Community's Jekyll tag to community page (#7139) Merge pull request 7139 --- docs/help/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/help/index.md b/docs/help/index.md index abc7ea2adba..4d0c126b44c 100644 --- a/docs/help/index.md +++ b/docs/help/index.md @@ -43,6 +43,10 @@ Known breaking changes are listed in the upgrading docs. Watch videos from members of the Jekyll community speak about interesting use cases, tricks they've learned or meta Jekyll topics. +### The Dev community + +[DEV’s jekyll tag](https://dev.to/t/jekyll) is a place to share Jekyll projects, articles and tutorials as well as start discussions and ask for feedback on Jekyll-related topics. Developers of all skill-levels are welcome to take part. + ### [Google](https://www.google.com/?q=jekyll) Add **jekyll** to almost any query, and you'll find just what you need. From 707e48a41272796378f094d5e33612b023c45c9d Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 16 Jul 2018 09:58:28 -0400 Subject: [PATCH 329/337] Update history to reflect merge of #7139 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index 939e2a56206..c2277cee65f 100644 --- a/History.markdown +++ b/History.markdown @@ -35,6 +35,7 @@ * Add the jekyll-firstimage filter plugin (#7127) * Use a real theme in the example (#7125) * Update docs about post creation (#7138) + * Add DEV Community's Jekyll tag to community page (#7139) ### Minor Enhancements From 6802ec93eb9c6f25489b6c734966ec4099ed9eaa Mon Sep 17 00:00:00 2001 From: Belhassen Chelbi Date: Mon, 16 Jul 2018 15:13:26 +0100 Subject: [PATCH 330/337] Add Dev.to website link --- docs/help/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/help/index.md b/docs/help/index.md index 4d0c126b44c..45492aaac3c 100644 --- a/docs/help/index.md +++ b/docs/help/index.md @@ -43,7 +43,7 @@ Known breaking changes are listed in the upgrading docs. Watch videos from members of the Jekyll community speak about interesting use cases, tricks they've learned or meta Jekyll topics. -### The Dev community +### [The Dev community](https://dev.to/) [DEV’s jekyll tag](https://dev.to/t/jekyll) is a place to share Jekyll projects, articles and tutorials as well as start discussions and ask for feedback on Jekyll-related topics. Developers of all skill-levels are welcome to take part. From 50e0379444f3b0906d6697934d1c7c49946f666b Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Tue, 17 Jul 2018 00:34:20 +0530 Subject: [PATCH 331/337] Initialize upgrading doc for v4.0 (#7140) Merge pull request 7140 --- docs/_docs/upgrading/3-to-4.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs/_docs/upgrading/3-to-4.md diff --git a/docs/_docs/upgrading/3-to-4.md b/docs/_docs/upgrading/3-to-4.md new file mode 100644 index 00000000000..8bd1fde1ae3 --- /dev/null +++ b/docs/_docs/upgrading/3-to-4.md @@ -0,0 +1,28 @@ +--- +title: Upgrading from 3.x to 4.x +permalink: /docs/upgrading/3-to-4/ +--- + +Upgrading from an older version of Jekyll? A few things have changed in Jekyll 4 +that you'll want to know about. + +Before we dive in, you need to have at least Ruby 2.3.0 installed. Run the following +in your terminal to check + +```sh +ruby -v +``` + +If you're using Ruby >= 2.3.0, go ahead and fetch the latest version of Jekyll: + +```sh +gem update jekyll +``` + +--- + + *Insert sections here* + +--- + +*Did we miss something? Please click "Improve this page" above and add a section. Thanks!* From ad9fbeb4b1d64b267f19955f50b32da89b5c6ebd Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Mon, 16 Jul 2018 15:04:22 -0400 Subject: [PATCH 332/337] Update history to reflect merge of #7140 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index c2277cee65f..efd8a7d0982 100644 --- a/History.markdown +++ b/History.markdown @@ -36,6 +36,7 @@ * Use a real theme in the example (#7125) * Update docs about post creation (#7138) * Add DEV Community's Jekyll tag to community page (#7139) + * Initialize upgrading doc for v4.0 (#7140) ### Minor Enhancements From e61cc513e96aca4d7955c687bf4119fd6e5d5f57 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Tue, 17 Jul 2018 20:12:10 +0530 Subject: [PATCH 333/337] Lock Travis to Bundler-1.16.2 (#7144) Merge pull request 7144 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2aa960d612d..b8277623c02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,4 +52,4 @@ after_success: before_install: - gem update --system - - gem install bundler + - gem install bundler --version 1.16.2 From 02a2f9460ad654e4e098402d47fb81407a2223a2 Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Tue, 17 Jul 2018 10:42:12 -0400 Subject: [PATCH 334/337] Update history to reflect merge of #7144 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index efd8a7d0982..bce05b63c08 100644 --- a/History.markdown +++ b/History.markdown @@ -76,6 +76,7 @@ * Fix Rubocop offences in test files (#7128) * fix up refute_equal call (#7133) * Fix incorrectly passed arguments to assert_equal (#7134) + * Lock Travis to Bundler-1.16.2 (#7144) ### Bug Fixes From 5701087e7b2b61dbea84b3782ca55195e348c5d4 Mon Sep 17 00:00:00 2001 From: Ken Salomon Date: Fri, 20 Jul 2018 19:22:44 -0400 Subject: [PATCH 335/337] Do not process Liquid in post excerpt when disabled in front matter (#7146) Merge pull request 7146 --- features/post_excerpts.feature | 18 ++++++++++++++++++ lib/jekyll/excerpt.rb | 1 + 2 files changed, 19 insertions(+) diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature index 6267fdc6572..38de73528c6 100644 --- a/features/post_excerpts.feature +++ b/features/post_excerpts.feature @@ -70,3 +70,21 @@ Feature: Post excerpts And the "_site/2007/12/31/entry1.html" file should exist And I should see "

content for entry1.

" in "_site/index.html" And I should see "

content for entry1.

\n" in "_site/2007/12/31/entry1.html" + + Scenario: Excerpts from posts having 'render_with_liquid' in their front matter + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have a _layouts directory + And I have a post layout that contains "{{ page.excerpt }}" + And I have the following posts: + | title | layout | render_with_liquid | date | content | + | Unrendered Post | post | false | 2017-07-06 | Liquid is not rendered at {{ page.url }} | + | Rendered Post | post | true | 2017-07-06 | Liquid is rendered at {{ page.url }} | + When I run jekyll build + Then I should get a zero exit status + And the _site/2017/07/06 directory should exist + And the "_site/2017/07/06/unrendered-post.html" file should exist + And the "_site/2017/07/06/rendered-post.html" file should exist + And I should see "Liquid is not rendered at {{ page.url }}" in "_site/2017/07/06/unrendered-post.html" + But I should see "

Liquid is rendered at /2017/07/06/rendered-post.html

" in "_site/2017/07/06/rendered-post.html" + And I should see "

Liquid is not rendered at {{ page.url }}

\n

Liquid is rendered at /2017/07/06/rendered-post.html

" in "_site/index.html" diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 6f4ac3d8ed0..8eea0e2edc0 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -89,6 +89,7 @@ def place_in_layout? end def render_with_liquid? + return false if data["render_with_liquid"] == false !(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content)) end From fe0a6caa7fd7f0414fff6be5c470633fe789449d Mon Sep 17 00:00:00 2001 From: jekyllbot Date: Fri, 20 Jul 2018 19:22:46 -0400 Subject: [PATCH 336/337] Update history to reflect merge of #7146 [ci skip] --- History.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/History.markdown b/History.markdown index bce05b63c08..3eb521eb83e 100644 --- a/History.markdown +++ b/History.markdown @@ -85,6 +85,7 @@ ### feature * Disable Liquid via front matter (#6824) + * Do not process Liquid in post excerpt when disabled in front matter (#7146) ## 3.8.3 / 2018-06-05 From ef41eeb7d457dd26b5516937582264f47782875f Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 23 Jul 2018 12:57:56 -0500 Subject: [PATCH 337/337] Name some of our Travis builds --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b8277623c02..d1c4f739a0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,10 @@ matrix: include: - rvm: *ruby1 env: TEST_SUITE=fmt + name: "🤖️ Code Format" - rvm: *ruby1 env: TEST_SUITE=default-site + name: "🏠️ Default Site" exclude: - rvm: *jruby env: TEST_SUITE=cucumber