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, #changelog_url, #contacts_link, #jquery_include_tag, #magic_bookmarklet_link, #pod_name, #pod_version, #popover_with_close_html, #raw_bookmarklet, #timeago

Instance Method Details

#bootstrap?Boolean


90
91
92
# File 'app/helpers/layout_helper.rb', line 90

def bootstrap?
  @css_framework == :bootstrap
end

#current_user_atom_tagObject


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

def current_user_atom_tag
  return #temp hax

  return unless @person.present?
  (:link, '', :rel => 'alternate', :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => t('.public_feed', :name => @person.name))
end

#flash_messagesObject


82
83
84
85
86
87
88
# File 'app/helpers/layout_helper.rb', line 82

def flash_messages
  flash.map do |name, msg|
    (:div, :id => "flash_#{name}") do
      (:div, msg, :class => 'message')
    end
  end.join(' ').html_safe
end

#include_base_css_framework(use_bootstrap = false) ⇒ Object


59
60
61
62
63
64
65
# File 'app/helpers/layout_helper.rb', line 59

def include_base_css_framework(use_bootstrap=false)
  if use_bootstrap || @aspect == :getting_started
    stylesheet_link_tag('bootstrap-complete')
  else
    stylesheet_link_tag 'blueprint', :media => 'screen'
  end
end

#load_javascript_locales(section = 'javascripts') ⇒ Object


31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/layout_helper.rb', line 31

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

#old_browser_js_supportObject


67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/helpers/layout_helper.rb', line 67

def old_browser_js_support
  (:script) do
    "if(Array.isArray === undefined) {\nArray.isArray = function (arg) {\nreturn Object.prototype.toString.call(arg) == '[object Array]';\n};\n}\nif ((window.history) && (window.history.pushState === undefined)) {\nwindow.history.pushState = function() { };\n}\n".html_safe
  end
end

#page_title(text = nil) ⇒ Object


17
18
19
20
# File 'app/helpers/layout_helper.rb', line 17

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

#set_asset_hostObject


22
23
24
25
26
27
28
29
# File 'app/helpers/layout_helper.rb', line 22

def set_asset_host
  path = AppConfig.environment.assets.host.to_s + '/assets/'
  (:script) do
    "if(window.app) app.baseImageUrl(\"\#{path}\")\n".html_safe
  end
end

#title(page_title, show_title = true) ⇒ Object


12
13
14
15
# File 'app/helpers/layout_helper.rb', line 12

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

#translation_missing_warningsObject


49
50
51
52
53
54
55
56
57
# File 'app/helpers/layout_helper.rb', line 49

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

  (:style) do
    ".translation_missing { color: purple; background-color: red; }\n"
  end
end