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)
|
2014-12-17 15:46:03 +00:00
|
|
|
"#{content_for(:title)} - asciinema".html_safe
|
2013-11-18 17:52:34 +00:00
|
|
|
else
|
2014-12-17 15:46:03 +00:00
|
|
|
"asciinema - Record and share your terminal sessions, the right way"
|
2012-07-25 18:24:20 +00:00
|
|
|
end
|
|
|
|
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
|
|
|
|
2014-06-30 21:26:25 +00:00
|
|
|
def default_user_theme_label(theme = Theme.default)
|
|
|
|
"Default (#{theme.label})"
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_asciicast_theme_label(theme)
|
|
|
|
"Default account theme (#{theme.label})"
|
|
|
|
end
|
|
|
|
|
|
|
|
def themes_for_select
|
|
|
|
Theme::AVAILABLE.invert
|
|
|
|
end
|
|
|
|
|
2014-10-12 18:44:55 +00:00
|
|
|
def flash_notifications
|
|
|
|
flash.select { |type, _| [:notice, :alert].include?(type.to_sym) }
|
|
|
|
end
|
|
|
|
|
2011-11-21 21:36:42 +00:00
|
|
|
end
|