jekyll-category_generator 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.gitlab-ci.yml +57 -0
- data/.overcommit.yml +10 -0
- data/.rubocop.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config.reek +6 -0
- data/jekyll-category_generator.gemspec +31 -0
- data/lib/jekyll-category_generator.rb +28 -0
- data/lib/jekyll/category_generator/categories.rb +53 -0
- data/lib/jekyll/category_generator/category.rb +44 -0
- data/lib/jekyll/category_generator/category_filters.rb +57 -0
- data/lib/jekyll/category_generator/category_index.rb +41 -0
- data/lib/jekyll/category_generator/site_override.rb +55 -0
- data/lib/jekyll/category_generator/time_override.rb +15 -0
- data/lib/jekyll/category_generator/version.rb +5 -0
- data/rakefile +1 -0
- data/readme.md +113 -0
- metadata +205 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8acda2ba362a6d53f70f0a1aae5b2214bd4ab2c8
|
|
4
|
+
data.tar.gz: a8d3769cb54d06230917bef2db623fbc5f4c5c7e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 943cae7c0008acb4cac059fd92115b46550424db78eccc178bed9545e1c0405174abbc20e67fc65cb336bcf482f85dcd5f42aa3b8a4b3927fe89cc42f9edcecb
|
|
7
|
+
data.tar.gz: 6a67a081b47d1fd9148a6b7d3e7b82ffc2231a3d6eeea57524122237d8db437998dce866ebba8c86dc978dcbc2787aebb2d6d27158ccf5e3612d87e1f09584fe
|
data/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
image: ruby:2.3
|
|
2
|
+
|
|
3
|
+
before_script:
|
|
4
|
+
- apt-get update >/dev/null
|
|
5
|
+
- apt-get install -y locales >/dev/null
|
|
6
|
+
- echo "en_US UTF-8" > /etc/locale.gen
|
|
7
|
+
- locale-gen en_US.UTF-8
|
|
8
|
+
- export LANG=en_US.UTF-8
|
|
9
|
+
- export LANGUAGE=en_US:en
|
|
10
|
+
- export LC_ALL=en_US.UTF-8
|
|
11
|
+
|
|
12
|
+
rubocop:
|
|
13
|
+
stage: test
|
|
14
|
+
script:
|
|
15
|
+
- bundle install
|
|
16
|
+
- bundle exec rubocop
|
|
17
|
+
|
|
18
|
+
reek:
|
|
19
|
+
stage: test
|
|
20
|
+
script:
|
|
21
|
+
- bundle install
|
|
22
|
+
- bundle exec reek
|
|
23
|
+
|
|
24
|
+
rspec:
|
|
25
|
+
stage: test
|
|
26
|
+
script:
|
|
27
|
+
- bundle install
|
|
28
|
+
- bundle exec rspec
|
|
29
|
+
artifacts:
|
|
30
|
+
paths:
|
|
31
|
+
- coverage/
|
|
32
|
+
only:
|
|
33
|
+
- master
|
|
34
|
+
|
|
35
|
+
pages:
|
|
36
|
+
stage: deploy
|
|
37
|
+
dependencies:
|
|
38
|
+
- rspec
|
|
39
|
+
script:
|
|
40
|
+
- mv coverage/ public/
|
|
41
|
+
artifacts:
|
|
42
|
+
paths:
|
|
43
|
+
- public
|
|
44
|
+
expire_in: 30 days
|
|
45
|
+
only:
|
|
46
|
+
- master
|
|
47
|
+
|
|
48
|
+
rubygems:
|
|
49
|
+
stage: deploy
|
|
50
|
+
dependencies:
|
|
51
|
+
- rspec
|
|
52
|
+
script:
|
|
53
|
+
- gem install dpl
|
|
54
|
+
- rake build
|
|
55
|
+
- dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
|
|
56
|
+
only:
|
|
57
|
+
- master
|
data/.overcommit.yml
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Alain ANDRE
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'jekyll_category_generator'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require 'irb'
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/config.reek
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require 'jekyll/category_generator/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = 'jekyll-category_generator'
|
|
9
|
+
spec.version = Jekyll::CategoryGenerator::VERSION
|
|
10
|
+
spec.authors = ['Alain ANDRE']
|
|
11
|
+
spec.email = ['dev@alain-andre.fr']
|
|
12
|
+
spec.summary = 'Category generator for Jekyll 3.x'
|
|
13
|
+
spec.description = 'Provides a simple category generator allowing filtering and easy configuration for Jekyll.'
|
|
14
|
+
spec.homepage = 'https://gitlab.com/al1_andre/jekyll-category-generator'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
|
18
|
+
end
|
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
+
spec.require_paths = ['lib']
|
|
21
|
+
spec.add_runtime_dependency 'jekyll', '>= 3.0.0'
|
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
25
|
+
spec.add_development_dependency 'simplecov', '~> 0.15.0'
|
|
26
|
+
spec.add_development_dependency 'byebug', '~> 9.0.6'
|
|
27
|
+
spec.add_development_dependency 'overcommit', '~> 0.40.0'
|
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 0.49.1'
|
|
29
|
+
spec.add_development_dependency 'bundle-audit', '~> 0.1.0'
|
|
30
|
+
spec.add_development_dependency 'reek', '~> 4.7.2'
|
|
31
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# Jekyll category page generator.
|
|
4
|
+
# Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
|
|
5
|
+
# Copyright (c) 2017 Alain ANDRE, http://alain-andre.fr/
|
|
6
|
+
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
7
|
+
|
|
8
|
+
require 'jekyll/category_generator/version'
|
|
9
|
+
require 'jekyll/category_generator/site_override.rb'
|
|
10
|
+
require 'jekyll/category_generator/category_filters.rb'
|
|
11
|
+
|
|
12
|
+
# Includes the plugin into the Jekyll module
|
|
13
|
+
module Jekyll
|
|
14
|
+
# The category generator module
|
|
15
|
+
module CategoryGenerator
|
|
16
|
+
DIRECTORIES_FOLDER = 'categories'.freeze
|
|
17
|
+
# Jekyll hook - the generate method is called by jekyll, and generates all of the category pages.
|
|
18
|
+
class CGenerator < Generator
|
|
19
|
+
safe true
|
|
20
|
+
priority :low
|
|
21
|
+
def generate(site)
|
|
22
|
+
site.write_category_indexes
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Liquid::Template.register_filter(Jekyll::CategoryFilters)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'jekyll/category_generator/category.rb'
|
|
4
|
+
|
|
5
|
+
# Includes the plugin into the Jekyll module
|
|
6
|
+
module Jekyll
|
|
7
|
+
##
|
|
8
|
+
# Managing many Category
|
|
9
|
+
class Categories
|
|
10
|
+
##
|
|
11
|
+
# Initialize the list of categories by passing a list of String.
|
|
12
|
+
#
|
|
13
|
+
# +category_names+ An array of strings representing a list of categories.
|
|
14
|
+
# +context+ is the Liquid:Tag context
|
|
15
|
+
#
|
|
16
|
+
def initialize(category_names, context)
|
|
17
|
+
category_names = [category_names] unless category_names.is_a? Array
|
|
18
|
+
initialize_category_list(category_names, context)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# Initialize the category list
|
|
23
|
+
#
|
|
24
|
+
# +category_names+ An array of strings representing a list of categories.
|
|
25
|
+
# +context+ is the Liquid:Tag context
|
|
26
|
+
#
|
|
27
|
+
def initialize_category_list(category_names, context)
|
|
28
|
+
@category_list = category_names.map { |string| Category.new(string, context) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Outputs a list of categories as comma-separated <a> links. This is used
|
|
33
|
+
# to output the category list for each post on a category page.
|
|
34
|
+
#
|
|
35
|
+
# Returns string
|
|
36
|
+
#
|
|
37
|
+
def links
|
|
38
|
+
comma_separate(@category_list.sort!.map(&:link))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
##
|
|
44
|
+
# Join a list as comma-separated
|
|
45
|
+
def comma_separate(list_of_links)
|
|
46
|
+
if list_of_links.length == 1
|
|
47
|
+
list_of_links[0].to_s
|
|
48
|
+
else
|
|
49
|
+
"#{list_of_links[0...-1].join(', ')}, #{list_of_links[-1]}"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
# Includes the plugin into the Jekyll module
|
|
6
|
+
module Jekyll
|
|
7
|
+
##
|
|
8
|
+
# Managing a Category
|
|
9
|
+
class Category
|
|
10
|
+
include Comparable
|
|
11
|
+
|
|
12
|
+
attr_reader :name
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
# Initialize the Category
|
|
16
|
+
#
|
|
17
|
+
# +name+ is the name of the current Category
|
|
18
|
+
# +context+ is the Liquid:Tag context
|
|
19
|
+
#
|
|
20
|
+
def initialize(name, context)
|
|
21
|
+
@name = name
|
|
22
|
+
@context = context
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
# Compare this Category against another Category.
|
|
27
|
+
# Comparison is a comparison between the 2 names.
|
|
28
|
+
#
|
|
29
|
+
def <=>(other)
|
|
30
|
+
return nil unless name.is_a? String
|
|
31
|
+
name <=> other.name
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# Outputs a single category as an <a> link using the given category_dir.
|
|
36
|
+
#
|
|
37
|
+
# Returns html formatted string
|
|
38
|
+
#
|
|
39
|
+
def link
|
|
40
|
+
dir = @context.registers[:site].config['category_dir'] || CategoryGenerator::DIRECTORIES_FOLDER
|
|
41
|
+
"<a class='category' href='/#{dir}/#{URI.encode(@name)}/'>#{@name}</a>"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'jekyll/category_generator/time_override.rb'
|
|
4
|
+
require 'jekyll/category_generator/categories.rb'
|
|
5
|
+
|
|
6
|
+
# Includes the Filters into the Jekyll module
|
|
7
|
+
module Jekyll
|
|
8
|
+
# Adds some extra filters used during the category creation process.
|
|
9
|
+
module CategoryFilters
|
|
10
|
+
##
|
|
11
|
+
# Outputs a list of categories as comma-separated <a> links. This is used
|
|
12
|
+
# to output the category list for each post on a category page.
|
|
13
|
+
#
|
|
14
|
+
# Returns string
|
|
15
|
+
def category_links(categories)
|
|
16
|
+
Categories.new(categories, @context).links
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Outputs a single category as an <a> link.
|
|
21
|
+
#
|
|
22
|
+
# Returns string
|
|
23
|
+
def category_link(category)
|
|
24
|
+
Category.new(category, @context).link
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Outputs the post.date as formatted html, with hooks for CSS styling.
|
|
29
|
+
#
|
|
30
|
+
# +date+ is the date object to format as HTML.
|
|
31
|
+
#
|
|
32
|
+
# Returns string
|
|
33
|
+
def date_to_html_string(date)
|
|
34
|
+
date.strftime_with(format, months)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# Return the configured format
|
|
39
|
+
#
|
|
40
|
+
# Returns string
|
|
41
|
+
def format
|
|
42
|
+
@context.registers[:site].config['jekyll-category-generator']['date']['format']
|
|
43
|
+
rescue
|
|
44
|
+
'%Y-%m-%d'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
##
|
|
48
|
+
# Return the configured months list
|
|
49
|
+
#
|
|
50
|
+
# Returns string
|
|
51
|
+
def months
|
|
52
|
+
@context.registers[:site].config['jekyll-category-generator']['date']['months']
|
|
53
|
+
rescue
|
|
54
|
+
nil
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# Includes the plugin into the Jekyll module
|
|
4
|
+
module Jekyll
|
|
5
|
+
# The CategoryIndex class creates a single category page for the specified category.
|
|
6
|
+
class CategoryIndex < Page
|
|
7
|
+
# Initializes a new CategoryIndex.
|
|
8
|
+
#
|
|
9
|
+
# +base+ is the String path to the <source>.
|
|
10
|
+
# +category_dir+ is the String path between <source> and the category folder.
|
|
11
|
+
# +category+ is the category currently being processed.
|
|
12
|
+
def initialize(site, base, category_dir, category)
|
|
13
|
+
@site = site
|
|
14
|
+
@base = base
|
|
15
|
+
@dir = category_dir
|
|
16
|
+
@name = 'index.html'
|
|
17
|
+
process(@name)
|
|
18
|
+
# Read the YAML data from the layout page.
|
|
19
|
+
read_yaml(File.join(base, '_layouts'), 'category_index.html')
|
|
20
|
+
data['category'] = category
|
|
21
|
+
# Set the title for this page.
|
|
22
|
+
data['title'] = "#{title_prefix}#{category}"
|
|
23
|
+
# Set the meta-description for this page.
|
|
24
|
+
data['description'] = "#{description_prefix}#{category}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Return the category title prefix
|
|
31
|
+
def title_prefix
|
|
32
|
+
site.config['jekyll-category-generator.title_prefix'] || 'Category: '
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Return the category description prefix
|
|
37
|
+
def description_prefix
|
|
38
|
+
site.config['jekyll-category-generator.description_prefix'] || 'Category: '
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'jekyll/category_generator/category.rb'
|
|
4
|
+
require 'jekyll/category_generator/categories.rb'
|
|
5
|
+
require 'jekyll/category_generator/category_index.rb'
|
|
6
|
+
|
|
7
|
+
# Includes the plugin into the Jekyll module
|
|
8
|
+
module Jekyll
|
|
9
|
+
# The Site class is a built-in Jekyll class with access to global site config information.
|
|
10
|
+
class Site
|
|
11
|
+
# Creates an instance of CategoryIndex for each category page, renders it, and
|
|
12
|
+
# writes the output to a file.
|
|
13
|
+
#
|
|
14
|
+
# +category_dir+ is the String path to the category folder.
|
|
15
|
+
# +category+ is the category currently being processed.
|
|
16
|
+
def write_category_index(category_dir, category)
|
|
17
|
+
index = CategoryIndex.new(self, source, category_dir, category)
|
|
18
|
+
index.render(layouts, site_payload)
|
|
19
|
+
index.write(dest)
|
|
20
|
+
# Record the fact that this page has been added, otherwise Site::cleanup will remove it.
|
|
21
|
+
pages << index
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Loops through the list of category pages and processes each one.
|
|
25
|
+
def write_category_indexes
|
|
26
|
+
raise_unexisting_layout_error unless layouts.key? 'category_index'
|
|
27
|
+
categories.keys.each do |category|
|
|
28
|
+
write_category_index(File.join(categories_folder, category), category)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# Returns the categories folder
|
|
34
|
+
#
|
|
35
|
+
def categories_folder
|
|
36
|
+
config['category_dir'] || CategoryGenerator::DIRECTORIES_FOLDER
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Raise an error on unexisting layout
|
|
40
|
+
def raise_unexisting_layout_error
|
|
41
|
+
raise <<-ERR
|
|
42
|
+
|
|
43
|
+
=======================================================================
|
|
44
|
+
Error for jekyll-category_generator.rb plugin
|
|
45
|
+
-----------------------------------------------------------------------
|
|
46
|
+
No 'category_index.html' in source/_layouts/ !!
|
|
47
|
+
You should create it first. See the plugin home page for more details
|
|
48
|
+
-----------------------------------------------------------------------
|
|
49
|
+
Home page : https://gitlab.com/al1_andre/jekyll-category-generator
|
|
50
|
+
=======================================================================
|
|
51
|
+
|
|
52
|
+
ERR
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
require 'time'
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# Overriding Time class
|
|
6
|
+
class Time
|
|
7
|
+
def strftime_with(format, months)
|
|
8
|
+
if months
|
|
9
|
+
months = [nil] + months.split(' ')
|
|
10
|
+
format = format.dup
|
|
11
|
+
format.gsub!(/%B/, months[mon])
|
|
12
|
+
end
|
|
13
|
+
strftime(format)
|
|
14
|
+
end
|
|
15
|
+
end
|
data/rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/readme.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Jekyll Category Generator
|
|
2
|
+
|
|
3
|
+
Provides a simple category generator allowing filtering and easy configuration for [Jekyll](https://jekyllrb.com/) V3.x.
|
|
4
|
+
|
|
5
|
+
[](https://gitlab.com/al1_andre/jekyll-category-generator/commits/master)
|
|
6
|
+
[](http://al1_andre.gitlab.io/jekyll-category-generator)
|
|
7
|
+
|
|
8
|
+
# Installation
|
|
9
|
+
|
|
10
|
+
## Add the gem in your `Gemfile`:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
group :jekyll_plugins do
|
|
14
|
+
gem 'jekyll-category_generator'
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Add the plugin to your `_config.yml`:
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
plugins:
|
|
22
|
+
- jekyll-category_generator
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
# Configuration
|
|
26
|
+
First of all, you need to create a *layout* named `category_index.html`; It will be used to create the index of all posts of a category.
|
|
27
|
+
|
|
28
|
+
The file should at least have the following code.
|
|
29
|
+
```html
|
|
30
|
+
<!-- _layouts/category_index.html -->
|
|
31
|
+
<ul>
|
|
32
|
+
{% for post in site.categories[page.category] %}
|
|
33
|
+
<li><a href="{{ root_url }}{{ post.url }}">{{ post.title }}</a></li>
|
|
34
|
+
{% endfor %}
|
|
35
|
+
</ul>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Using the plugin
|
|
39
|
+
The plugin contains usefull filters and configuration variables helping you to create a nice *layout*.
|
|
40
|
+
|
|
41
|
+
## Filters
|
|
42
|
+
### category_links
|
|
43
|
+
This filter allows you to create a list of links of all the given categories.
|
|
44
|
+
|
|
45
|
+
Usefull to add to the end of a post for example.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
{{ post.categories | category_links }}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### category_link
|
|
52
|
+
This filter allows you to create the link of a given category.
|
|
53
|
+
|
|
54
|
+
Usefull for a menu listing all categories for example.
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<ul>
|
|
58
|
+
{% for category in site.categories %}
|
|
59
|
+
<li>{{ category.first | category_link }}</li>
|
|
60
|
+
{% endfor %}
|
|
61
|
+
</ul>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### date_to_html_string
|
|
65
|
+
This filter allows you to output a HtML formatted date (`2017-03-12` by default).
|
|
66
|
+
|
|
67
|
+
This code
|
|
68
|
+
```html
|
|
69
|
+
{{ post.date | date_to_html_string }}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The format can be specified in the `_config.yml` file.
|
|
73
|
+
|
|
74
|
+
## Variables in `_config.yml`
|
|
75
|
+
|
|
76
|
+
### Basics configuration keys
|
|
77
|
+
The title of the category can be prefixed by the `title_prefix` value, by default, it is set with **Category:**
|
|
78
|
+
|
|
79
|
+
The category directory is by default the `categories/` folder, but you can change it by adding the `category_dir` key.
|
|
80
|
+
|
|
81
|
+
The `description_prefix` configuration key can be used to prefix each post description.
|
|
82
|
+
|
|
83
|
+
### Date format configuration
|
|
84
|
+
The `date_to_html_string` filter allows you to stringify the date for your own language by adding the following.
|
|
85
|
+
|
|
86
|
+
The *format* variable uses the Ruby [Time#strftime](http://ruby-doc.org/core-2.2.1/Time.html#method-i-strftime) method.
|
|
87
|
+
|
|
88
|
+
```yml
|
|
89
|
+
jekyll-category-generator:
|
|
90
|
+
date:
|
|
91
|
+
format : '%d %B %Y'
|
|
92
|
+
months : 'janvier février mars avril mai juin juillet août septembre octobre novembre décembre'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The output will be as follow.
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
12 janvier 2017
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
# Licences and greetings
|
|
102
|
+
This gem is under [MIT Licence](/LICENSE) and is build based on the work of :
|
|
103
|
+
- [Dave Perrett](http://recursive-design.com/)
|
|
104
|
+
- [Rémi Prévost](https://gist.github.com/remiprev/2665712)
|
|
105
|
+
|
|
106
|
+
# Gem tasks
|
|
107
|
+
|
|
108
|
+
- rake build # Build jekyll-category-generator-0.0.1.gem into the pkg directory
|
|
109
|
+
- rake clean # Remove any temporary products
|
|
110
|
+
- rake clobber # Remove any generated files
|
|
111
|
+
- rake install # Build and install jekyll-category-generator-0.0.1.gem into system gems
|
|
112
|
+
- rake install:local # Build and install jekyll-category-generator-0.0.1.gem into system gems without network access
|
|
113
|
+
- rake release[remote] # Create tag v0.0.1 and build and push jekyll-category-generator-0.0.1.gem to Rubygems
|
metadata
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jekyll-category_generator
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alain ANDRE
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: jekyll
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 3.0.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.15'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.15'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.15.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.15.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: byebug
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 9.0.6
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 9.0.6
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: overcommit
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.40.0
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.40.0
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rubocop
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.49.1
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.49.1
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: bundle-audit
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.1.0
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 0.1.0
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: reek
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: 4.7.2
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: 4.7.2
|
|
153
|
+
description: Provides a simple category generator allowing filtering and easy configuration
|
|
154
|
+
for Jekyll.
|
|
155
|
+
email:
|
|
156
|
+
- dev@alain-andre.fr
|
|
157
|
+
executables: []
|
|
158
|
+
extensions: []
|
|
159
|
+
extra_rdoc_files: []
|
|
160
|
+
files:
|
|
161
|
+
- ".gitignore"
|
|
162
|
+
- ".gitlab-ci.yml"
|
|
163
|
+
- ".overcommit.yml"
|
|
164
|
+
- ".rubocop.yml"
|
|
165
|
+
- Gemfile
|
|
166
|
+
- LICENSE
|
|
167
|
+
- bin/console
|
|
168
|
+
- bin/setup
|
|
169
|
+
- config.reek
|
|
170
|
+
- jekyll-category_generator.gemspec
|
|
171
|
+
- lib/jekyll-category_generator.rb
|
|
172
|
+
- lib/jekyll/category_generator/categories.rb
|
|
173
|
+
- lib/jekyll/category_generator/category.rb
|
|
174
|
+
- lib/jekyll/category_generator/category_filters.rb
|
|
175
|
+
- lib/jekyll/category_generator/category_index.rb
|
|
176
|
+
- lib/jekyll/category_generator/site_override.rb
|
|
177
|
+
- lib/jekyll/category_generator/time_override.rb
|
|
178
|
+
- lib/jekyll/category_generator/version.rb
|
|
179
|
+
- rakefile
|
|
180
|
+
- readme.md
|
|
181
|
+
homepage: https://gitlab.com/al1_andre/jekyll-category-generator
|
|
182
|
+
licenses:
|
|
183
|
+
- MIT
|
|
184
|
+
metadata: {}
|
|
185
|
+
post_install_message:
|
|
186
|
+
rdoc_options: []
|
|
187
|
+
require_paths:
|
|
188
|
+
- lib
|
|
189
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
|
+
requirements:
|
|
191
|
+
- - ">="
|
|
192
|
+
- !ruby/object:Gem::Version
|
|
193
|
+
version: '0'
|
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
|
+
requirements:
|
|
196
|
+
- - ">="
|
|
197
|
+
- !ruby/object:Gem::Version
|
|
198
|
+
version: '0'
|
|
199
|
+
requirements: []
|
|
200
|
+
rubyforge_project:
|
|
201
|
+
rubygems_version: 2.5.1
|
|
202
|
+
signing_key:
|
|
203
|
+
specification_version: 4
|
|
204
|
+
summary: Category generator for Jekyll 3.x
|
|
205
|
+
test_files: []
|