module Write module ApplicationHelper def write_admin? login_user && Write.admin?(login_user.github) end def login_user defined?(current_user) && current_user end def timestamp_display post words = time_ago_in_words(post.created_at) + " ago" if post.updated? words << " (Updated #{time_ago_in_words(post.updated_at)} ago)" end words end def head_links content_for :head, auto_discovery_link_tag(:atom, atom_feed_url, :title => Write.full_title) + stylesheet_link_tag("write/application", :media => "all") end def atom_feed_url Write.feed_url || feed_url end def post_snippet post truncate_html(Write::MD.render(post.content), :length => 256).html_safe end end end