Sha256: 4b5afae6297a568b6a299b37c28e18705cf5d50f871676f0eaae3d38490d8bb9
Contents?: true
Size: 876 Bytes
Versions: 2
Compression:
Stored size: 876 Bytes
Contents
module Hitchens class PostDecorator < ApplicationDecorator decorates 'Hitchens::Post' def body_to_html html = markdown(body) syntax_highlight(html).html_safe end def pubdate_tag if publication_date h.time_tag publication_date, pubdate_display, pubdate: true else "(not yet published)" end end private def pubdate_display publication_date.getlocal.strftime("%A, %B %e, %Y at %l:%M %p") end def syntax_highlight(html) doc = Nokogiri::HTML.fragment(html) # remove all pre tags. # coderay will nest pre tags within the code tags. doc.css("pre").each { |pre| pre.replace pre.inner_html } doc.css("code").each do |code| code_ray = CodeRay.scan(code.text.rstrip, code[:class]).div code.replace code_ray end doc.to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hitchens-0.0.3 | app/decorators/hitchens/post_decorator.rb |
hitchens-0.0.2 | app/decorators/hitchens/post_decorator.rb |