dimples 5.5.0 → 5.5.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
2
  SHA1:
3
- metadata.gz: 347bd6a8efb9b677218b6f8ed69e3888fbf3ac2b
4
- data.tar.gz: 1b7886a6af98d37c50d3538b3f180c04a7b05a91
3
+ metadata.gz: 523ca9490b506eb7f2c4da685e85809ec650f4a1
4
+ data.tar.gz: 5b40db0b29c2e846c1ed45f1a7bf9d0685244543
5
5
  SHA512:
6
- metadata.gz: e880ddc6967301841abf9ff274e7082f9b7320f020bb0c87e48f4aad3795eaff97ecda8b33e96647486fac8696aa6ea6bb2531341c3525a37043959fbc2e4565
7
- data.tar.gz: b744697a3b9566a3f2e029be3bb239182640df0e21834a6b5d5cc5d96a4026ebc4a5724ef2a29c499c9a149d3ed0941218e4c132d0955e365abac5f0ac811b10
6
+ metadata.gz: 644e0fcdfe86e59cb76175297ffc29fbc7655f94ae112c27338d84b971634cfff0ec6816a69d14a5e766fa7b33df954492700f1ce419b152469e1c1e82e8f620
7
+ data.tar.gz: 71625d1493f0b6731e56160e3b06ff6f65bb598aa1baf2e40db8b60b19888fe2d7974596e57e9264ca460dd5a60edbe175d37cd5dfae989540b356bce1d43f43
data/lib/dimples/site.rb CHANGED
@@ -9,6 +9,7 @@ module Dimples
9
9
  attr_reader :paths
10
10
  attr_reader :posts
11
11
  attr_reader :pages
12
+ attr_reader :archives
12
13
  attr_reader :templates
13
14
  attr_reader :latest_post
14
15
 
@@ -54,7 +55,7 @@ module Dimples
54
55
 
55
56
  publish_posts
56
57
  publish_pages
57
- publish_archives
58
+ publish_archives if @config.generation.year_archives
58
59
  publish_categories if @config.generation.categories
59
60
 
60
61
  trigger_event(:after_publishing)
@@ -67,7 +68,7 @@ module Dimples
67
68
  private
68
69
 
69
70
  def prepare
70
- @archives = { year: {}, month: {}, day: {} }
71
+ @archives = { year: {} }
71
72
 
72
73
  @categories = {}
73
74
  @templates = {}
@@ -114,9 +115,9 @@ module Dimples
114
115
  end
115
116
 
116
117
  def add_archive_post(post)
117
- archive_year(post.year) << post
118
- archive_month(post.year, post.month) << post
119
- archive_day(post.year, post.month, post.day) << post
118
+ archive_year(post.year)[:posts] << post
119
+ archive_month(post.year, post.month)[:posts] << post
120
+ archive_day(post.year, post.month, post.day)[:posts] << post
120
121
  end
121
122
 
122
123
  def categorise_post(post)
@@ -160,13 +161,13 @@ module Dimples
160
161
 
161
162
  publish_feeds(@posts, @paths[:output]) if @config.generation.main_feed
162
163
 
163
- if @config.generation.paginated_posts
164
- paginate_posts(
165
- @posts,
166
- File.join(@paths[:output], @config.paths.paginated_posts),
167
- @config.layouts.paginated_post
168
- )
169
- end
164
+ return unless @config.generation.paginated_posts
165
+
166
+ paginate_posts(
167
+ @posts,
168
+ File.join(@paths[:output], @config.paths.paginated_posts),
169
+ @config.layouts.paginated_post
170
+ )
170
171
  end
171
172
 
172
173
  def publish_pages
@@ -189,30 +190,47 @@ module Dimples
189
190
  end
190
191
 
191
192
  def publish_archives
192
- %w[year month day].each do |date_type|
193
- next unless @config.generation["#{date_type}_archives"]
194
- publish_date_archive(date_type.to_sym)
195
- end
196
- end
193
+ @archives[:year].each do |year, year_archive|
194
+ publish_date_archive(year)
195
+ next unless @config.generation.month_archives
197
196
 
198
- def publish_date_archive(date_type)
199
- @archives[date_type].each do |date, posts|
200
- date_parts = date.split('-')
201
- path = File.join(@paths[:output], @config.paths.archives, date_parts)
197
+ year_archive[:month].each do |month, month_archive|
198
+ publish_date_archive(year, month)
199
+ next unless @config.generation.day_archives
202
200
 
203
- paginate_posts(
204
- posts.reverse,
205
- path,
206
- @config.layouts.date_archive,
207
- page: {
208
- title: posts[0].date.strftime(@config.date_formats[date_type]),
209
- archive_date: posts[0].date,
210
- archive_type: date_type
211
- }
212
- )
201
+ month_archive[:day].each do |day, _|
202
+ publish_date_archive(year, month, day)
203
+ end
204
+ end
213
205
  end
214
206
  end
215
207
 
208
+ def publish_date_archive(year, month = nil, day = nil)
209
+ date_type = if day
210
+ 'day'
211
+ elsif month
212
+ 'month'
213
+ else
214
+ 'year'
215
+ end
216
+
217
+ date_parts = [year, month, day].compact
218
+ path = File.join(@paths[:output], @config.paths.archives, date_parts)
219
+
220
+ posts = archive(year, month, day)[:posts]
221
+
222
+ paginate_posts(
223
+ posts.reverse,
224
+ path,
225
+ @config.layouts.date_archive,
226
+ page: {
227
+ title: posts[0].date.strftime(@config.date_formats[date_type]),
228
+ archive_date: posts[0].date,
229
+ archive_type: date_type
230
+ }
231
+ )
232
+ end
233
+
216
234
  def publish_categories
217
235
  @categories.each_value do |category|
218
236
  path = File.join(
@@ -276,16 +294,34 @@ module Dimples
276
294
  end
277
295
  end
278
296
 
297
+ def archive(year, month = nil, day = nil)
298
+ if day
299
+ archive_day(year, month, day)
300
+ elsif month
301
+ archive_month(year, month)
302
+ else
303
+ archive_year(year)
304
+ end
305
+ end
306
+
279
307
  def archive_year(year)
280
- @archives[:year][year] ||= []
308
+ @archives[:year][year.to_s] ||= {
309
+ month: {},
310
+ posts: []
311
+ }
281
312
  end
282
313
 
283
314
  def archive_month(year, month)
284
- @archives[:month]["#{year}-#{month}"] ||= []
315
+ archive_year(year)[:month][month.to_s] ||= {
316
+ day: {},
317
+ posts: []
318
+ }
285
319
  end
286
320
 
287
321
  def archive_day(year, month, day)
288
- @archives[:day]["#{year}-#{month}-#{day}"] ||= []
322
+ archive_month(year, month)[:day][day.to_s] ||= {
323
+ posts: []
324
+ }
289
325
  end
290
326
 
291
327
  def plugins
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '5.5.0'
4
+ VERSION = '5.5.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 5.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan