jekyll-post-tags 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +6 -5
- data/README.md +6 -9
- data/Rakefile +41 -6
- data/lib/jekyll-post-tags.rb +4 -3
- data/lib/jekyll/post/tags.rb +9 -15
- data/lib/jekyll/post/tags/drop.rb +13 -13
- data/lib/jekyll/post/tags/generator.rb +39 -33
- data/lib/jekyll/post/tags/helpers.rb +9 -11
- data/lib/jekyll/post/tags/hook.rb +19 -5
- data/lib/jekyll/post/tags/page.rb +8 -6
- data/lib/jekyll/post/tags/version.rb +5 -4
- metadata +60 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dc296d8f4add80c0002a7443deca2a61db53f41d96f5d61013d4b98add6f4004
|
4
|
+
data.tar.gz: a1505efce2180779d9255a7c92022247dca0cf7a7ba703f96c235b723a2669b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f9eb8f498adb3bb552f2490d05e16b45dc093b51906b2b9cb44a9709d3608676859f5125a811dd49a188645140e6ab64d888ad59d13202bc1e3b53e2c156286
|
7
|
+
data.tar.gz: eb45cfea6698a658f062ed0219241d31fd2e52943656c7a06a82a1d33825bd8d217e2784eb8a32a2f2a0f6da9122fa210b30655b6a50b37bc83e1129e3b082de
|
data/Gemfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
1
6
|
source "https://rubygems.org"
|
2
7
|
gemspec
|
3
8
|
|
4
|
-
gem "rake"
|
5
|
-
gem "pry"
|
6
|
-
|
7
9
|
if ENV["JEKYLL_VERSION"]
|
8
|
-
|
9
|
-
gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
|
10
|
+
gem "jekyll", "~> #{ENV['JEKYLL_VERSION']}"
|
10
11
|
end
|
data/README.md
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<img src="https://travis-ci.org/envygeeks/jekyll-post-tags.svg?branch=master">
|
8
|
-
</a>
|
9
|
-
</div>
|
1
|
+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/envygeeks/jekyll-post-tags.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-post-tags/maintainability)
|
2
|
+
[![Code Climate](https://img.shields.io/codeclimate/c/envygeeks/jekyll-post-tags.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-post-tags/coverage)
|
3
|
+
[![Travis CI](https://img.shields.io/travis/envygeeks/jekyll-post-tags/master.svg?style=for-the-badge)](https://travis-ci.org/envygeeks/jekyll-post-tags)
|
4
|
+
[![Donate](https://img.shields.io/badge/-DONATE-yellow.svg?style=for-the-badge)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LKGZAWXLZ8ZPG)
|
5
|
+
![Gem Version](https://img.shields.io/gem/v/jekyll-post-tags.svg?style=for-the-badge)
|
6
|
+
![Gem DL](https://img.shields.io/gem/dt/jekyll-post-tags.svg?style=for-the-badge)
|
10
7
|
|
11
8
|
# Jekyll Post Tags
|
12
9
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,42 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2017 - 2018 - MIT License
|
3
|
+
# Source: https://github.com/envygeeks/devfiles
|
4
|
+
# Author: Jordon Bedwell
|
5
|
+
# Encoding: utf-8
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
# --
|
8
|
+
# 🔖
|
9
|
+
# RSpec, MiniTest, Whatever.
|
10
|
+
# --
|
11
|
+
task default: [:spec]
|
12
|
+
task :spec do
|
13
|
+
exec "script/test"
|
14
|
+
end
|
15
|
+
# --
|
16
|
+
# 🔖
|
17
|
+
# RSpec, MiniTest, Whatever.
|
18
|
+
# --
|
19
|
+
task :test do
|
20
|
+
exec "script/test"
|
21
|
+
end
|
22
|
+
# --
|
23
|
+
# 🔖
|
24
|
+
# @see .rubocop.yml
|
25
|
+
# Rubocop.
|
26
|
+
# --
|
27
|
+
task :rubocop do
|
28
|
+
exec "script/lint"
|
29
|
+
end
|
30
|
+
# --
|
31
|
+
# 🔖
|
32
|
+
# @see .rubocop.yml
|
33
|
+
# Rubocop.
|
34
|
+
# --
|
35
|
+
task :lint do
|
36
|
+
exec "script/lint"
|
37
|
+
end
|
38
|
+
|
39
|
+
# --
|
40
|
+
Dir.glob("script/rake.d/*.rake").each do |v|
|
41
|
+
load v
|
42
|
+
end
|
data/lib/jekyll-post-tags.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
require_relative "jekyll/post/tags"
|
data/lib/jekyll/post/tags.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
require "jekyll"
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require_relative "tags/generator"
|
12
|
-
require_relative "tags/version"
|
13
|
-
require_relative "tags/page"
|
14
|
-
require_relative "tags/hook"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
7
|
+
require_relative "tags/drop"
|
8
|
+
require_relative "tags/generator"
|
9
|
+
require_relative "tags/version"
|
10
|
+
require_relative "tags/page"
|
11
|
+
require_relative "tags/hook"
|
@@ -1,6 +1,7 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright 2016 -
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
require_relative "helpers"
|
6
7
|
require "liquid/drop/str"
|
@@ -8,20 +9,15 @@ require "liquid/drop/str"
|
|
8
9
|
module Jekyll
|
9
10
|
module Post
|
10
11
|
module Tags
|
11
|
-
|
12
|
-
# --
|
13
|
-
# @see https://github.com/envygeeks/liquid-string-drop
|
14
|
-
# Provides a string drop that we can wrap directly
|
15
|
-
# back into Jekyll without disrupting the ways users
|
16
|
-
# work, and without disrupting the way Jekyll currently
|
17
|
-
# works with it's own stuff.
|
18
|
-
# --
|
19
12
|
class Drop < Liquid::Drop::Str
|
20
13
|
attr_reader :weight, :site
|
21
14
|
extend Forwardable::Extended
|
22
15
|
rb_delegate :name, to: :@tag, alias_of: :to_s
|
23
16
|
include Helpers
|
24
17
|
|
18
|
+
# --
|
19
|
+
# New instance.
|
20
|
+
# @return [nil]
|
25
21
|
# --
|
26
22
|
def initialize(tag, site:, weight: 1)
|
27
23
|
super(tag)
|
@@ -31,15 +27,19 @@ module Jekyll
|
|
31
27
|
@tag = tag
|
32
28
|
end
|
33
29
|
|
30
|
+
# --
|
31
|
+
# The url of the tag.
|
32
|
+
# @return [String]
|
34
33
|
# --
|
35
34
|
def url
|
36
35
|
File.join(*tag_path)
|
37
36
|
end
|
38
37
|
|
39
38
|
# --
|
39
|
+
# Loop through, and return tags.
|
40
|
+
# @param site [Jekyll::Site] the site.
|
41
|
+
# @note These should return drops?
|
40
42
|
# @return [[]] the tags.
|
41
|
-
# Loop through tags, set them up and then, pass
|
42
|
-
# them back out.
|
43
43
|
# --
|
44
44
|
def self.to_tags(site:)
|
45
45
|
div = 4.0 / site.tags.values.max_by(&:size).size
|
@@ -1,47 +1,53 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright 2016 -
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
require "jekyll/generator"
|
6
7
|
|
7
8
|
module Jekyll
|
8
9
|
module Post
|
9
10
|
module Tags
|
10
|
-
|
11
|
-
# --
|
12
|
-
# @see https://github.com/jekyll/jekyll
|
13
|
-
# Generates the sites tags, using Jekyll's
|
14
|
-
# generators this is controlled by them and we don't
|
15
|
-
# really need to do that much after that.
|
16
|
-
#
|
17
|
-
# @example
|
18
|
-
# ```yaml
|
19
|
-
# # _config.yml
|
20
|
-
# tag_layout: custom_layout
|
21
|
-
# ```
|
22
|
-
# --
|
23
11
|
class Generator < Jekyll::Generator
|
24
|
-
def generate(site)
|
25
|
-
# @note this belongs in your `_config.yml`
|
26
|
-
key = (site.config["tag_layout"] || "default").chomp(".html")
|
27
12
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
13
|
+
# --
|
14
|
+
# Generate the tags.
|
15
|
+
# @param site [Jekyll::Site]
|
16
|
+
# @return [nil]
|
17
|
+
# --
|
18
|
+
def generate(site)
|
19
|
+
site.config["tags"] ||= {}
|
20
|
+
key = site.config["tags"]["layout"] || "tag"
|
21
|
+
site.layouts.key?(key) || key = "default" # Main?
|
22
|
+
return error(key) unless site.layouts.key?(key)
|
23
|
+
site.config["tags"]["layout"] = key
|
24
|
+
generate_tags_with(site)
|
25
|
+
end
|
39
26
|
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
# --
|
28
|
+
# Generate the tags.
|
29
|
+
# @param site [Jekyll::Site] the site
|
30
|
+
# @see #generate
|
31
|
+
# @return [nil]
|
32
|
+
# --
|
33
|
+
def generate_tags_with(site)
|
34
|
+
site.tags.each_key do |v|
|
35
|
+
site.pages << (Page.new(v, site: site).tap do |o|
|
36
|
+
o.render(site.layouts, site.site_payload); o.write(site.dest)
|
37
|
+
end)
|
43
38
|
end
|
44
39
|
end
|
40
|
+
|
41
|
+
# --
|
42
|
+
# Throw an error.
|
43
|
+
# @param layout [String]
|
44
|
+
# @see #generate
|
45
|
+
# @return [nil]
|
46
|
+
# --
|
47
|
+
def error(layout)
|
48
|
+
Jekyll.logger.error "", "Could not find '#{layout}.html' " \
|
49
|
+
"Skipping tag generation."
|
50
|
+
end
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
@@ -1,6 +1,7 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright 2016 -
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
module Jekyll
|
6
7
|
module Post
|
@@ -12,10 +13,7 @@ module Jekyll
|
|
12
13
|
# --
|
13
14
|
private
|
14
15
|
def tag_layout
|
15
|
-
|
16
|
-
File.join("_layouts", (site.config["tag_layout"] \
|
17
|
-
||= "default.html").gsub(/^_layouts\//, ""))
|
18
|
-
end
|
16
|
+
@tag_layout ||= File.join("_layouts", site.config["tags"]["layout"])
|
19
17
|
end
|
20
18
|
|
21
19
|
# --
|
@@ -24,16 +22,16 @@ module Jekyll
|
|
24
22
|
# --
|
25
23
|
private
|
26
24
|
def tag_path
|
27
|
-
|
28
|
-
path = @site.config["
|
25
|
+
@tag_path ||= begin
|
26
|
+
path = @site.config["tags"]["path"] || "/tag/:tag.html"
|
29
27
|
path = path.sub(":tag", @tag).split("/")
|
30
|
-
unless path.last =~
|
28
|
+
unless path.last =~ %r!\.html$!
|
31
29
|
path << "/index.html"
|
32
30
|
end
|
33
31
|
|
34
32
|
[
|
35
33
|
path[0...-1].join("/"),
|
36
|
-
path.last
|
34
|
+
path.last,
|
37
35
|
]
|
38
36
|
end
|
39
37
|
end
|
@@ -1,10 +1,24 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright 2016 -
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
# --
|
7
|
+
# Register a hook to create the configuration
|
8
|
+
# @return [nil]
|
9
|
+
# --
|
10
|
+
Jekyll::Hooks.register :site, :after_init do |s|
|
11
|
+
s.config["tags"] ||= {
|
12
|
+
"layout" => nil, "path" => nil
|
13
|
+
}
|
14
|
+
end
|
7
15
|
|
16
|
+
# --
|
17
|
+
# Register a hook to generate the tags.
|
18
|
+
# @return [nil]
|
19
|
+
# --
|
20
|
+
Jekyll::Hooks.register :site, :pre_render, priority: 99 do |s, _|
|
21
|
+
tags = Jekyll::Post::Tags::Drop.to_tags(site: s)
|
8
22
|
s.posts.docs.each do |d|
|
9
23
|
d.data["tags"] = d.data["tags"].map do |t|
|
10
24
|
o = tags.find do |v|
|
@@ -1,6 +1,7 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
require_relative "helpers"
|
6
7
|
|
@@ -13,7 +14,7 @@ module Jekyll
|
|
13
14
|
# this is mostly modeled after Jekyll's own pages, posts
|
14
15
|
# documents and otherwise.
|
15
16
|
# --
|
16
|
-
class
|
17
|
+
class Page < Jekyll::Page
|
17
18
|
attr_accessor :site, :base, :tag, :dir, :name
|
18
19
|
include Helpers
|
19
20
|
|
@@ -38,8 +39,9 @@ module Jekyll
|
|
38
39
|
# @return [String]
|
39
40
|
# --
|
40
41
|
def realpath
|
41
|
-
@site.tags[@tag].sort_by
|
42
|
-
|
42
|
+
@site.tags[@tag].sort_by do |v|
|
43
|
+
v.data["date"]
|
44
|
+
end.first.relative_path
|
43
45
|
end
|
44
46
|
|
45
47
|
# --
|
@@ -1,11 +1,12 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright
|
3
|
-
#
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2016 - 2018 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
4
5
|
|
5
6
|
module Jekyll
|
6
7
|
module Post
|
7
8
|
module Tags
|
8
|
-
VERSION = "1.
|
9
|
+
VERSION = "1.1.0"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-post-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordon Bedwell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.16'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: luna-rspec-formatters
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +94,34 @@ dependencies:
|
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '3.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.52'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.52'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
description: Reusable Post Tags for Jekyll
|
70
126
|
email:
|
71
127
|
- jordon@envygeeks.io
|
@@ -97,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
153
|
requirements:
|
98
154
|
- - ">="
|
99
155
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
156
|
+
version: 2.4.0
|
101
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
158
|
requirements:
|
103
159
|
- - ">="
|
@@ -105,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
161
|
version: '0'
|
106
162
|
requirements: []
|
107
163
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.6
|
164
|
+
rubygems_version: 2.7.6
|
109
165
|
signing_key:
|
110
166
|
specification_version: 4
|
111
167
|
summary: Post Tags for Jekyll
|