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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 82dd827934df79ac51aef7b21aac284c6b25e53f
4
- data.tar.gz: ed13ea925f73f25e96bb1c27f2010bbe4ea4a2ce
2
+ SHA256:
3
+ metadata.gz: dc296d8f4add80c0002a7443deca2a61db53f41d96f5d61013d4b98add6f4004
4
+ data.tar.gz: a1505efce2180779d9255a7c92022247dca0cf7a7ba703f96c235b723a2669b6
5
5
  SHA512:
6
- metadata.gz: dd010d97fbe32465b007517ac794b7a6e6ffe1eb208c1a80c0663c58ac7cf21ab5b5917fe8c778c67ae1961ccac1160bc19cb78f56e75c814f673e2e732e7407
7
- data.tar.gz: b2b62853fa92a1c29663ff639976c17d9c36aca219a39d4ce0d5b0867acb0d6790620822b0de0a9f42017b2b9d7c9c184960d1d91da3cc4f2fc0502520179906
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
- # So we can test across all our supported.
9
- gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
10
+ gem "jekyll", "~> #{ENV['JEKYLL_VERSION']}"
10
11
  end
data/README.md CHANGED
@@ -1,12 +1,9 @@
1
- <p align=center>
2
- <a href=https://goo.gl/BhrgjW>
3
- <img src=https://envygeeks.io/badges/paypal-large_1.png alt=Donate>
4
- </a>
5
- <br>
6
- <a href=https://travis-ci.org/envygeeks/jekyll-post-tags>
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-String-Literal: true
2
- # Copyright 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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
- require "rspec/core/rake_task"
6
- RSpec::Core::RakeTask.new(:spec)
7
- task :default => [:spec]
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
@@ -1,5 +1,6 @@
1
- # Frozen-String-Literal: true
2
- # Copyright 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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"
@@ -1,17 +1,11 @@
1
- # Frozen-String-Literal: true
2
- # Copyright 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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
- module Jekyll
8
- module Post
9
- module Tags
10
- require_relative "tags/drop"
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-String-Literal: true
2
- # Copyright 2016 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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-String-Literal: true
2
- # Copyright 2016 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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
- if site.layouts.has_key?(key)
29
- return site.tags.keys.each do |v|
30
- tag = Doc.new(v, site: site)
31
- tag.render(site.layouts, site.site_payload)
32
- tag.write(site.dest)
33
- site.pages << tag
34
- end
35
-
36
- # This error should be configurable or removed entirely
37
- # because at the end of the day if there is no default.html
38
- # or a specific tag layout, the user knows this...
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
- else
41
- Jekyll.logger.error "", "Could not find '#{key}.html' " \
42
- "Skipping tags."
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-String-Literal: true
2
- # Copyright 2016 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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
- return @tag_layout ||= begin
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
- return @tag_path ||= begin
28
- path = @site.config["tag_path"] || "/tag/:tag.html"
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 =~ /\.html$/
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-String-Literal: true
2
- # Copyright 2016 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2016 - 2018 - MIT License
3
+ # Author: Jordon Bedwell
4
+ # Encoding: utf-8
4
5
 
5
- Jekyll::Hooks.register :site, :pre_render, priority: 99 do |s, p|
6
- tags = Jekyll::Post::Tags::Drop.to_tags(site: s)
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-String-Literal: true
2
- # Copyright 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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 Doc < Jekyll::Page
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 { |v| v.data["date"] \
42
- }.first.relative_path
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-String-Literal: true
2
- # Copyright 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: UTF-8
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.0.0"
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.0.0
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: 2017-08-12 00:00:00.000000000 Z
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: '0'
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.11
164
+ rubygems_version: 2.7.6
109
165
  signing_key:
110
166
  specification_version: 4
111
167
  summary: Post Tags for Jekyll