Permalink
Browse files

page styles for coderay now via class and style only for rss

  • Loading branch information...
1 parent 9884514 commit 268c261a1f2a1483e0b69a49f1caa9eb4654c7f2 @georgi committed Jun 19, 2011
Showing with 25 additions and 18 deletions.
  1. +10 −8 lib/shinmun/bluecloth_coderay.rb
  2. +8 −5 lib/shinmun/helpers.rb
  3. +4 −2 lib/shinmun/post.rb
  4. +1 −1 shinmun.gemspec
  5. +2 −2 templates/index.rxml
@@ -1,21 +1,23 @@
class BlueCloth
- def transform_code_blocks( str, rs )
- @log.debug " Transforming code blocks"
+ attr_accessor :code_css
- str.gsub(CodeBlockRegexp) {|block|
- codeblock = $1
- remainder = $2
+ def transform_code_blocks( str, rs )
+ @log.debug " Transforming code blocks"
+
+ str.gsub(CodeBlockRegexp) {|block|
+ codeblock = $1
+ remainder = $2
# Generate the codeblock
if codeblock =~ /^(?:[ ]{4}|\t)@@(.*?)\n\n(.*)\n\n/m
"\n\n<pre class='highlight'>%s</pre>\n\n%s" %
- [CodeRay.scan(outdent($2), $1).html(:css => :style, :line_numbers => :list).delete("\n"), remainder]
+ [CodeRay.scan(outdent($2), $1).html(:css => (code_css || :class), :line_numbers => :list).delete("\n"), remainder]
else
"\n\n<pre><code>%s\n</code></pre>\n\n%s" %
[encode_code(outdent(codeblock), rs).rstrip, remainder]
end
- }
- end
+ }
+ end
end
View
@@ -34,11 +34,14 @@ def rfc822(time)
# Render a link for the navigation bar.
def navi_link(text, path)
- if path.match(/categories\/(.*)/)
- active = $1 == urlify(@category) if @category
- active = $1 == urlify(@post.category) if @post
- else
- active = request.path_info == path
+ active = request.path_info == path
+
+ if path.match(/categories\/(.*)/)
+ category = $1
+ if request.path.match(/(\d+)\/(\d+)\/(.*)/)
+ post = posts_by_date[$1.to_i][$2.to_i][$3]
+ active ||= category == urlify(post.category) if post
+ end
end
link_to text, path, :class => active ? 'active' : nil
View
@@ -115,14 +115,16 @@ def dump
end
# Transform the body of this post. Defaults to Markdown.
- def transform(src)
+ def transform(src, options={})
case type
when 'html'
RubyPants.new(src).to_html
when 'tt'
RubyPants.new(RedCloth.new(src).to_html).to_html
else
- RubyPants.new(BlueCloth.new(src).to_html).to_html
+ bluecloth = BlueCloth.new(src)
+ bluecloth.code_css = options[:code_css]
+ RubyPants.new(bluecloth.to_html).to_html
end
end
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'shinmun'
- s.version = '1.0.1'
+ s.version = '1.0.2'
s.summary = 'file based blog engine'
s.author = 'Matthias Georgi'
s.email = 'matti.georgi@gmail.com'
View
@@ -11,8 +11,8 @@
<item>
<title><%= post.title %></title>
<category><%= post.category %></category>
- <description><%= strip_tags post.summary %></description>
- <author><%= @author || @blog.author %></author>
+ <description><![CDATA[ <%= post.transform(post.body, :code_css => :style) %>]]></description>
+ <author><%= @blog.author %></author>
<link><%= @blog.url %><%= post_path post %></link>
<pubDate><%= rfc822 post.date %></pubDate>
</item>

0 comments on commit 268c261

Please sign in to comment.