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(text, :urls, tag_builder.tag_options(:rel => "nofollow"))
12 def rss_link_to(*args)
13 link_to(image_tag("RSS.png", :size => "16x16", :border => 0), Hash[*args], :class => "rsssmall")
16 def atom_link_to(*args)
17 link_to(image_tag("RSS.png", :size => "16x16", :border => 0), Hash[*args], :class => "rsssmall")
20 def richtext_area(object_name, method, options = {})
21 id = "#{object_name}_#{method}"
22 type = options.delete(:format) || "markdown"
24 content_tag(:div, :id => "#{id}_container", :class => "richtext_container") do
25 output_buffer << content_tag(:div, :id => "#{id}_content", :class => "richtext_content") do
26 output_buffer << text_area(object_name, method, options.merge("data-preview-url" => preview_url(:type => type)))
27 output_buffer << content_tag(:div, "", :id => "#{id}_preview", :class => "richtext_preview richtext")
30 output_buffer << content_tag(:div, :id => "#{id}_help", :class => "richtext_help") do
31 output_buffer << render("site/#{type}_help")
32 output_buffer << content_tag(:div, :class => "buttons") do
33 output_buffer << submit_tag(I18n.t("site.richtext_area.edit"), :id => "#{id}_doedit", :class => "richtext_doedit deemphasize", :disabled => true)
34 output_buffer << submit_tag(I18n.t("site.richtext_area.preview"), :id => "#{id}_dopreview", :class => "richtext_dopreview deemphasize")
42 dir == "rtl" ? "rtl" : "ltr"
48 def friendly_date(date)
49 content_tag(:span, time_ago_in_words(date), :title => l(date, :format => :friendly))
53 if content_for? :body_class
54 content_for :body_class
56 "#{params[:controller]} #{params[:controller]}-#{params[:action]}"
60 def current_page_class(path)
61 :current if current_page?(path)
66 :locale => I18n.locale,
67 :preferred_editor => preferred_editor
71 data[:user] = current_user.id.to_json
73 data[:user_home] = { :lat => current_user.home_lat, :lon => current_user.home_lon } unless current_user.home_lon.nil? || current_user.home_lat.nil?
76 data[:location] = session[:location] if session[:location]
79 data[:token] = @oauth.token
80 data[:token_secret] = @oauth.secret
81 data[:consumer_key] = @oauth.client_application.key
82 data[:consumer_secret] = @oauth.client_application.secret