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.
@@ -1,21 +1,23 @@
1
1
  class BlueCloth
2
2
 
3
- def transform_code_blocks( str, rs )
4
- @log.debug " Transforming code blocks"
3
+ attr_accessor :code_css
5
4
 
6
- str.gsub(CodeBlockRegexp) {|block|
7
- codeblock = $1
8
- remainder = $2
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 => :style, :line_numbers => :list).delete("\n"), remainder]
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
- end
20
+ }
21
+ end
20
22
 
21
23
  end
@@ -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
- if path.match(/categories\/(.*)/)
38
- active = $1 == urlify(@category) if @category
39
- active = $1 == urlify(@post.category) if @post
40
- else
41
- active = request.path_info == path
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
- RubyPants.new(BlueCloth.new(src).to_html).to_html
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><%= strip_tags post.summary %></description>
15
- <author><%= @author || @blog.author %></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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
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-06 00:00:00 Z
18
+ date: 2011-06-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: BlueCloth