Module: LayoutHelper

Includes:
ApplicationHelper
Defined in:
app/helpers/layout_helper.rb

Overview

These helper methods can be called in your template to set variables to be used in the layout This module should be included in all views globally, to do so you may need to add this line to your ApplicationController

helper :layout

Instance Method Summary collapse

Methods included from ApplicationHelper

#all_services_connected?, #bookmarklet_code, #changelog_url, #donations_enabled?, #jquery_include_tag, #pod_name, #pod_version, #popover_with_close_html, #qrcode_uri, #service_unconnected?, #source_url, #timeago

Instance Method Details

#current_user_atom_tagObject


35
36
37
38
39
# File 'app/helpers/layout_helper.rb', line 35

def current_user_atom_tag
  return unless @person.present?
  (:link, "", rel: "alternate", href: @person.atom_url, type: "application/atom+xml",
              title: t("layouts.application.public_feed", name: @person.name))
end

#flash_messagesObject


55
56
57
58
59
60
61
62
# File 'app/helpers/layout_helper.rb', line 55

def flash_messages
  flash.map do |name, msg|
    klass = flash_class name
    (:div, msg, class: "flash-body expose") do
      (:div, msg, class: "flash-message message alert alert-#{klass}", role: "alert")
    end
  end.join(' ').html_safe
end

#include_color_theme(view = "desktop") ⇒ Object


51
52
53
# File 'app/helpers/layout_helper.rb', line 51

def include_color_theme(view="desktop")
  stylesheet_link_tag "#{current_color_theme}/#{view}", media: "all"
end

#load_javascript_locales(section = 'javascripts') ⇒ Object


24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/layout_helper.rb', line 24

def load_javascript_locales(section = 'javascripts')
  nonced_javascript_tag do
    <<-JS.html_safe
      Diaspora.I18n.load(#{get_javascript_strings_for(I18n.locale, section).to_json},
                         "#{I18n.locale}",
                         #{get_javascript_strings_for(DEFAULT_LANGUAGE, section).to_json});
      Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}";
    JS
  end
end

#page_title(text = nil) ⇒ Object


19
20
21
22
# File 'app/helpers/layout_helper.rb', line 19

def page_title(text=nil)
  return text unless text.blank?
  pod_name
end

#title(page_title, show_title = true) ⇒ Object


14
15
16
17
# File 'app/helpers/layout_helper.rb', line 14

def title(page_title, show_title = true)
  content_for(:title) { page_title.to_s }
  @show_title = show_title
end

#translation_missing_warningsObject


41
42
43
44
45
46
47
48
49
# File 'app/helpers/layout_helper.rb', line 41

def translation_missing_warnings
  return if Rails.env == "production"

  (:style) do
    <<-CSS
      .translation_missing { color: purple; background-color: red; }
    CSS
  end
end