1 # frozen_string_literal: true
3 module ApplicationHelper
5 link_attr = 'rel="nofollow" dir="auto"'
7 Rinku.auto_link(text, :urls, link_attr).html_safe
9 Rinku.auto_link(ERB::Util.h(text), :urls, link_attr).html_safe
13 def rss_link_to(args = {})
14 link_to tag.i(:class => "bi bi-rss-fill fs-6", :aria => { :hidden => "true" }), args
19 dir == "rtl" ? "rtl" : "ltr"
25 def friendly_date(date)
26 tag.time(time_ago_in_words(date), :title => l(date, :format => :friendly), :datetime => date.xmlschema)
29 def friendly_date_ago(date)
30 tag.time(time_ago_in_words(date, :scope => :"datetime.distance_in_words_ago"), :title => l(date, :format => :friendly), :datetime => date.xmlschema)
34 if content_for? :body_class
35 content_for :body_class
37 controller_part = params[:controller].tr("/", "-")
38 "#{controller_part} #{controller_part}-#{params[:action]}"
42 def secondary_nav_items
44 [history_path, t("layouts.header.history")],
45 [export_path, t("layouts.header.export")],
46 [traces_path, t("layouts.header.gps_traces")],
47 [diary_entries_path, t("layouts.header.user_diaries")],
48 [communities_path, t("layouts.header.communities")],
49 [copyright_path, t("layouts.header.copyright")],
50 [help_path, t("layouts.header.help")],
51 [Settings.donation_url, t("layouts.header.donate"), { :target => :new }],
52 [about_path, t("layouts.header.about")]
55 if Settings.status != "database_offline" && can?(:index, Issue)
57 issues_path(:status => "open"),
58 safe_join([t("layouts.header.issues"), open_issues_count], " ")
67 :locale => I18n.locale,
68 :preferred_editor => preferred_editor,
69 :preferred_languages => preferred_languages.expand.map(&:to_s)
73 data[:user] = current_user.id.to_json
75 data[:user_home] = { :lat => current_user.home_lat, :lon => current_user.home_lon } if current_user.home_location?
78 data[:location] = session[:location] if session[:location]
79 data[:oauth_token] = oauth_token.token if oauth_token
84 # If the flash is a hash, then it will be a partial with a hash of locals, so we can call `render` on that
85 # This allows us to render html into a flash message in a safe manner.
86 def render_flash(flash)
88 render flash.deep_symbolize_keys
93 flash.inspect if Rails.env.development?