jekyll-archives-v2 0.0.6 → 0.0.7
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 +4 -4
- data/LICENSE +21 -0
- data/lib/jekyll-archives-v2/archive.rb +7 -6
- data/lib/jekyll-archives-v2/page_drop.rb +2 -1
- data/lib/jekyll-archives-v2/version.rb +1 -1
- data/lib/jekyll-archives-v2.rb +36 -32
- metadata +5 -88
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 754709d370320a7e9e7a2036aca0dcec025f89674be854b89f6e588d6e1b2d4a
|
|
4
|
+
data.tar.gz: 5fdfed2761628f0fc89c1136072b3d6c4df9c529f90f4d96fcd5c8fb20809fe6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2b8a5bc2179dcab6729b07646405c233b51169a70211dd6ac74b440b246860677ffe097c30a40b6f4381314ba7494cbb0f0b8941c83184ecfa6b7e5e99ee536
|
|
7
|
+
data.tar.gz: a02fd9b0b5d1fe9cd177db5961bc8206a6614b05f2312df067a8554f210af6248eec64edf77de5b6b4b39ddb0d6069886bb6bcae66726b49df2320776612d050
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present George Corrêa de Araújo and the jekyll-archives-v2 contributors
|
|
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.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
require "active_support/inflector"
|
|
3
4
|
|
|
4
5
|
module Jekyll
|
|
5
6
|
module ArchivesV2
|
|
@@ -28,8 +29,8 @@ module Jekyll
|
|
|
28
29
|
# collection_name - The name of the collection.
|
|
29
30
|
# documents - The array of documents that belong in this archive.
|
|
30
31
|
def initialize(site, title, type, collection_name, documents)
|
|
31
|
-
@site
|
|
32
|
-
@documents
|
|
32
|
+
@site = site
|
|
33
|
+
@documents = documents
|
|
33
34
|
@type = type
|
|
34
35
|
@title = title
|
|
35
36
|
@collection_name = collection_name
|
|
@@ -81,11 +82,11 @@ module Jekyll
|
|
|
81
82
|
:permalink => nil
|
|
82
83
|
).to_s
|
|
83
84
|
rescue ArgumentError
|
|
84
|
-
raise ArgumentError, "Template
|
|
85
|
+
raise ArgumentError, "Template #{template.inspect} provided is invalid."
|
|
85
86
|
end
|
|
86
87
|
|
|
87
88
|
def permalink
|
|
88
|
-
data
|
|
89
|
+
data.is_a?(Hash) && data["permalink"]
|
|
89
90
|
end
|
|
90
91
|
|
|
91
92
|
# Produce a title object suitable for Liquid based on type of archive.
|
|
@@ -93,7 +94,7 @@ module Jekyll
|
|
|
93
94
|
# Returns a String (for tag and category archives) and nil for
|
|
94
95
|
# date-based archives.
|
|
95
96
|
def title
|
|
96
|
-
@title if @title.is_a?
|
|
97
|
+
@title if @title.is_a?(String)
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
# Produce a date object if a date-based archive
|
|
@@ -7,7 +7,8 @@ module Jekyll
|
|
|
7
7
|
|
|
8
8
|
mutable false
|
|
9
9
|
|
|
10
|
-
def_delegators :@obj, :collection_name, :documents, :type, :title, :date, :name, :path, :url,
|
|
10
|
+
def_delegators :@obj, :collection_name, :documents, :type, :title, :date, :name, :path, :url,
|
|
11
|
+
:permalink
|
|
11
12
|
private def_delegator :@obj, :data, :fallback_data
|
|
12
13
|
end
|
|
13
14
|
end
|
data/lib/jekyll-archives-v2.rb
CHANGED
|
@@ -11,18 +11,19 @@ module Jekyll
|
|
|
11
11
|
|
|
12
12
|
class Archives < Jekyll::Generator
|
|
13
13
|
safe true
|
|
14
|
+
DATE_ENABLES = %w(year month day).freeze
|
|
14
15
|
|
|
15
16
|
def initialize(config = {})
|
|
16
17
|
defaults = {}
|
|
17
|
-
config.fetch("collections", {}).each do |name,
|
|
18
|
+
config.fetch("collections", {}).each do |name, _collection|
|
|
18
19
|
defaults[name] = {
|
|
19
20
|
"layout" => "archive",
|
|
20
21
|
"enabled" => [],
|
|
21
22
|
"permalinks" => {
|
|
22
|
-
"year"
|
|
23
|
-
"month"
|
|
24
|
-
"day"
|
|
25
|
-
"tags"
|
|
23
|
+
"year" => "/:collection/:year/",
|
|
24
|
+
"month" => "/:collection/:year/:month/",
|
|
25
|
+
"day" => "/:collection/:year/:month/:day/",
|
|
26
|
+
"tags" => "/:collection/:type/:name/",
|
|
26
27
|
},
|
|
27
28
|
}
|
|
28
29
|
end
|
|
@@ -47,7 +48,7 @@ module Jekyll
|
|
|
47
48
|
@site.config["jekyll-archives"] = @config
|
|
48
49
|
|
|
49
50
|
# loop through collections keys and read them
|
|
50
|
-
@config.each do |collection_name,
|
|
51
|
+
@config.each do |collection_name, _collection_config|
|
|
51
52
|
read(collection_name)
|
|
52
53
|
end
|
|
53
54
|
|
|
@@ -58,19 +59,23 @@ module Jekyll
|
|
|
58
59
|
# Read archive data from collection
|
|
59
60
|
def read(collection)
|
|
60
61
|
if @config[collection]["enabled"].is_a?(Array)
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
use_year = @config[collection]["enabled"].include?("year")
|
|
63
|
+
use_month = @config[collection]["enabled"].include?("month")
|
|
64
|
+
use_day = @config[collection]["enabled"].include?("day")
|
|
65
|
+
|
|
66
|
+
if use_year || use_month || use_day
|
|
67
|
+
read_dates(collection, :use_year => use_year, :use_month => use_month, :use_day => use_day)
|
|
63
68
|
end
|
|
64
69
|
|
|
65
70
|
# read all attributes that are not year, month, or day
|
|
66
|
-
attributes = @config[collection]["enabled"].
|
|
71
|
+
attributes = @config[collection]["enabled"].reject { |attr| DATE_ENABLES.include?(attr) }
|
|
67
72
|
|
|
68
73
|
attributes.each do |attr|
|
|
69
74
|
read_attrs(collection, attr)
|
|
70
75
|
end
|
|
71
76
|
|
|
72
77
|
elsif @config[collection]["enabled"] == true || @config[collection]["enabled"] == "all"
|
|
73
|
-
read_dates(collection)
|
|
78
|
+
read_dates(collection, :use_year => true, :use_month => true, :use_day => true)
|
|
74
79
|
|
|
75
80
|
# create a list of all attributes
|
|
76
81
|
attributes = @collections[collection].docs.flat_map { |doc| doc.data.keys }.uniq
|
|
@@ -89,23 +94,28 @@ module Jekyll
|
|
|
89
94
|
end
|
|
90
95
|
end
|
|
91
96
|
|
|
92
|
-
def read_dates(collection)
|
|
97
|
+
def read_dates(collection, use_year: false, use_month: false, use_day: false)
|
|
93
98
|
years(@collections[collection]).each do |year, y_documents|
|
|
94
|
-
|
|
99
|
+
if use_year
|
|
100
|
+
@archives << Archive.new(@site, { :year => year }, "year", collection, y_documents)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
next unless use_month || use_day
|
|
104
|
+
|
|
95
105
|
months(y_documents).each do |month, m_documents|
|
|
96
|
-
|
|
106
|
+
if use_month
|
|
107
|
+
@archives << Archive.new(@site, { :year => year, :month => month }, "month", collection, m_documents)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
next unless use_day
|
|
111
|
+
|
|
97
112
|
days(m_documents).each do |day, d_documents|
|
|
98
|
-
|
|
113
|
+
@archives << Archive.new(@site, { :year => year, :month => month, :day => day }, "day", collection, d_documents)
|
|
99
114
|
end
|
|
100
115
|
end
|
|
101
116
|
end
|
|
102
117
|
end
|
|
103
118
|
|
|
104
|
-
# Checks if archive type is enabled in config
|
|
105
|
-
def enabled?(collection, archive)
|
|
106
|
-
@config[collection]["enabled"] == true || @config[collection]["enabled"] == "all" || (@config[collection]["enabled"].is_a?(Array) && @config[collection]["enabled"].include?(archive))
|
|
107
|
-
end
|
|
108
|
-
|
|
109
119
|
# Custom `post_attr_hash` method for years
|
|
110
120
|
def years(documents)
|
|
111
121
|
date_attr_hash(documents.docs, "%Y")
|
|
@@ -123,17 +133,6 @@ module Jekyll
|
|
|
123
133
|
|
|
124
134
|
private
|
|
125
135
|
|
|
126
|
-
# Initialize a new Archive page and append to base array if the associated date `type`
|
|
127
|
-
# has been enabled by configuration.
|
|
128
|
-
#
|
|
129
|
-
# meta - A Hash of the year / month / day as applicable for date.
|
|
130
|
-
# type - The type of date archive.
|
|
131
|
-
# collection - the name of the collection
|
|
132
|
-
# documents - The array of documents that belong in the date archive.
|
|
133
|
-
def append_enabled_date_type(meta, type, collection, documents)
|
|
134
|
-
@archives << Archive.new(@site, meta, type, collection, documents) if enabled?(collection, type)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
136
|
# Custom `post_attr_hash` for date type archives.
|
|
138
137
|
#
|
|
139
138
|
# documents - Array of documents to be considered for archiving.
|
|
@@ -141,7 +140,7 @@ module Jekyll
|
|
|
141
140
|
def date_attr_hash(documents, id)
|
|
142
141
|
hash = Hash.new { |hsh, key| hsh[key] = [] }
|
|
143
142
|
documents.each { |document| hash[document.date.strftime(id)] << document }
|
|
144
|
-
hash.each_value { |
|
|
143
|
+
hash.each_value { |documents_in_hsh| documents_in_hsh.sort!.reverse! }
|
|
145
144
|
hash
|
|
146
145
|
end
|
|
147
146
|
|
|
@@ -153,7 +152,12 @@ module Jekyll
|
|
|
153
152
|
# Build a hash map based on the specified document attribute ( doc_attr =>
|
|
154
153
|
# array of elements from collection ) then sort each array in reverse order.
|
|
155
154
|
hash = Hash.new { |h, key| h[key] = [] }
|
|
156
|
-
documents.docs.each
|
|
155
|
+
documents.docs.each do |document|
|
|
156
|
+
attr_value = document.data[doc_attr]
|
|
157
|
+
next if attr_value.nil?
|
|
158
|
+
attr_value = [attr_value] if attr_value.is_a?(String)
|
|
159
|
+
attr_value.each { |t| hash[t] << document }
|
|
160
|
+
end
|
|
157
161
|
hash.each_value { |documents| documents.sort!.reverse! }
|
|
158
162
|
hash
|
|
159
163
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-archives-v2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- George Corrêa de Araújo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|
|
@@ -44,96 +44,13 @@ dependencies:
|
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: '0'
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: bundler
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
54
|
-
type: :development
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - ">="
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '0'
|
|
61
|
-
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: minitest
|
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - ">="
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0'
|
|
68
|
-
type: :development
|
|
69
|
-
prerelease: false
|
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0'
|
|
75
|
-
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: rake
|
|
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: rdoc
|
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - ">="
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '0'
|
|
96
|
-
type: :development
|
|
97
|
-
prerelease: false
|
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - ">="
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0'
|
|
103
|
-
- !ruby/object:Gem::Dependency
|
|
104
|
-
name: rubocop-jekyll
|
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - "~>"
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0.9'
|
|
110
|
-
type: :development
|
|
111
|
-
prerelease: false
|
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - "~>"
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0.9'
|
|
117
|
-
- !ruby/object:Gem::Dependency
|
|
118
|
-
name: shoulda
|
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - ">="
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0'
|
|
124
|
-
type: :development
|
|
125
|
-
prerelease: false
|
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - ">="
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0'
|
|
131
47
|
description: Automatically generate collections archives by dates, tags, and categories.
|
|
132
48
|
email:
|
|
133
49
|
executables: []
|
|
134
50
|
extensions: []
|
|
135
51
|
extra_rdoc_files: []
|
|
136
52
|
files:
|
|
53
|
+
- LICENSE
|
|
137
54
|
- lib/jekyll-archives-v2.rb
|
|
138
55
|
- lib/jekyll-archives-v2/archive.rb
|
|
139
56
|
- lib/jekyll-archives-v2/page_drop.rb
|
|
@@ -154,14 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
154
71
|
requirements:
|
|
155
72
|
- - ">="
|
|
156
73
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: 2.
|
|
74
|
+
version: 2.7.0
|
|
158
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
76
|
requirements:
|
|
160
77
|
- - ">="
|
|
161
78
|
- !ruby/object:Gem::Version
|
|
162
79
|
version: '0'
|
|
163
80
|
requirements: []
|
|
164
|
-
rubygems_version: 3.
|
|
81
|
+
rubygems_version: 3.4.20
|
|
165
82
|
signing_key:
|
|
166
83
|
specification_version: 4
|
|
167
84
|
summary: Collections archives for Jekyll.
|