1 module ApplicationHelper
2 require "rexml/document"
6 Rinku.auto_link(text, :urls, tag_builder.tag_options(:rel => "nofollow")).html_safe
8 Rinku.auto_link(ERB::Util.h(text), :urls, tag_builder.tag_options(:rel => "nofollow")).html_safe
12 def rss_link_to(args = {})
13 link_to(image_tag("RSS.png", :size => "16x16", :border => 0), args, :class => "rsssmall")
16 def atom_link_to(args = {})
17 link_to(image_tag("RSS.png", :size => "16x16", :border => 0), args, :class => "rsssmall")
22 dir == "rtl" ? "rtl" : "ltr"
28 def friendly_date(date)
29 tag.span(time_ago_in_words(date), :title => l(date, :format => :friendly))
32 def friendly_date_ago(date)
33 tag.span(time_ago_in_words(date, :scope => :"datetime.distance_in_words_ago"), :title => l(date, :format => :friendly))
37 if content_for? :body_class
38 content_for :body_class
40 "#{params[:controller]} #{params[:controller]}-#{params[:action]}"
44 def current_page_class(path)
45 :current if current_page?(path)
50 :locale => I18n.locale,
51 :preferred_editor => preferred_editor
55 data[:user] = current_user.id.to_json
57 data[:user_home] = { :lat => current_user.home_lat, :lon => current_user.home_lon } unless current_user.home_lon.nil? || current_user.home_lat.nil?
60 data[:location] = session[:location] if session[:location]
61 data[:oauth_token] = oauth_token.token if oauth_token
66 # If the flash is a hash, then it will be a partial with a hash of locals, so we can call `render` on that
67 # This allows us to render html into a flash message in a safe manner.
68 def render_flash(flash)
70 render flash.with_indifferent_access