diff --git a/Gemfile b/Gemfile
index 5f502f1a39a8..5afdc65f7ea1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,29 +1,23 @@
source "https://rubygems.org"
-ruby "> 2.3.0"
+ruby "> 2.5.0"
group :development do
- gem 'rake', '~> 10.0'
- # 3.8.5 throws errors on unfinished liquid tags in excerpts
- # Wait with upgrade until release https://github.com/jekyll/jekyll/pull/7382
- gem 'jekyll', '3.8.4'
- gem 'compass', '~> 0.12'
- gem 'sass-globbing', '~> 1.0'
- gem 'stringex', '~> 1.4'
- gem 'pry'
-
- # See https://github.com/home-assistant/home-assistant.github.io/pull/3904
- gem 'rb-inotify', '< 0.9.9'
+ gem 'rake', '12.3.2'
+ gem 'jekyll', '3.8.6'
+ gem 'compass', '1.0.3'
+ gem 'sass-globbing', '1.1.5'
+ gem 'stringex', '2.8.5'
end
group :jekyll_plugins do
- gem 'jekyll-paginate'
- gem 'jekyll-redirect-from'
- gem 'jekyll-sitemap'
- gem 'jekyll-time-to-read'
- gem 'octopress', '~> 3.0'
- gem 'octopress-include-tag'
+ gem 'jekyll-paginate', '1.1.0'
+ gem 'jekyll-redirect-from', '0.15.0'
+ gem 'jekyll-sitemap', '1.3.1'
+ gem 'jekyll-time-to-read', '0.1.2'
+ gem 'octopress', '3.0.11'
+ gem 'octopress-include-tag', '1.1.3'
end
-gem 'sinatra', '~> 1.4.2'
-gem 'nokogiri'
+gem 'sinatra', '2.0.5'
+gem 'nokogiri', '1.10.3'
diff --git a/Gemfile.lock b/Gemfile.lock
index c79660b6aa11..d3421bd8a47f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,27 +1,33 @@
GEM
remote: https://rubygems.org/
specs:
- addressable (2.5.2)
+ addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
- chunky_png (1.3.8)
- coderay (1.1.1)
+ chunky_png (1.3.11)
colorator (1.1.0)
- compass (0.12.7)
+ compass (1.0.3)
chunky_png (~> 1.2)
- fssm (>= 0.2.7)
- sass (~> 3.2.19)
- concurrent-ruby (1.1.3)
+ compass-core (~> 1.0.2)
+ compass-import-once (~> 1.0.5)
+ rb-fsevent (>= 0.9.3)
+ rb-inotify (>= 0.9)
+ sass (>= 3.3.13, < 3.5)
+ compass-core (1.0.3)
+ multi_json (~> 1.0)
+ sass (>= 3.3.0, < 3.5)
+ compass-import-once (1.0.5)
+ sass (>= 3.2, < 3.5)
+ concurrent-ruby (1.1.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.2.7)
- ffi (1.9.25)
+ ffi (1.11.1)
forwardable-extended (2.6.0)
- fssm (0.2.10)
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
- jekyll (3.8.4)
+ jekyll (3.8.6)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
@@ -35,26 +41,27 @@ GEM
rouge (>= 1.7, < 4)
safe_yaml (~> 1.0)
jekyll-paginate (1.1.0)
- jekyll-redirect-from (0.12.1)
- jekyll (~> 3.3)
- jekyll-sass-converter (1.3.0)
- sass (~> 3.2)
- jekyll-sitemap (1.1.1)
- jekyll (~> 3.3)
+ jekyll-redirect-from (0.15.0)
+ jekyll (>= 3.3, < 5.0)
+ jekyll-sass-converter (1.5.2)
+ sass (~> 3.4)
+ jekyll-sitemap (1.3.1)
+ jekyll (>= 3.7, < 5.0)
jekyll-time-to-read (0.1.2)
jekyll
- jekyll-watch (2.1.2)
+ jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (1.17.0)
- liquid (4.0.1)
+ liquid (4.0.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
mercenary (0.3.6)
- method_source (0.8.2)
mini_portile2 (2.4.0)
- nokogiri (1.10.1)
+ multi_json (1.13.1)
+ mustermann (1.0.3)
+ nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
octopress (3.0.11)
jekyll (>= 2.0)
@@ -73,57 +80,51 @@ GEM
octopress-include-tag (1.1.3)
jekyll (>= 2.0)
octopress-tag-helpers (~> 1.0)
- octopress-tag-helpers (1.0.8)
+ octopress-tag-helpers (1.0.9)
jekyll (>= 2.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
- pry (0.10.4)
- coderay (~> 1.1.0)
- method_source (~> 0.8.1)
- slop (~> 3.4)
- public_suffix (3.0.3)
- rack (1.6.9)
- rack-protection (1.5.5)
+ public_suffix (3.1.1)
+ rack (2.0.7)
+ rack-protection (2.0.5)
rack
- rake (10.5.0)
+ rake (12.3.2)
rb-fsevent (0.10.3)
- rb-inotify (0.9.8)
- ffi (>= 0.5.0)
+ rb-inotify (0.10.0)
+ ffi (~> 1.0)
redcarpet (3.4.0)
- rouge (3.3.0)
+ rouge (3.5.1)
ruby_dep (1.5.0)
- safe_yaml (1.0.4)
- sass (3.2.19)
+ safe_yaml (1.0.5)
+ sass (3.4.25)
sass-globbing (1.1.5)
sass (>= 3.1)
- sinatra (1.4.8)
- rack (~> 1.5)
- rack-protection (~> 1.4)
- tilt (>= 1.3, < 3)
- slop (3.6.0)
- stringex (1.5.1)
- tilt (2.0.8)
+ sinatra (2.0.5)
+ mustermann (~> 1.0)
+ rack (~> 2.0)
+ rack-protection (= 2.0.5)
+ tilt (~> 2.0)
+ stringex (2.8.5)
+ tilt (2.0.9)
titlecase (0.1.1)
PLATFORMS
ruby
DEPENDENCIES
- compass (~> 0.12)
- jekyll (= 3.8.4)
- jekyll-paginate
- jekyll-redirect-from
- jekyll-sitemap
- jekyll-time-to-read
- nokogiri
- octopress (~> 3.0)
- octopress-include-tag
- pry
- rake (~> 10.0)
- rb-inotify (< 0.9.9)
- sass-globbing (~> 1.0)
- sinatra (~> 1.4.2)
- stringex (~> 1.4)
+ compass (= 1.0.3)
+ jekyll (= 3.8.6)
+ jekyll-paginate (= 1.1.0)
+ jekyll-redirect-from (= 0.15.0)
+ jekyll-sitemap (= 1.3.1)
+ jekyll-time-to-read (= 0.1.2)
+ nokogiri (= 1.10.3)
+ octopress (= 3.0.11)
+ octopress-include-tag (= 1.1.3)
+ rake (= 12.3.2)
+ sass-globbing (= 1.1.5)
+ sinatra (= 2.0.5)
+ stringex (= 2.8.5)
RUBY VERSION
ruby 2.6.2p47
diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb
index c55d62f41c1a..54210c7a740e 100644
--- a/plugins/category_generator.rb
+++ b/plugins/category_generator.rb
@@ -3,13 +3,46 @@
# Jekyll category page generator.
# http://recursive-design.com/projects/jekyll-plugins/
#
-# Version: 0.1.4 (201101061053)
+# Version: 0.2.4 (201210160037)
#
# Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
#
# A generator that creates category pages for jekyll sites.
#
+# To use it, simply drop this script into the _plugins directory of your Jekyll site. You should
+# also create a file called 'category_index.html' in the _layouts directory of your jekyll site
+# with the following contents (note: you should remove the leading '# ' characters):
+#
+# ================================== COPY BELOW THIS LINE ==================================
+# ---
+# layout: default
+# ---
+#
+#
{{ page.title }}
+#
+# {% for post in site.categories[page.category] %}
+# {{ post.date | date_to_html_string }}
+#
+# Filed under {{ post.categories | category_links }}
+# {% endfor %}
+#
+# ================================== COPY ABOVE THIS LINE ==================================
+#
+# You can alter the _layout_ setting if you wish to use an alternate layout, and obviously you
+# can change the HTML above as you see fit.
+#
+# When you compile your jekyll site, this plugin will loop through the list of categories in your
+# site, and use the layout above to generate a page for each one with a list of links to the
+# individual posts.
+#
+# You can also (optionally) generate an atom.xml feed for each category. To do this, copy
+# the category_feed.xml file to the _includes/custom directory of your own project
+# (https://github.com/recurser/jekyll-plugins/blob/master/_includes/custom/category_feed.xml).
+# You'll also need to copy the octopress_filters.rb file into the _plugins directory of your
+# project as the category_feed.xml requires a couple of extra filters
+# (https://github.com/recurser/jekyll-plugins/blob/master/_plugins/octopress_filters.rb).
+#
# Included filters :
# - category_links: Outputs the list of categories as comma-separated links.
# - date_to_html_string: Outputs the post.date as formatted html, with hooks for CSS styling.
@@ -18,64 +51,81 @@
# - category_dir: The subfolder to build category pages in (default is 'categories').
# - category_title_prefix: The string used before the category name in the page title (default is
# 'Category: ').
+module Jekyll
-require 'stringex'
+ # The CategoryIndex class creates a single category page for the specified category.
+ class CategoryPage < Page
-module Jekyll
+ # Initializes a new CategoryIndex.
+ #
+ # +template_path+ is the path to the layout template to use.
+ # +site+ is the Jekyll Site instance.
+ # +base+ is the String path to the .
+ # +category_dir+ is the String path between and the category folder.
+ # +category+ is the category currently being processed.
+ def initialize(template_path, name, site, base, category_dir, category)
+ @site = site
+ @base = base
+ @dir = category_dir
+ @name = name
+
+ self.process(name)
+
+ if File.exist?(template_path)
+ @perform_render = true
+ template_dir = File.dirname(template_path)
+ template = File.basename(template_path)
+ # Read the YAML data from the layout page.
+ self.read_yaml(template_dir, template)
+ self.data['category'] = category
+ # Set the title for this page.
+ title_prefix = site.config['category_title_prefix'] || 'Category: '
+ self.data['title'] = "#{title_prefix}#{category}"
+ # Set the meta-description for this page.
+ meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: '
+ self.data['description'] = "#{meta_description_prefix}#{category}"
+ else
+ @perform_render = false
+ end
+ end
+
+ def render?
+ @perform_render
+ end
+
+ end
# The CategoryIndex class creates a single category page for the specified category.
- class CategoryIndex < Page
+ class CategoryIndex < CategoryPage
# Initializes a new CategoryIndex.
#
+ # +site+ is the Jekyll Site instance.
# +base+ is the String path to the .
# +category_dir+ is the String path between and the category folder.
# +category+ is the category currently being processed.
def initialize(site, base, category_dir, category)
- @site = site
- @base = base
- @dir = category_dir
- @name = 'index.html'
- self.process(@name)
- # Read the YAML data from the layout page.
- self.read_yaml(File.join(base, '_layouts'), 'category_index.html')
- self.data['category'] = category
- # Set the title for this page.
- title_prefix = site.config['category_title_prefix'] || 'Category: '
- self.data['title'] = "#{title_prefix}#{category}"
- # Set the meta-description for this page.
- meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: '
- self.data['description'] = "#{meta_description_prefix}#{category}"
+ template_path = File.join(base, '_layouts', 'category_index.html')
+ super(template_path, 'index.html', site, base, category_dir, category)
end
end
# The CategoryFeed class creates an Atom feed for the specified category.
- class CategoryFeed < Page
+ class CategoryFeed < CategoryPage
# Initializes a new CategoryFeed.
#
+ # +site+ is the Jekyll Site instance.
# +base+ is the String path to the .
# +category_dir+ is the String path between and the category folder.
# +category+ is the category currently being processed.
def initialize(site, base, category_dir, category)
- @site = site
- @base = base
- @dir = category_dir
- @name = 'atom.xml'
- self.process(@name)
- # Read the YAML data from the layout page.
- self.read_yaml(File.join(base, '_includes/custom'), 'category_feed.xml')
- self.data['category'] = category
- # Set the title for this page.
- title_prefix = site.config['category_title_prefix'] || 'Category: '
- self.data['title'] = "#{title_prefix}#{category}"
- # Set the meta-description for this page.
- meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: '
- self.data['description'] = "#{meta_description_prefix}#{category}"
+ template_path = File.join(base, '_includes', 'custom', 'category_feed.xml')
+ super(template_path, 'atom.xml', site, base, category_dir, category)
# Set the correct feed URL.
- self.data['feed_url'] = "#{category_dir}/#{name}"
+ self.data['feed_url'] = "#{category_dir}/#{name}" if render?
end
end
@@ -86,44 +136,37 @@ class Site
# Creates an instance of CategoryIndex for each category page, renders it, and
# writes the output to a file.
#
- # +category_dir+ is the String path to the category folder.
- # +category+ is the category currently being processed.
- def write_category_index(category_dir, category)
- index = CategoryIndex.new(self, self.source, category_dir, category)
- index.render(self.layouts, site_payload)
- index.write(self.dest)
- # Record the fact that this page has been added, otherwise Site::cleanup will remove it.
- self.pages << index
+ # +category+ is the category currently being processed.
+ def write_category_index(category)
+ target_dir = GenerateCategories.category_dir(self.config['category_dir'], category)
+ index = CategoryIndex.new(self, self.source, target_dir, category)
+ if index.render?
+ index.render(self.layouts, site_payload)
+ index.write(self.dest)
+ # Record the fact that this pages has been added, otherwise Site::cleanup will remove it.
+ self.pages << index
+ end
# Create an Atom-feed for each index.
- feed = CategoryFeed.new(self, self.source, category_dir, category)
- feed.render(self.layouts, site_payload)
- feed.write(self.dest)
- # Record the fact that this page has been added, otherwise Site::cleanup will remove it.
- self.pages << feed
+ feed = CategoryFeed.new(self, self.source, target_dir, category)
+ if feed.render?
+ feed.render(self.layouts, site_payload)
+ feed.write(self.dest)
+ # Record the fact that this pages has been added, otherwise Site::cleanup will remove it.
+ self.pages << feed
+ end
end
# Loops through the list of category pages and processes each one.
def write_category_indexes
if self.layouts.key? 'category_index'
- dir = self.config['category_dir'] || 'categories'
self.categories.keys.each do |category|
- self.write_category_index(File.join(dir, category.to_url), category)
+ self.write_category_index(category)
end
# Throw an exception if the layout couldn't be found.
else
- raise <<-ERR
-
-
-===============================================
- Error for category_generator.rb plugin
------------------------------------------------
- No 'category_index.html' in source/_layouts/
- Perhaps you haven't installed a theme yet.
-===============================================
-
-ERR
+ throw "No 'category_index' layout found."
end
end
@@ -135,10 +178,20 @@ class GenerateCategories < Generator
safe true
priority :low
+ CATEGORY_DIR = 'categories'
+
def generate(site)
site.write_category_indexes
end
+ # Processes the given dir and removes leading and trailing slashes. Falls
+ # back on the default if no dir is provided.
+ def self.category_dir(base_dir, category)
+ base_dir = (base_dir || CATEGORY_DIR).gsub(/^\/*(.*)\/*$/, '\1')
+ category = category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase
+ File.join(base_dir, category)
+ end
+
end
@@ -151,9 +204,14 @@ module Filters
# +categories+ is the list of categories to format.
#
# Returns string
- #
def category_links(categories)
- categories = categories.sort!.map { |c| category_link c }
+ base_dir = @context.registers[:site].config['category_dir']
+ categories = categories.sort!.map do |category|
+ category_dir = GenerateCategories.category_dir(base_dir, category)
+ # Make sure the category directory begins with a slash.
+ category_dir = "/#{category_dir}" unless category_dir =~ /^\//
+ "#{category}"
+ end
case categories.length
when 0
@@ -161,7 +219,7 @@ def category_links(categories)
when 1
categories[0].to_s
else
- "#{categories[0...-1].join(', ')}, #{categories[-1]}"
+ categories.join(', ')
end
end
@@ -172,8 +230,9 @@ def category_links(categories)
# Returns string
#
def category_link(category)
- dir = @context.registers[:site].config['category_dir']
- "#{category}"
+ base_dir = @context.registers[:site].config['category_dir']
+ category_dir = GenerateCategories.category_dir(base_dir, category)
+ "#{category}"
end
# Outputs the post.date as formatted html, with hooks for CSS styling.