dimples 5.1.0 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/dimples/category.rb +2 -2
- data/lib/dimples/pager.rb +4 -4
- data/lib/dimples/plugin.rb +4 -10
- data/lib/dimples/site.rb +14 -10
- data/lib/dimples/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 838304f8086ccf74e9a4c44feee78027747a3625
|
4
|
+
data.tar.gz: cfa7dc4bbedeb98446526fb1380c49c5070f1d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba760bbb200a9b9464325cc121529ca7616854354e53e4613a923b16f85c11bfe626478bf8df19b124b1b3c68559b777c2b328b9399f1c1a42a588229bc9cc9
|
7
|
+
data.tar.gz: 12484fa4f299017f487b0a95839d5d22c47f6d61b584ab764037ee60f34a20862d7b8b80391e264f4caacdeb501dd7985d519c57d10ce17ffa3594e3d175e600
|
data/lib/dimples/category.rb
CHANGED
data/lib/dimples/pager.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module Dimples
|
4
4
|
# A paginated collection of posts that can be walked forward or backwards.
|
5
5
|
class Pager
|
6
|
+
PER_PAGE_DEFAULT = 10
|
7
|
+
|
6
8
|
include Enumerable
|
7
9
|
|
8
10
|
attr_reader :current_page
|
@@ -14,7 +16,7 @@ module Dimples
|
|
14
16
|
def initialize(url, posts, options = {})
|
15
17
|
@url = url
|
16
18
|
@posts = posts
|
17
|
-
@per_page = options[:per_page] ||
|
19
|
+
@per_page = options[:per_page] || PER_PAGE_DEFAULT
|
18
20
|
@page_prefix = options[:page_prefix] || 'page'
|
19
21
|
@page_count = (posts.length.to_f / @per_page.to_i).ceil
|
20
22
|
|
@@ -22,9 +24,7 @@ module Dimples
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def each(&block)
|
25
|
-
(1..@page_count).each
|
26
|
-
block.yield step_to(index)
|
27
|
-
end
|
27
|
+
(1..@page_count).each { |index| block.yield step_to(index) }
|
28
28
|
end
|
29
29
|
|
30
30
|
def step_to(page)
|
data/lib/dimples/plugin.rb
CHANGED
@@ -12,18 +12,12 @@ module Dimples
|
|
12
12
|
after_page_write
|
13
13
|
].freeze
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.plugins(site)
|
20
|
-
@plugins ||= @subclasses&.map { |subclass| subclass.new(site) }
|
15
|
+
class << self
|
16
|
+
attr_reader :subclasses
|
21
17
|
end
|
22
18
|
|
23
|
-
def self.
|
24
|
-
|
25
|
-
plugin.process(event, item) if plugin.supports_event?(event)
|
26
|
-
end
|
19
|
+
def self.inherited(subclass)
|
20
|
+
(@subclasses ||= []) << subclass
|
27
21
|
end
|
28
22
|
|
29
23
|
def initialize(site)
|
data/lib/dimples/site.rb
CHANGED
@@ -71,8 +71,9 @@ module Dimples
|
|
71
71
|
|
72
72
|
def read_templates
|
73
73
|
@templates = {}
|
74
|
+
template_glob = File.join(@paths[:sources][:templates], '**', '*.*')
|
74
75
|
|
75
|
-
|
76
|
+
Dir.glob(template_glob).each do |path|
|
76
77
|
basename = File.basename(path, File.extname(path))
|
77
78
|
dir_name = File.dirname(path)
|
78
79
|
|
@@ -85,7 +86,9 @@ module Dimples
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def read_posts
|
88
|
-
|
89
|
+
post_glob = File.join(@paths[:sources][:posts], '**', '*.*')
|
90
|
+
|
91
|
+
@posts = Dir.glob(post_glob).sort.map do |path|
|
89
92
|
Post.new(self, path).tap do |post|
|
90
93
|
add_archive_post(post)
|
91
94
|
categorise_post(post)
|
@@ -96,9 +99,8 @@ module Dimples
|
|
96
99
|
end
|
97
100
|
|
98
101
|
def read_pages
|
99
|
-
|
100
|
-
|
101
|
-
end
|
102
|
+
page_glob = File.join(@paths[:sources][:pages], '**', '*.*')
|
103
|
+
@pages = Dir.glob(page_glob).sort.map { |path| Page.new(self, path) }
|
102
104
|
end
|
103
105
|
|
104
106
|
def add_archive_post(post)
|
@@ -264,10 +266,6 @@ module Dimples
|
|
264
266
|
end
|
265
267
|
end
|
266
268
|
|
267
|
-
def globbed_files(path)
|
268
|
-
Dir.glob(File.join(path, '**', '*.*'))
|
269
|
-
end
|
270
|
-
|
271
269
|
def archive_year(year)
|
272
270
|
@archives[:year][year] ||= []
|
273
271
|
end
|
@@ -280,8 +278,14 @@ module Dimples
|
|
280
278
|
@archives[:day]["#{year}-#{month}-#{day}"] ||= []
|
281
279
|
end
|
282
280
|
|
281
|
+
def plugins
|
282
|
+
@plugins ||= Plugin.subclasses&.map { |subclass| subclass.new(self) }
|
283
|
+
end
|
284
|
+
|
283
285
|
def trigger_event(event, item = nil)
|
284
|
-
|
286
|
+
plugins.each do |plugin|
|
287
|
+
plugin.process(event, item) if plugin.supports_event?(event)
|
288
|
+
end
|
285
289
|
end
|
286
290
|
end
|
287
291
|
end
|
data/lib/dimples/version.rb
CHANGED
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: 5.1.
|
4
|
+
version: 5.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -200,9 +200,9 @@ require_paths:
|
|
200
200
|
- lib
|
201
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
202
|
requirements:
|
203
|
-
- - "
|
203
|
+
- - "~>"
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version: '
|
205
|
+
version: '2.4'
|
206
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
208
|
- - ">="
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
212
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.6.14
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: A basic static site generator
|