dimples 2.0.1 → 2.1.0

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
  SHA1:
3
- metadata.gz: b735e5c1923e5031dcf45fcb806258bf9f54edcd
4
- data.tar.gz: 8b82d836b87a8d3cab0a4c2c44b64bd37782670f
3
+ metadata.gz: bb07e2dae3e97f99ebb95ea5705b64cb983aa0b0
4
+ data.tar.gz: 7d392ce9d2675950095c3c8f73ed79d1548b2c41
5
5
  SHA512:
6
- metadata.gz: 04b49469ca3ec690671015dcc885553be7d2f728f48b3a14da141e81f40b60cdf0441c423c3369608e2a6369b563a4a6be21942fdaeddf68fefc21f8e4e42ad3
7
- data.tar.gz: 9fac79f506828681abb38006beb7efaaf1cf71554499c8670348a27327ef09e14b0ce3f9c87d9fe08e44986fafb5eba7e702cffa6457170885bc1d8395c1d507
6
+ metadata.gz: 6e672a6cb580456ea3c71a0dc60dbf97ad07212bf709c88a50278868c5341af9dea16603a8e058cdd44d66f8a1494cdcb3427b899e5af118fa57aa7a70646215
7
+ data.tar.gz: 738a445ec92f50848dca3a16512cba0856ddab3a5dc30d15139c63361f4d8a143d723e513da7dabf2bcc0177ddb6455c3380a22da460fc644dd71a22fbd0c505
@@ -13,6 +13,7 @@ require 'dimples/frontable'
13
13
  require 'dimples/writeable'
14
14
  require 'dimples/renderable'
15
15
 
16
+ require 'dimples/category'
16
17
  require 'dimples/configuration'
17
18
  require 'dimples/page'
18
19
  require 'dimples/post'
@@ -0,0 +1,13 @@
1
+ module Dimples
2
+ class Category
3
+ attr_accessor :name
4
+ attr_accessor :slug
5
+ attr_accessor :posts
6
+
7
+ def initialize(name, slug)
8
+ @name = name
9
+ @slug = slug
10
+ @posts = []
11
+ end
12
+ end
13
+ end
@@ -107,7 +107,12 @@ module Dimples
107
107
  next if post.draft
108
108
 
109
109
  post.categories.each do |slug|
110
- (@categories[slug] ||= []) << post
110
+ unless @categories[slug]
111
+ name = @config['category_names'][slug] || slug.capitalize
112
+ @categories[slug] = Dimples::Category.new(name, slug)
113
+ end
114
+
115
+ @categories[slug].posts << post
111
116
  end
112
117
 
113
118
  archive_year(post.year) << post
@@ -195,18 +200,17 @@ module Dimples
195
200
  def generate_categories
196
201
  Dimples.logger.debug_generation('category pages', @categories.length) if @config['verbose_logging']
197
202
 
198
- @categories.each do |slug, posts|
199
- generate_category(slug, posts)
203
+ @categories.each_value do |category|
204
+ generate_category(category)
200
205
  end
201
206
  end
202
207
 
203
- def generate_category(slug, posts)
204
- name = @config['category_names'][slug] || slug.capitalize
205
- paths = [@output_paths[:categories], slug]
208
+ def generate_category(category)
209
+ paths = [@output_paths[:categories], category.slug]
206
210
  layout = @config['layouts']['category']
207
- context = { category: slug }
211
+ context = { category: category.slug }
208
212
 
209
- paginate(posts: posts, title: name, paths: paths, layout: layout, context: context)
213
+ paginate(posts: category.posts, title: category.name, paths: paths, layout: layout, context: context)
210
214
  end
211
215
 
212
216
  def generate_archives
@@ -256,11 +260,11 @@ module Dimples
256
260
  end
257
261
 
258
262
  def generate_category_feeds
259
- @categories.each do |slug, posts|
260
- path = File.join(@output_paths[:categories], slug)
261
- posts = posts[0..@config['pagination']['per_page'] - 1]
263
+ @categories.each_value do |category|
264
+ path = File.join(@output_paths[:categories], category.slug)
265
+ posts = category.posts[0..@config['pagination']['per_page'] - 1]
262
266
 
263
- generate_feed(path, posts: posts, category: slug)
267
+ generate_feed(path, posts: category.posts, category: category.slug)
264
268
  end
265
269
  end
266
270
 
@@ -1,3 +1,3 @@
1
1
  module Dimples
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-26 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - bin/dimples
120
120
  - lib/dimples.rb
121
+ - lib/dimples/category.rb
121
122
  - lib/dimples/configuration.rb
122
123
  - lib/dimples/errors.rb
123
124
  - lib/dimples/frontable.rb