blogue 0.0.5 → 0.0.6

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: 89bed214ac4b48dc4d477f2bdbf041d3a006b4ee
4
- data.tar.gz: d6ea180fe2ecc223e7ca3b597990d85d50908f8e
3
+ metadata.gz: 1c035ba68580bf4db897979d04f5b744429d515f
4
+ data.tar.gz: 764a4f8f7728b89e13c408f46bc0cbc119ac8b52
5
5
  SHA512:
6
- metadata.gz: f7d9543cb44479549cde5338b52f264feff35e12288a7f558b6979e9cf1f02fbbfa13bc7c5343eea5277bd6a248a47b646ec682ecd8b1e8a396ae939ece378e9
7
- data.tar.gz: c139b854e3542b904dea5e2665643af18937cd98f6effe5104873bd5e2e94d94d1b968dde518679846425c874cc1797d809f003e16d223a7292952ae2ef687b2
6
+ metadata.gz: 6e334339e988a603dfdad08b996b37b6ba20f8e0c15d73bb0a5526d3e0b23494842749df348f11fb6ebfc0af067f5baebe174daa0a5e1da5653c99c1f46bc46d
7
+ data.tar.gz: 2ed10090486942681a1a2769f350ab30706eec6d5d06a8208fa1dbab81150915c2d0ad3d8d4d63830bdb61beed4b85c0e6c7b4cce48b4c66086ee0c4e8f59397
@@ -33,6 +33,14 @@ module Blogue
33
33
  post_b.time <=> post_a.time
34
34
  end
35
35
 
36
+ def load_meta(text)
37
+ YAML.load(
38
+ text.lines.select do |line|
39
+ !!(line[/^<!--\s*meta/]..line[/--!>$/])
40
+ end[1..-2].try(:join, "\n") || ''
41
+ ) || {}
42
+ end
43
+
36
44
  def cache_key
37
45
  "blogue/#{Blogue.blanket_checksum}"
38
46
  end
@@ -77,11 +85,7 @@ module Blogue
77
85
  end
78
86
 
79
87
  def meta
80
- YAML.load(
81
- body.lines.select do |line|
82
- !!(line[/^<!--\s*meta/]..line[/--!>$/])
83
- end[1..-2].try(:join, "\n") || ''
84
- ) || {}
88
+ self.class.load_meta(body)
85
89
  end
86
90
 
87
91
  def cache_key
@@ -1,3 +1,3 @@
1
1
  module Blogue
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/blogue.rb CHANGED
@@ -18,30 +18,34 @@ module Blogue
18
18
  Digest::MD5.hexdigest(checksums.values.sort.join)
19
19
  end
20
20
 
21
+ mattr_accessor :default_markdown_format_handler
22
+ self.default_markdown_format_handler = -> template {
23
+ mdown = ActionView::Template.registered_template_handler(:erb).(template)
24
+ "Kramdown::Document.new(begin;#{mdown};end).to_blogue"
25
+ }
26
+
27
+ mattr_accessor :default_kramdown_codeblock_handler
28
+ self.default_kramdown_codeblock_handler = -> el, indent {
29
+ attr = el.attr.dup
30
+ lang = extract_code_language!(attr)
31
+
32
+ begin
33
+ Rouge.highlight(el.value, lang || 'text', 'html')
34
+ rescue RuntimeError
35
+ Rouge.highlight(el.value, 'text', 'html')
36
+ end
37
+ }
38
+
21
39
  mattr_accessor :markdown_format_handler
22
40
  def self.setup_kramdown_for_handling_md_files
23
41
  require 'kramdown/converter/blogue'
24
-
25
- self.markdown_format_handler ||= -> template {
26
- mdown = ActionView::Template.registered_template_handler(:erb).(template)
27
- "Kramdown::Document.new(begin;#{mdown};end).to_blogue"
28
- }
29
-
42
+ self.markdown_format_handler ||= default_markdown_format_handler
30
43
  ActionView::Template.register_template_handler :md, markdown_format_handler
31
44
  end
32
45
 
33
46
  mattr_accessor :kramdown_codeblock_handler
34
47
  def self.use_rouge_codeblock_handler
35
- self.kramdown_codeblock_handler ||= -> el, indent {
36
- attr = el.attr.dup
37
- lang = extract_code_language!(attr)
38
-
39
- begin
40
- Rouge.highlight(el.value, lang || 'text', 'html')
41
- rescue RuntimeError
42
- Rouge.highlight(el.value, 'text', 'html')
43
- end
44
- }
48
+ self.kramdown_codeblock_handler ||= default_kramdown_codeblock_handler
45
49
  end
46
50
 
47
51
  mattr_accessor :checksums
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails