shinmun 1.0.1 → 1.0.2
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.
- data/lib/shinmun/bluecloth_coderay.rb +10 -8
- data/lib/shinmun/helpers.rb +8 -5
- data/lib/shinmun/post.rb +4 -2
- data/templates/index.rxml +2 -2
- metadata +4 -4
@@ -1,21 +1,23 @@
|
|
1
1
|
class BlueCloth
|
2
2
|
|
3
|
-
|
4
|
-
@log.debug " Transforming code blocks"
|
3
|
+
attr_accessor :code_css
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def transform_code_blocks( str, rs )
|
6
|
+
@log.debug " Transforming code blocks"
|
7
|
+
|
8
|
+
str.gsub(CodeBlockRegexp) {|block|
|
9
|
+
codeblock = $1
|
10
|
+
remainder = $2
|
9
11
|
|
10
12
|
# Generate the codeblock
|
11
13
|
if codeblock =~ /^(?:[ ]{4}|\t)@@(.*?)\n\n(.*)\n\n/m
|
12
14
|
"\n\n<pre class='highlight'>%s</pre>\n\n%s" %
|
13
|
-
[CodeRay.scan(outdent($2), $1).html(:css => :
|
15
|
+
[CodeRay.scan(outdent($2), $1).html(:css => (code_css || :class), :line_numbers => :list).delete("\n"), remainder]
|
14
16
|
else
|
15
17
|
"\n\n<pre><code>%s\n</code></pre>\n\n%s" %
|
16
18
|
[encode_code(outdent(codeblock), rs).rstrip, remainder]
|
17
19
|
end
|
18
|
-
|
19
|
-
|
20
|
+
}
|
21
|
+
end
|
20
22
|
|
21
23
|
end
|
data/lib/shinmun/helpers.rb
CHANGED
@@ -34,11 +34,14 @@ module Shinmun
|
|
34
34
|
|
35
35
|
# Render a link for the navigation bar.
|
36
36
|
def navi_link(text, path)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
active = request.path_info == path
|
38
|
+
|
39
|
+
if path.match(/categories\/(.*)/)
|
40
|
+
category = $1
|
41
|
+
if request.path.match(/(\d+)\/(\d+)\/(.*)/)
|
42
|
+
post = posts_by_date[$1.to_i][$2.to_i][$3]
|
43
|
+
active ||= category == urlify(post.category) if post
|
44
|
+
end
|
42
45
|
end
|
43
46
|
|
44
47
|
link_to text, path, :class => active ? 'active' : nil
|
data/lib/shinmun/post.rb
CHANGED
@@ -115,14 +115,16 @@ module Shinmun
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# Transform the body of this post. Defaults to Markdown.
|
118
|
-
def transform(src)
|
118
|
+
def transform(src, options={})
|
119
119
|
case type
|
120
120
|
when 'html'
|
121
121
|
RubyPants.new(src).to_html
|
122
122
|
when 'tt'
|
123
123
|
RubyPants.new(RedCloth.new(src).to_html).to_html
|
124
124
|
else
|
125
|
-
|
125
|
+
bluecloth = BlueCloth.new(src)
|
126
|
+
bluecloth.code_css = options[:code_css]
|
127
|
+
RubyPants.new(bluecloth.to_html).to_html
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
data/templates/index.rxml
CHANGED
@@ -11,8 +11,8 @@
|
|
11
11
|
<item>
|
12
12
|
<title><%= post.title %></title>
|
13
13
|
<category><%= post.category %></category>
|
14
|
-
<description
|
15
|
-
<author><%= @
|
14
|
+
<description><![CDATA[ <%= post.transform(post.body, :code_css => :style) %>]]></description>
|
15
|
+
<author><%= @blog.author %></author>
|
16
16
|
<link><%= @blog.url %><%= post_path post %></link>
|
17
17
|
<pubDate><%= rfc822 post.date %></pubDate>
|
18
18
|
</item>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shinmun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthias Georgi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: BlueCloth
|