Ruby deps upgrades and cleanup (#9778)

This commit is contained in:
Franck Nijhof 2019-07-06 01:08:16 +02:00 committed by Paulus Schoutsen
parent 8faccaaaad
commit 56ec75238c
3 changed files with 196 additions and 142 deletions

34
Gemfile
View File

@ -1,29 +1,23 @@
source "https://rubygems.org" source "https://rubygems.org"
ruby "> 2.3.0" ruby "> 2.5.0"
group :development do group :development do
gem 'rake', '~> 10.0' gem 'rake', '12.3.2'
# 3.8.5 throws errors on unfinished liquid tags in excerpts gem 'jekyll', '3.8.6'
# Wait with upgrade until release https://github.com/jekyll/jekyll/pull/7382 gem 'compass', '1.0.3'
gem 'jekyll', '3.8.4' gem 'sass-globbing', '1.1.5'
gem 'compass', '~> 0.12' gem 'stringex', '2.8.5'
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'
end end
group :jekyll_plugins do group :jekyll_plugins do
gem 'jekyll-paginate' gem 'jekyll-paginate', '1.1.0'
gem 'jekyll-redirect-from' gem 'jekyll-redirect-from', '0.15.0'
gem 'jekyll-sitemap' gem 'jekyll-sitemap', '1.3.1'
gem 'jekyll-time-to-read' gem 'jekyll-time-to-read', '0.1.2'
gem 'octopress', '~> 3.0' gem 'octopress', '3.0.11'
gem 'octopress-include-tag' gem 'octopress-include-tag', '1.1.3'
end end
gem 'sinatra', '~> 1.4.2' gem 'sinatra', '2.0.5'
gem 'nokogiri' gem 'nokogiri', '1.10.3'

View File

@ -1,27 +1,33 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
addressable (2.5.2) addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
chunky_png (1.3.8) chunky_png (1.3.11)
coderay (1.1.1)
colorator (1.1.0) colorator (1.1.0)
compass (0.12.7) compass (1.0.3)
chunky_png (~> 1.2) chunky_png (~> 1.2)
fssm (>= 0.2.7) compass-core (~> 1.0.2)
sass (~> 3.2.19) compass-import-once (~> 1.0.5)
concurrent-ruby (1.1.3) 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) em-websocket (0.5.1)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
eventmachine (1.2.7) eventmachine (1.2.7)
ffi (1.9.25) ffi (1.11.1)
forwardable-extended (2.6.0) forwardable-extended (2.6.0)
fssm (0.2.10)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
i18n (0.9.5) i18n (0.9.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jekyll (3.8.4) jekyll (3.8.6)
addressable (~> 2.4) addressable (~> 2.4)
colorator (~> 1.0) colorator (~> 1.0)
em-websocket (~> 0.5) em-websocket (~> 0.5)
@ -35,26 +41,27 @@ GEM
rouge (>= 1.7, < 4) rouge (>= 1.7, < 4)
safe_yaml (~> 1.0) safe_yaml (~> 1.0)
jekyll-paginate (1.1.0) jekyll-paginate (1.1.0)
jekyll-redirect-from (0.12.1) jekyll-redirect-from (0.15.0)
jekyll (~> 3.3) jekyll (>= 3.3, < 5.0)
jekyll-sass-converter (1.3.0) jekyll-sass-converter (1.5.2)
sass (~> 3.2) sass (~> 3.4)
jekyll-sitemap (1.1.1) jekyll-sitemap (1.3.1)
jekyll (~> 3.3) jekyll (>= 3.7, < 5.0)
jekyll-time-to-read (0.1.2) jekyll-time-to-read (0.1.2)
jekyll jekyll
jekyll-watch (2.1.2) jekyll-watch (2.2.1)
listen (~> 3.0) listen (~> 3.0)
kramdown (1.17.0) kramdown (1.17.0)
liquid (4.0.1) liquid (4.0.3)
listen (3.1.5) listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2) ruby_dep (~> 1.2)
mercenary (0.3.6) mercenary (0.3.6)
method_source (0.8.2)
mini_portile2 (2.4.0) 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) mini_portile2 (~> 2.4.0)
octopress (3.0.11) octopress (3.0.11)
jekyll (>= 2.0) jekyll (>= 2.0)
@ -73,57 +80,51 @@ GEM
octopress-include-tag (1.1.3) octopress-include-tag (1.1.3)
jekyll (>= 2.0) jekyll (>= 2.0)
octopress-tag-helpers (~> 1.0) octopress-tag-helpers (~> 1.0)
octopress-tag-helpers (1.0.8) octopress-tag-helpers (1.0.9)
jekyll (>= 2.0) jekyll (>= 2.0)
pathutil (0.16.2) pathutil (0.16.2)
forwardable-extended (~> 2.6) forwardable-extended (~> 2.6)
pry (0.10.4) public_suffix (3.1.1)
coderay (~> 1.1.0) rack (2.0.7)
method_source (~> 0.8.1) rack-protection (2.0.5)
slop (~> 3.4)
public_suffix (3.0.3)
rack (1.6.9)
rack-protection (1.5.5)
rack rack
rake (10.5.0) rake (12.3.2)
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
rb-inotify (0.9.8) rb-inotify (0.10.0)
ffi (>= 0.5.0) ffi (~> 1.0)
redcarpet (3.4.0) redcarpet (3.4.0)
rouge (3.3.0) rouge (3.5.1)
ruby_dep (1.5.0) ruby_dep (1.5.0)
safe_yaml (1.0.4) safe_yaml (1.0.5)
sass (3.2.19) sass (3.4.25)
sass-globbing (1.1.5) sass-globbing (1.1.5)
sass (>= 3.1) sass (>= 3.1)
sinatra (1.4.8) sinatra (2.0.5)
rack (~> 1.5) mustermann (~> 1.0)
rack-protection (~> 1.4) rack (~> 2.0)
tilt (>= 1.3, < 3) rack-protection (= 2.0.5)
slop (3.6.0) tilt (~> 2.0)
stringex (1.5.1) stringex (2.8.5)
tilt (2.0.8) tilt (2.0.9)
titlecase (0.1.1) titlecase (0.1.1)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
compass (~> 0.12) compass (= 1.0.3)
jekyll (= 3.8.4) jekyll (= 3.8.6)
jekyll-paginate jekyll-paginate (= 1.1.0)
jekyll-redirect-from jekyll-redirect-from (= 0.15.0)
jekyll-sitemap jekyll-sitemap (= 1.3.1)
jekyll-time-to-read jekyll-time-to-read (= 0.1.2)
nokogiri nokogiri (= 1.10.3)
octopress (~> 3.0) octopress (= 3.0.11)
octopress-include-tag octopress-include-tag (= 1.1.3)
pry rake (= 12.3.2)
rake (~> 10.0) sass-globbing (= 1.1.5)
rb-inotify (< 0.9.9) sinatra (= 2.0.5)
sass-globbing (~> 1.0) stringex (= 2.8.5)
sinatra (~> 1.4.2)
stringex (~> 1.4)
RUBY VERSION RUBY VERSION
ruby 2.6.2p47 ruby 2.6.2p47

View File

@ -3,13 +3,46 @@
# Jekyll category page generator. # Jekyll category page generator.
# http://recursive-design.com/projects/jekyll-plugins/ # 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/ # Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) # Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
# #
# A generator that creates category pages for jekyll sites. # 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
# ---
#
# <h1 class="category">{{ page.title }}</h1>
# <ul class="posts">
# {% for post in site.categories[page.category] %}
# <div>{{ post.date | date_to_html_string }}</div>
# <h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
# <div class="categories">Filed under {{ post.categories | category_links }}</div>
# {% endfor %}
# </ul>
# ================================== 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 : # Included filters :
# - category_links: Outputs the list of categories as comma-separated <a> links. # - category_links: Outputs the list of categories as comma-separated <a> links.
# - date_to_html_string: Outputs the post.date as formatted html, with hooks for CSS styling. # - date_to_html_string: Outputs the post.date as formatted html, with hooks for CSS styling.
@ -18,27 +51,32 @@
# - category_dir: The subfolder to build category pages in (default is 'categories'). # - 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_title_prefix: The string used before the category name in the page title (default is
# 'Category: '). # 'Category: ').
require 'stringex'
module Jekyll module Jekyll
# The CategoryIndex class creates a single category page for the specified category. # The CategoryIndex class creates a single category page for the specified category.
class CategoryIndex < Page class CategoryPage < Page
# Initializes a new CategoryIndex. # 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 <source>. # +base+ is the String path to the <source>.
# +category_dir+ is the String path between <source> and the category folder. # +category_dir+ is the String path between <source> and the category folder.
# +category+ is the category currently being processed. # +category+ is the category currently being processed.
def initialize(site, base, category_dir, category) def initialize(template_path, name, site, base, category_dir, category)
@site = site @site = site
@base = base @base = base
@dir = category_dir @dir = category_dir
@name = 'index.html' @name = name
self.process(@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. # Read the YAML data from the layout page.
self.read_yaml(File.join(base, '_layouts'), 'category_index.html') self.read_yaml(template_dir, template)
self.data['category'] = category self.data['category'] = category
# Set the title for this page. # Set the title for this page.
title_prefix = site.config['category_title_prefix'] || 'Category: ' title_prefix = site.config['category_title_prefix'] || 'Category: '
@ -46,36 +84,48 @@ module Jekyll
# Set the meta-description for this page. # Set the meta-description for this page.
meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: ' meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: '
self.data['description'] = "#{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 < CategoryPage
# Initializes a new CategoryIndex.
#
# +site+ is the Jekyll Site instance.
# +base+ is the String path to the <source>.
# +category_dir+ is the String path between <source> and the category folder.
# +category+ is the category currently being processed.
def initialize(site, base, category_dir, category)
template_path = File.join(base, '_layouts', 'category_index.html')
super(template_path, 'index.html', site, base, category_dir, category)
end end
end end
# The CategoryFeed class creates an Atom feed for the specified category. # The CategoryFeed class creates an Atom feed for the specified category.
class CategoryFeed < Page class CategoryFeed < CategoryPage
# Initializes a new CategoryFeed. # Initializes a new CategoryFeed.
# #
# +site+ is the Jekyll Site instance.
# +base+ is the String path to the <source>. # +base+ is the String path to the <source>.
# +category_dir+ is the String path between <source> and the category folder. # +category_dir+ is the String path between <source> and the category folder.
# +category+ is the category currently being processed. # +category+ is the category currently being processed.
def initialize(site, base, category_dir, category) def initialize(site, base, category_dir, category)
@site = site template_path = File.join(base, '_includes', 'custom', 'category_feed.xml')
@base = base super(template_path, 'atom.xml', site, base, category_dir, category)
@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}"
# Set the correct feed URL. # Set the correct feed URL.
self.data['feed_url'] = "#{category_dir}/#{name}" self.data['feed_url'] = "#{category_dir}/#{name}" if render?
end end
end end
@ -86,44 +136,37 @@ module Jekyll
# Creates an instance of CategoryIndex for each category page, renders it, and # Creates an instance of CategoryIndex for each category page, renders it, and
# writes the output to a file. # writes the output to a file.
# #
# +category_dir+ is the String path to the category folder.
# +category+ is the category currently being processed. # +category+ is the category currently being processed.
def write_category_index(category_dir, category) def write_category_index(category)
index = CategoryIndex.new(self, self.source, category_dir, 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.render(self.layouts, site_payload)
index.write(self.dest) index.write(self.dest)
# Record the fact that this page has been added, otherwise Site::cleanup will remove it. # Record the fact that this pages has been added, otherwise Site::cleanup will remove it.
self.pages << index self.pages << index
end
# Create an Atom-feed for each index. # Create an Atom-feed for each index.
feed = CategoryFeed.new(self, self.source, category_dir, category) feed = CategoryFeed.new(self, self.source, target_dir, category)
if feed.render?
feed.render(self.layouts, site_payload) feed.render(self.layouts, site_payload)
feed.write(self.dest) feed.write(self.dest)
# Record the fact that this page has been added, otherwise Site::cleanup will remove it. # Record the fact that this pages has been added, otherwise Site::cleanup will remove it.
self.pages << feed self.pages << feed
end end
end
# Loops through the list of category pages and processes each one. # Loops through the list of category pages and processes each one.
def write_category_indexes def write_category_indexes
if self.layouts.key? 'category_index' if self.layouts.key? 'category_index'
dir = self.config['category_dir'] || 'categories'
self.categories.keys.each do |category| self.categories.keys.each do |category|
self.write_category_index(File.join(dir, category.to_url), category) self.write_category_index(category)
end end
# Throw an exception if the layout couldn't be found. # Throw an exception if the layout couldn't be found.
else else
raise <<-ERR throw "No 'category_index' layout found."
===============================================
Error for category_generator.rb plugin
-----------------------------------------------
No 'category_index.html' in source/_layouts/
Perhaps you haven't installed a theme yet.
===============================================
ERR
end end
end end
@ -135,10 +178,20 @@ ERR
safe true safe true
priority :low priority :low
CATEGORY_DIR = 'categories'
def generate(site) def generate(site)
site.write_category_indexes site.write_category_indexes
end 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 end
@ -151,9 +204,14 @@ ERR
# +categories+ is the list of categories to format. # +categories+ is the list of categories to format.
# #
# Returns string # Returns string
#
def category_links(categories) 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 =~ /^\//
"<a class='category' href='#{category_dir}/'>#{category}</a>"
end
case categories.length case categories.length
when 0 when 0
@ -161,7 +219,7 @@ ERR
when 1 when 1
categories[0].to_s categories[0].to_s
else else
"#{categories[0...-1].join(', ')}, #{categories[-1]}" categories.join(', ')
end end
end end
@ -172,8 +230,9 @@ ERR
# Returns string # Returns string
# #
def category_link(category) def category_link(category)
dir = @context.registers[:site].config['category_dir'] base_dir = @context.registers[:site].config['category_dir']
"<a class='category' href='/#{dir}/#{category.to_url}/'>#{category}</a>" category_dir = GenerateCategories.category_dir(base_dir, category)
"<a class='category' href='/#{category_dir}/'>#{category}</a>"
end end
# Outputs the post.date as formatted html, with hooks for CSS styling. # Outputs the post.date as formatted html, with hooks for CSS styling.