jekyll-archives 2.1.1 → 2.2.1

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: 2f27192f95a4ce144e1d72588b4bf80d765357f2
4
- data.tar.gz: 2e51316514e8d6020cfc281c302b9854e66e7c4b
2
+ SHA256:
3
+ metadata.gz: c5c95258f37bf6d7a5e8dc1befbefc7bbdf77aabfccdadd1c3a1522b9274907d
4
+ data.tar.gz: '0578f15ede10791f5febf123a00ded5fe86b90a79e1ba4091efcf012fba5b6d8'
5
5
  SHA512:
6
- metadata.gz: 6a07cb99f2004e548f0b386485f1f6a5ec9139b24f99db985a8a3e1b55ae42459fe07826aa5eaadc92f8454bbf5a82d3ff5c0b9891e1a0aa557190b6da5dd6a6
7
- data.tar.gz: f46620e903c6a09d2bd7ac414162d45eaeacf7a3f95ce407b6cb4e2dabe63358bd8e9946698bff2b32b436fbaa17da34fe24ad74df8b6ce51d48b40db18749d5
6
+ metadata.gz: cc616dc7d954f996eb84a485751c326aa3c825f52775bf42712b084083de3b9e46fb2cc2bed960f89785c4257fb8786046cd7d801d380778d7cb2737003f1dba
7
+ data.tar.gz: 190fe9519e46d52b7edbd68dd66fe38f5c92b1b84606bad1a1f336aea700f5b01af8ab6a498b160c9784575d411e6ed6721e8ddb756f7e3646b56d883f15b762
@@ -1,40 +1,30 @@
1
- require 'jekyll'
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll"
2
4
 
3
5
  module Jekyll
4
6
  module Archives
5
7
  # Internal requires
6
- autoload :Archive, 'jekyll-archives/archive'
7
- autoload :VERSION, 'jekyll-archives/version'
8
-
9
- if (Jekyll.const_defined? :Hooks)
10
- Jekyll::Hooks.register :site, :after_reset do |site|
11
- # We need to disable incremental regen for Archives to generate with the
12
- # correct content
13
- site.regenerator.instance_variable_set(:@disabled, true)
14
- end
15
- end
8
+ autoload :Archive, "jekyll-archives/archive"
9
+ autoload :VERSION, "jekyll-archives/version"
16
10
 
17
11
  class Archives < Jekyll::Generator
18
12
  safe true
19
13
 
20
14
  DEFAULTS = {
21
- 'layout' => 'archive',
22
- 'enabled' => [],
23
- 'permalinks' => {
24
- 'year' => '/:year/',
25
- 'month' => '/:year/:month/',
26
- 'day' => '/:year/:month/:day/',
27
- 'tag' => '/tag/:name/',
28
- 'category' => '/category/:name/'
29
- }
30
- }
15
+ "layout" => "archive",
16
+ "enabled" => [],
17
+ "permalinks" => {
18
+ "year" => "/:year/",
19
+ "month" => "/:year/:month/",
20
+ "day" => "/:year/:month/:day/",
21
+ "tag" => "/tag/:name/",
22
+ "category" => "/category/:name/",
23
+ },
24
+ }.freeze
31
25
 
32
26
  def initialize(config = nil)
33
- if config['jekyll-archives'].nil?
34
- @config = DEFAULTS
35
- else
36
- @config = Utils.deep_merge_hashes(DEFAULTS, config['jekyll-archives'])
37
- end
27
+ @config = Utils.deep_merge_hashes(DEFAULTS, config.fetch("jekyll-archives", {}))
38
28
  end
39
29
 
40
30
  def generate(site)
@@ -42,7 +32,7 @@ module Jekyll
42
32
  @posts = site.posts
43
33
  @archives = []
44
34
 
45
- @site.config['jekyll-archives'] = @config
35
+ @site.config["jekyll-archives"] = @config
46
36
 
47
37
  read
48
38
  @site.pages.concat(@archives)
@@ -88,16 +78,16 @@ module Jekyll
88
78
  # Checks if archive type is enabled in config
89
79
  def enabled?(archive)
90
80
  @config["enabled"] == true || @config["enabled"] == "all" || if @config["enabled"].is_a? Array
91
- @config["enabled"].include? archive
92
- end
81
+ @config["enabled"].include? archive
82
+ end
93
83
  end
94
84
 
95
85
  def tags
96
- @site.post_attr_hash('tags')
86
+ @site.post_attr_hash("tags")
97
87
  end
98
88
 
99
89
  def categories
100
- @site.post_attr_hash('categories')
90
+ @site.post_attr_hash("categories")
101
91
  end
102
92
 
103
93
  # Custom `post_attr_hash` method for years
@@ -105,26 +95,26 @@ module Jekyll
105
95
  hash = Hash.new { |h, key| h[key] = [] }
106
96
 
107
97
  # In Jekyll 3, Collection#each should be called on the #docs array directly.
108
- if Jekyll::VERSION >= '3.0.0'
98
+ if Jekyll::VERSION >= "3.0.0"
109
99
  @posts.docs.each { |p| hash[p.date.strftime("%Y")] << p }
110
100
  else
111
101
  @posts.each { |p| hash[p.date.strftime("%Y")] << p }
112
102
  end
113
- hash.values.each { |posts| posts.sort!.reverse! }
103
+ hash.each_value { |posts| posts.sort!.reverse! }
114
104
  hash
115
105
  end
116
106
 
117
107
  def months(year_posts)
118
108
  hash = Hash.new { |h, key| h[key] = [] }
119
109
  year_posts.each { |p| hash[p.date.strftime("%m")] << p }
120
- hash.values.each { |posts| posts.sort!.reverse! }
110
+ hash.each_value { |posts| posts.sort!.reverse! }
121
111
  hash
122
112
  end
123
113
 
124
114
  def days(month_posts)
125
115
  hash = Hash.new { |h, key| h[key] = [] }
126
116
  month_posts.each { |p| hash[p.date.strftime("%d")] << p }
127
- hash.values.each { |posts| posts.sort!.reverse! }
117
+ hash.each_value { |posts| posts.sort!.reverse! }
128
118
  hash
129
119
  end
130
120
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jekyll
2
4
  module Archives
3
5
  class Archive < Jekyll::Page
4
-
5
6
  attr_accessor :posts, :type, :slug
6
7
 
7
8
  # Attributes for Liquid templates
@@ -13,6 +14,7 @@ module Jekyll
13
14
  name
14
15
  path
15
16
  url
17
+ permalink
16
18
  ).freeze
17
19
 
18
20
  # Initialize a new Archive page
@@ -27,12 +29,11 @@ module Jekyll
27
29
  @posts = posts
28
30
  @type = type
29
31
  @title = title
30
- @config = site.config['jekyll-archives']
32
+ @config = site.config["jekyll-archives"]
31
33
 
32
- # Generate slug if tag or category (taken from jekyll/jekyll/features/support/env.rb)
33
- if title.to_s.length
34
- @slug = Utils.slugify(title.to_s)
35
- end
34
+ # Generate slug if tag or category
35
+ # (taken from jekyll/jekyll/features/support/env.rb)
36
+ @slug = Utils.slugify(title) if title.is_a? String
36
37
 
37
38
  # Use ".html" for file extension and url for path
38
39
  @ext = File.extname(relative_path)
@@ -40,7 +41,7 @@ module Jekyll
40
41
  @name = File.basename(relative_path, @ext)
41
42
 
42
43
  @data = {
43
- "layout" => layout
44
+ "layout" => layout,
44
45
  }
45
46
  @content = ""
46
47
  end
@@ -49,17 +50,17 @@ module Jekyll
49
50
  #
50
51
  # Returns the template String.
51
52
  def template
52
- @config['permalinks'][type]
53
+ @config["permalinks"][type]
53
54
  end
54
55
 
55
56
  # The layout to use for rendering
56
57
  #
57
58
  # Returns the layout as a String
58
59
  def layout
59
- if @config['layouts'] && @config['layouts'][type]
60
- @config['layouts'][type]
60
+ if @config["layouts"] && @config["layouts"][type]
61
+ @config["layouts"][type]
61
62
  else
62
- @config['layout']
63
+ @config["layout"]
63
64
  end
64
65
  end
65
66
 
@@ -67,7 +68,7 @@ module Jekyll
67
68
  # desired placeholder replacements. For details see "url.rb".
68
69
  def url_placeholders
69
70
  if @title.is_a? Hash
70
- @title.merge({ :type => @type })
71
+ @title.merge(:type => @type)
71
72
  else
72
73
  { :name => @slug, :type => @type }
73
74
  end
@@ -77,13 +78,17 @@ module Jekyll
77
78
  #
78
79
  # Returns the String url.
79
80
  def url
80
- @url ||= URL.new({
81
- :template => template,
81
+ @url ||= URL.new(
82
+ :template => template,
82
83
  :placeholders => url_placeholders,
83
- :permalink => nil
84
- }).to_s
84
+ :permalink => nil
85
+ ).to_s
85
86
  rescue ArgumentError
86
- raise ArgumentError.new "Template \"#{template}\" provided is invalid."
87
+ raise ArgumentError, "Template \"#{template}\" provided is invalid."
88
+ end
89
+
90
+ def permalink
91
+ data&.is_a?(Hash) && data["permalink"]
87
92
  end
88
93
 
89
94
  # Produce a title object suitable for Liquid based on type of archive.
@@ -91,9 +96,7 @@ module Jekyll
91
96
  # Returns a String (for tag and category archives) and nil for
92
97
  # date-based archives.
93
98
  def title
94
- if @title.is_a? String
95
- @title
96
- end
99
+ @title if @title.is_a? String
97
100
  end
98
101
 
99
102
  # Produce a date object if a date-based archive
@@ -101,7 +104,7 @@ module Jekyll
101
104
  # Returns a Date.
102
105
  def date
103
106
  if @title.is_a? Hash
104
- args = @title.values.map { |s| s.to_i }
107
+ args = @title.values.map(&:to_i)
105
108
  Date.new(*args)
106
109
  end
107
110
  end
@@ -110,14 +113,14 @@ module Jekyll
110
113
  #
111
114
  # Returns the destination relative path String.
112
115
  def relative_path
113
- path = URL.unescape_path(url).gsub(/^\//, '')
114
- path = File.join(path, "index.html") if url =~ /\/$/
116
+ path = URL.unescape_path(url).gsub(%r!^\/!, "")
117
+ path = File.join(path, "index.html") if url =~ %r!\/$!
115
118
  path
116
119
  end
117
120
 
118
121
  # Returns the object as a debug String.
119
122
  def inspect
120
- "#<Jekyll:Archive @type=#{@type.to_s} @title=#{@title} @data=#{@data.inspect}>"
123
+ "#<Jekyll:Archive @type=#{@type} @title=#{@title} @data=#{@data.inspect}>"
121
124
  end
122
125
  end
123
126
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Archives
5
+ VERSION = "2.2.1"
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-archives
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alfred Xing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-18 00:00:00.000000000 Z
11
+ date: 2019-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -16,16 +16,22 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '3.6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '2.4'
29
+ version: '3.6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
- name: rake
34
+ name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
@@ -39,7 +45,7 @@ dependencies:
39
45
  - !ruby/object:Gem::Version
40
46
  version: '0'
41
47
  - !ruby/object:Gem::Dependency
42
- name: rdoc
48
+ name: minitest
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - ">="
@@ -53,7 +59,7 @@ dependencies:
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
55
61
  - !ruby/object:Gem::Dependency
56
- name: shoulda
62
+ name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - ">="
@@ -67,7 +73,35 @@ dependencies:
67
73
  - !ruby/object:Gem::Version
68
74
  version: '0'
69
75
  - !ruby/object:Gem::Dependency
70
- name: minitest
76
+ name: rdoc
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-jekyll
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.9'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.9'
103
+ - !ruby/object:Gem::Dependency
104
+ name: shoulda
71
105
  requirement: !ruby/object:Gem::Requirement
72
106
  requirements:
73
107
  - - ">="
@@ -88,6 +122,7 @@ extra_rdoc_files: []
88
122
  files:
89
123
  - lib/jekyll-archives.rb
90
124
  - lib/jekyll-archives/archive.rb
125
+ - lib/jekyll-archives/version.rb
91
126
  homepage: https://github.com/jekyll/jekyll-archives
92
127
  licenses:
93
128
  - MIT
@@ -100,15 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
135
  requirements:
101
136
  - - ">="
102
137
  - !ruby/object:Gem::Version
103
- version: '0'
138
+ version: 2.3.0
104
139
  required_rubygems_version: !ruby/object:Gem::Requirement
105
140
  requirements:
106
141
  - - ">="
107
142
  - !ruby/object:Gem::Version
108
143
  version: '0'
109
144
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.5.1
145
+ rubygems_version: 3.0.3
112
146
  signing_key:
113
147
  specification_version: 4
114
148
  summary: Post archives for Jekyll.