Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 268c261a1f2a1483e0b69a49f1caa9eb4654c7f2 1 parent 9884514
@georgi authored
View
18 lib/shinmun/bluecloth_coderay.rb
@@ -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
13 lib/shinmun/helpers.rb
@@ -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
6 lib/shinmun/post.rb
@@ -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
2  shinmun.gemspec
@@ -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
4 templates/index.rxml
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.