2011-11-21 21:36:42 +00:00
|
|
|
module ApplicationHelper
|
2013-10-19 16:25:30 +00:00
|
|
|
|
2013-11-18 11:17:05 +00:00
|
|
|
class CategoryLinks
|
|
|
|
|
|
|
|
def initialize(current_category, view_context)
|
|
|
|
@current_category = current_category
|
|
|
|
@view_context = view_context
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_to(*args)
|
|
|
|
@view_context.link_to_category(@current_category, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2014-02-20 22:00:44 +00:00
|
|
|
def current_user
|
|
|
|
decorated_current_user
|
|
|
|
end
|
|
|
|
|
2012-07-25 18:24:20 +00:00
|
|
|
def page_title
|
2013-11-18 17:52:34 +00:00
|
|
|
if content_for?(:title)
|
|
|
|
"#{content_for(:title)} - Asciinema"
|
|
|
|
else
|
|
|
|
"Asciinema - Record and share your terminal sessions, the right way"
|
2012-07-25 18:24:20 +00:00
|
|
|
end
|
|
|
|
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
|
|
|
|
2013-10-19 16:25:30 +00:00
|
|
|
def browser_id_user
|
2013-10-23 19:54:11 +00:00
|
|
|
email = current_user && current_user.email || session[:new_user_email]
|
|
|
|
email ? "'#{email}'".html_safe : 'null'
|
2013-10-19 16:25:30 +00:00
|
|
|
end
|
|
|
|
|
2013-11-18 11:17:05 +00:00
|
|
|
def category_links(current_category, &blk)
|
|
|
|
links = CategoryLinks.new(current_category, self)
|
|
|
|
|
|
|
|
content_tag(:ul, class: 'nav nav-pills nav-stacked') do
|
|
|
|
blk.call(links)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_to_category(current_category, text, url, name)
|
2012-07-25 18:24:20 +00:00
|
|
|
opts = {}
|
|
|
|
|
2013-11-18 11:17:05 +00:00
|
|
|
if name == current_category
|
2012-07-25 18:24:20 +00:00
|
|
|
opts[:class] = 'active'
|
|
|
|
end
|
|
|
|
|
2013-11-18 11:17:05 +00:00
|
|
|
content_tag(:li, link_to(text, url), opts)
|
2012-07-25 18:24:20 +00:00
|
|
|
end
|
2012-08-25 12:24:53 +00:00
|
|
|
|
2012-11-19 21:18:29 +00:00
|
|
|
def time_ago_tag(time, options = {})
|
2012-08-25 12:24:53 +00:00
|
|
|
options[:class] ||= "timeago"
|
|
|
|
content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601))
|
|
|
|
end
|
2012-12-08 21:29:21 +00:00
|
|
|
|
2011-11-21 21:36:42 +00:00
|
|
|
end
|