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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 538d08c80ac9f6a250c630f9b1fa1c8fdaed7bed
4
- data.tar.gz: e0405b6226aab9e77bf53f41d3bc4cc613de3842
3
+ metadata.gz: 89bed214ac4b48dc4d477f2bdbf041d3a006b4ee
4
+ data.tar.gz: d6ea180fe2ecc223e7ca3b597990d85d50908f8e
5
5
  SHA512:
6
- metadata.gz: 7d65af9705190abb94a95e4a52a9ae05eafe327a00ac3c61d7553068e2780301fd94407563e6cde17dd4c72ae13852267179c5961535a840356e5eae16bc9b37
7
- data.tar.gz: a7aac15e81f7eb8ad6096bd664327d5eb776b9d118845aab4777bdc3a8ad4abb88255a3b8fa8af05f76dba181dc1786919ae3c6b018b7d11dedab2c2c3e48a3b
6
+ metadata.gz: f7d9543cb44479549cde5338b52f264feff35e12288a7f558b6979e9cf1f02fbbfa13bc7c5343eea5277bd6a248a47b646ec682ecd8b1e8a396ae939ece378e9
7
+ data.tar.gz: c139b854e3542b904dea5e2665643af18937cd98f6effe5104873bd5e2e94d94d1b968dde518679846425c874cc1797d809f003e16d223a7292952ae2ef687b2
@@ -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
@@ -14,6 +14,8 @@ module Blogue
14
14
  if defined?(Kramdown)
15
15
  Blogue.setup_kramdown_for_handling_md_files
16
16
  Blogue.use_rouge_codeblock_handler if defined?(Rouge)
17
+ Blogue.set_checksums
18
+ Blogue.set_blanket_checksum
17
19
  end
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module Blogue
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/blogue.rb CHANGED
@@ -1,14 +1,24 @@
1
- require "blogue/engine"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak