blogue 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/blogue/post.rb +8 -0
- data/lib/blogue/engine.rb +2 -0
- data/lib/blogue/version.rb +1 -1
- data/lib/blogue.rb +28 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89bed214ac4b48dc4d477f2bdbf041d3a006b4ee
|
4
|
+
data.tar.gz: d6ea180fe2ecc223e7ca3b597990d85d50908f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7d9543cb44479549cde5338b52f264feff35e12288a7f558b6979e9cf1f02fbbfa13bc7c5343eea5277bd6a248a47b646ec682ecd8b1e8a396ae939ece378e9
|
7
|
+
data.tar.gz: c139b854e3542b904dea5e2665643af18937cd98f6effe5104873bd5e2e94d94d1b968dde518679846425c874cc1797d809f003e16d223a7292952ae2ef687b2
|
data/app/models/blogue/post.rb
CHANGED
@@ -32,6 +32,10 @@ module Blogue
|
|
32
32
|
def sort_posts(post_a, post_b)
|
33
33
|
post_b.time <=> post_a.time
|
34
34
|
end
|
35
|
+
|
36
|
+
def cache_key
|
37
|
+
"blogue/#{Blogue.blanket_checksum}"
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
attr_reader :path
|
@@ -80,6 +84,10 @@ module Blogue
|
|
80
84
|
) || {}
|
81
85
|
end
|
82
86
|
|
87
|
+
def cache_key
|
88
|
+
"blogue/posts/#{id}/#{Blogue.checksums[id]}"
|
89
|
+
end
|
90
|
+
|
83
91
|
def to_partial_path
|
84
92
|
'posts/post'
|
85
93
|
end
|
data/lib/blogue/engine.rb
CHANGED
data/lib/blogue/version.rb
CHANGED
data/lib/blogue.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require 'blogue/engine'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Blogue
|
4
|
-
mattr_accessor :posts_path
|
5
|
-
mattr_accessor :assets_path
|
6
|
-
mattr_accessor :markdown_format_handler
|
7
|
-
mattr_accessor :kramdown_codeblock_handler
|
8
5
|
mattr_accessor :author_name
|
6
|
+
mattr_accessor :assets_path
|
9
7
|
|
8
|
+
mattr_accessor :posts_path
|
10
9
|
self.posts_path = 'app/posts'
|
11
10
|
|
11
|
+
mattr_accessor :checksum_calc
|
12
|
+
self.checksum_calc = -> post do
|
13
|
+
Digest::MD5.hexdigest([post.id, post.author_name, post.body].join)
|
14
|
+
end
|
15
|
+
|
16
|
+
mattr_accessor :blanket_checksum_calc
|
17
|
+
self.blanket_checksum_calc = -> do
|
18
|
+
Digest::MD5.hexdigest(checksums.values.sort.join)
|
19
|
+
end
|
20
|
+
|
21
|
+
mattr_accessor :markdown_format_handler
|
12
22
|
def self.setup_kramdown_for_handling_md_files
|
13
23
|
require 'kramdown/converter/blogue'
|
14
24
|
|
@@ -20,6 +30,7 @@ module Blogue
|
|
20
30
|
ActionView::Template.register_template_handler :md, markdown_format_handler
|
21
31
|
end
|
22
32
|
|
33
|
+
mattr_accessor :kramdown_codeblock_handler
|
23
34
|
def self.use_rouge_codeblock_handler
|
24
35
|
self.kramdown_codeblock_handler ||= -> el, indent {
|
25
36
|
attr = el.attr.dup
|
@@ -32,4 +43,16 @@ module Blogue
|
|
32
43
|
end
|
33
44
|
}
|
34
45
|
end
|
46
|
+
|
47
|
+
mattr_accessor :checksums
|
48
|
+
def self.set_checksums
|
49
|
+
self.checksums = Hash[
|
50
|
+
Post.all.map{ |p| [p.id, checksum_calc.(p)] }
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
mattr_accessor :blanket_checksum
|
55
|
+
def self.set_blanket_checksum
|
56
|
+
self.blanket_checksum = blanket_checksum_calc.()
|
57
|
+
end
|
35
58
|
end
|