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), 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 tag.div(:id => "#{id}_container", :class => "richtext_container") do
25 output_buffer << 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 << tag.div("", :id => "#{id}_preview", :class => "richtext_preview richtext")
30 output_buffer << tag.div(:id => "#{id}_help", :class => "richtext_help") do
31 output_buffer << render("site/#{type}_help")
32 output_buffer << 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 tag.span(time_ago_in_words(date), :title => l(date, :format => :friendly))
52 def friendly_date_ago(date)
53 tag.span(time_ago_in_words(date, :scope => :'datetime.distance_in_words_ago'), :title => l(date, :format => :friendly))
57 if content_for? :body_class
58 content_for :body_class
60 "#{params[:controller]} #{params[:controller]}-#{params[:action]}"
64 def current_page_class(path)
65 :current if current_page?(path)
70 :locale => I18n.locale,
71 :preferred_editor => preferred_editor
75 data[:user] = current_user.id.to_json
77 data[:user_home] = { :lat => current_user.home_lat, :lon => current_user.home_lon } unless current_user.home_lon.nil? || current_user.home_lat.nil?
80 data[:location] = session[:location] if session[:location]
83 data[:token] = @oauth.token
84 data[:token_secret] = @oauth.secret
85 data[:consumer_key] = @oauth.client_application.key
86 data[:consumer_secret] = @oauth.client_application.secret