asciinema.org/app/helpers/application_helper.rb

44 lines
764 B
Ruby
Raw Normal View History

module ApplicationHelper
2012-07-25 18:24:20 +00:00
def page_title
title = "ascii.io"
if @title
title = "#{@title} - #{title}"
end
title
end
2012-02-26 15:40:30 +00:00
def twitter_auth_path
"/auth/twitter"
end
def github_auth_path
"/auth/github"
end
2012-03-03 07:52:10 +00:00
2012-04-05 20:30:57 +00:00
def markdown(&block)
2012-06-08 07:08:30 +00:00
text = capture(&block)
2012-06-09 13:23:56 +00:00
MKD_RENDERER.render(capture(&block)).html_safe
2012-04-05 20:30:57 +00:00
end
def indented(string, width)
string.lines.map { |l| "#{' ' * width}#{l}" }.join('')
end
2012-07-25 18:24:20 +00:00
def category_link(text, url, name)
opts = {}
if name == @current_category
opts[:class] = 'active'
end
link_to text, url, opts
end
def timeago(time, options = {})
options[:class] ||= "timeago"
content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601))
end
end