jekyll-tally-tags 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5903dcfca2ed55cd34e7a86a40ca2565b2aa7981f2a3fe81d04a35d6a2bbe558
4
- data.tar.gz: 4ece7a9e9aaa7ddbf1cfe54efea8f03d7c534c59e273d6f2cb501d71c7131346
3
+ metadata.gz: 34b78495f4983b7c7eba9fdf4214753b26efaad6fe98606ca5c69ada66a6a5aa
4
+ data.tar.gz: 915a7ddb6dfc629796941fdb0ab669722c0b22dea4c3029f2e5f68da63f2ac1f
5
5
  SHA512:
6
- metadata.gz: dfb1fa03b7ced48a5f6ee40cf228602166f4f063a877cc558ad6a61b045e0917b111ac4ce4ac4dc32fc02aa2a0c9afb064b8dac974017b0bb521eeea2704002c
7
- data.tar.gz: 19dc53b00954e5f764310c8ee2438b6d7463dca92ccac0b3b32ca67f03146429030c14586cfb5a5b957737c390729c0885db5469f9cae2648588579ad5a419da
6
+ metadata.gz: 94e15c2fd5e7856b2899ea56bee1ce9b323568cf8312f28e613d562cea8349416b7428df4081edad30295652da672bb76dcdb24ac2e73f8a57ee79306880d945
7
+ data.tar.gz: 6e82474e5d7c83e197294597be8274706b39f398aa9b9fca13a0e22dc8f467a47c52463911d8a43a5a0d48d6b3bf27c6ead03c0ba62decab0081d960ec858544
@@ -8,7 +8,6 @@ module Jekyll
8
8
 
9
9
  autoload :DocsToItems, "jekyll-tally-tags/docs_to_items"
10
10
  autoload :Item, "jekyll-tally-tags/item"
11
- autoload :ItemsToPage, "jekyll-tally-tags/items_to_page"
12
11
  autoload :Methods, "jekyll-tally-tags/methods"
13
12
  autoload :Utils, "jekyll-tally-tags/utils"
14
13
  autoload :BasePage, "jekyll-tally-tags/pages/base_page"
@@ -137,10 +137,17 @@ module Jekyll
137
137
  end
138
138
  end
139
139
  # 把模板内自带有 `keys` 的加入进来
140
- date_hash.each do |date, hash|
141
- hash.each do |temp_key, csv_list|
140
+ date_hash.each do |date, csv_list|
141
+ date_hash[date] = {}
142
+ csv_list.each do |csv|
143
+ # lstrip rstrip 去掉前后空格
144
+ values = csv.gsub(/[,|,|\s]+/, " , ").split(',').each(&:lstrip!).each(&:rstrip!)
145
+ temp_key = values[0]
146
+ if !date_hash[date][temp_key]
147
+ date_hash[date][temp_key] = [csv]
148
+ end
142
149
  if templates[temp_key][KEYS]
143
- csv_list.insert(0, templates[temp_key][KEYS].join(" "))
150
+ date_hash[date][temp_key].insert(0, templates[temp_key][KEYS].join(" "))
144
151
  end
145
152
  end
146
153
  end
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
  module TallyTags
3
3
 
4
-
4
+
5
5
 
6
6
  class YearPage < TallyTags::BasePage
7
7
 
@@ -48,17 +48,18 @@ module Jekyll
48
48
  templates_hash = yml_temp_hash[date]
49
49
  templates_hash.each_key do |temp_keys|
50
50
  temp = temp_keys.keys[0]
51
- content += " #{temp}:\n"
51
+ # content += " #{temp}:\n"
52
52
  keys = temp_keys.values[0]
53
53
  hash = templates_hash[temp_keys]
54
54
  lengths = hash[MAX_LENGTH]
55
55
  # content += " - #{center_values(keys, lengths, sep)}\n"
56
56
  hash[VALUES].each_index do |index|
57
57
  values = hash[VALUES][index]
58
- content += " - #{center_values(values, lengths, sep)}\n"
58
+ content += " - #{center_values(values, lengths, sep)}\n"
59
59
  end
60
- content += "\n"
60
+ # content += "\n"
61
61
  end
62
+ content += "\n"
62
63
  end
63
64
  content += "```"
64
65
  end
@@ -5,7 +5,7 @@ require "jekyll"
5
5
  module Jekyll
6
6
  module TallyTags
7
7
 
8
- VERSION = "0.1.2"
8
+ VERSION = "0.1.3"
9
9
 
10
10
  # Hooks
11
11
  NO_NAME = %r!^(?>.+/)*?(\d{2,4}-\d{1,2}-\d{1,2})(-([^/]*))?(\.[^.]+)$!.freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-tally-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danyow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -54,7 +54,6 @@ files:
54
54
  - lib/jekyll-tally-tags.rb
55
55
  - lib/jekyll-tally-tags/docs_to_items.rb
56
56
  - lib/jekyll-tally-tags/item.rb
57
- - lib/jekyll-tally-tags/items_to_page.rb
58
57
  - lib/jekyll-tally-tags/methods.rb
59
58
  - lib/jekyll-tally-tags/pages/base_page.rb
60
59
  - lib/jekyll-tally-tags/pages/day_page.rb
@@ -1,128 +0,0 @@
1
- # # frozen_string_literal: true
2
- #
3
- # require "jekyll"
4
- #
5
- # module Jekyll
6
- # module TallyTags
7
- #
8
- # class ItemsToPage < Generator
9
- # safe true
10
- # # @param [Configuration] config
11
- # def initialize(config = nil)
12
- # @config = Utils.get_permalink_config(config)
13
- # @enabled = Utils.get_permalink_config(config, ENABLED)
14
- # end
15
- #
16
- # # @param [Site] site
17
- # def generate(site)
18
- # # 判断是否为空
19
- # return if @config.nil?
20
- # # 开始赋值
21
- # @site = site
22
- # @posts = site.posts
23
- # @pages = []
24
- #
25
- # read_all(@config[PERMALINKS], @site.posts.docs)
26
- # # 把所有的拼接到到 `pages` 里面
27
- # @site.pages.concat(@pages)
28
- # # 配置里面也放一份
29
- # @site.config[PAGES] = @pages
30
- # end
31
- #
32
- # # @param [Hash{String => String}] permalinks
33
- # # @param [Array<Document>] scan_docs
34
- # def read_all(permalinks, scan_docs)
35
- # permalinks.each do |key, permalink|
36
- # # 判断 链接是否包含 :xxx :(\w+)
37
- # matches = []
38
- # permalink.scan(/:(\w+)/) { |match| matches << match[0] }
39
- # read_loop(key, {}, Array.new(scan_docs), matches, 0)
40
- # end
41
- # end
42
- #
43
- # # @param [String] permalink_key
44
- # # @param [Hash{Symbol => String}] titles
45
- # # @param [Array<Document>] docs
46
- # # @param [Array<String>] matches
47
- # # @param [Integer] index
48
- # def read_loop(permalink_key, titles, docs, matches, index)
49
- # if index > matches.size - 1
50
- # return
51
- # end
52
- # match = matches[index]
53
- # # 找到对应的 docs
54
- # if DATE_HASH.keys.include?(match)
55
- # docs_hash = date_to_docs_hash(docs, DATE_HASH[match])
56
- # read_any(docs_hash, match.to_sym, permalink_key, titles, matches, index + 1)
57
- # else
58
- # begin
59
- # docs_hash = tags_to_docs_hash(docs, match)
60
- # read_any(docs_hash, match.to_sym, permalink_key, titles, matches, index + 1)
61
- # rescue
62
- # Jekyll.logger.warn CLASSIFY, "没有该keys ':#{match}'"
63
- # end
64
- # end
65
- # end
66
- #
67
- # # @param [Hash{String => Array<Document>}] docs_hash
68
- # # @param [Symbol] symbol
69
- # # @param [String] permalink_key
70
- # # @param [Hash{Symbol => String}] titles
71
- # # @param [Array<String>] matches
72
- # # @param [Integer] index
73
- # def read_any(docs_hash, symbol, permalink_key, titles, matches, index)
74
- # docs_hash.each do |key, docs|
75
- # new_titles = titles.merge({ symbol => key })
76
- # # 开启了该字段 同时 是匹配的最后一项的时候 写入数组
77
- # if enabled?(permalink_key) && index == matches.size
78
- # clz = SinglePage
79
- # case permalink_key
80
- # when YEAR
81
- # clz = YearPage
82
- # when MONTH
83
- # clz = MonthPage
84
- # when DAY
85
- # clz = DayPage
86
- # when WEEK
87
- # clz = WeekPage
88
- # when WEEKS
89
- # clz = WeekPage
90
- # end
91
- # @pages << clz.new(@site, new_titles, permalink_key, docs.keep_if { |doc| doc.data[TEMPLATE] })
92
- # end
93
- # read_loop(permalink_key, new_titles, docs, matches, index)
94
- # end
95
- # end
96
- #
97
- # private
98
- #
99
- # # @param [String] type
100
- # def enabled?(type)
101
- # @enabled == true || @enabled == ALL || (@enabled.is_a?(Array) && @enabled.include?(type))
102
- # end
103
- #
104
- # # @param [Array<Document>] docs
105
- # # @param [String] attr
106
- # # @return [Hash{String => Array<Document>}]
107
- # def tags_to_docs_hash(docs, attr)
108
- # hash = Hash.new { |h, key| h[key] = [] }
109
- # docs.each do |doc|
110
- # doc.data[attr]&.each { |key| hash[key] << doc }
111
- # end
112
- # hash.each_value { |docs| docs.sort!.reverse! }
113
- # hash
114
- # end
115
- #
116
- # # @param [Array<Document>] docs `yaml` 头部信息
117
- # # @param [String] id ISO-8601
118
- # # @return [Hash{String=>Array<Document>}]
119
- # def date_to_docs_hash(docs, id)
120
- # hash = Hash.new { |h, k| h[k] = [] }
121
- # docs.each { |doc| hash[doc.date.strftime(id)] << doc }
122
- # hash.each_value { |docs| docs.sort!.reverse! }
123
- # hash
124
- # end
125
- #
126
- # end
127
- # end
128
- # end