Module: Masq::ApplicationHelper
- Defined in:
- app/helpers/masq/application_helper.rb
Instance Method Summary collapse
-
#active_page?(pages = {}) ⇒ Boolean
Takes a hash with pages and tells whether the current page is among them.
- #error_messages_for(*objects) ⇒ Object
-
#home_page? ⇒ Boolean
Is the current page the home page? This is used to display further information (like the endoint url) in the <head>.
-
#identity_page? ⇒ Boolean
Is the current page an identity page? This is used to display further information (like the endoint url) in the <head>.
- #label_tag(field, text = nil, options = {}) ⇒ Object
-
#nav(name, url, pages = nil, active = false) ⇒ Object
Renders a navigation element and marks it as active where appropriate.
- #page_title ⇒ Object
-
#property_label_text(property) ⇒ Object
Custom label names for request properties (like SReg data).
- #property_label_text_for_type_uri(type_uri) ⇒ Object
Instance Method Details
#active_page?(pages = {}) ⇒ Boolean
Takes a hash with pages and tells whether the current page is among them. The keys must be controller names and their value must be an array of action names. If the array is empty, every action is supposed to be valid.
51 52 53 54 55 |
# File 'app/helpers/masq/application_helper.rb', line 51 def active_page?(pages = {}) is_active = pages.include?(params[:controller]) is_active = pages[params[:controller]].include?(params[:action]) if is_active && !pages[params[:controller]].empty? is_active end |
#error_messages_for(*objects) ⇒ Object
11 12 13 |
# File 'app/helpers/masq/application_helper.rb', line 11 def (*objects) render("masq/shared/error_messages", objects: objects.flatten) end |
#home_page? ⇒ Boolean
Is the current page the home page? This is used to display further information (like the endoint url) in the <head>
23 24 25 |
# File 'app/helpers/masq/application_helper.rb', line 23 def home_page? active_page?("info" => ["index"]) end |
#identity_page? ⇒ Boolean
Is the current page an identity page? This is used to display further information (like the endoint url) in the <head>
17 18 19 |
# File 'app/helpers/masq/application_helper.rb', line 17 def identity_page? active_page?("accounts" => ["show"]) end |
#label_tag(field, text = nil, options = {}) ⇒ Object
7 8 9 |
# File 'app/helpers/masq/application_helper.rb', line 7 def label_tag(field, text = nil, = {}) content_tag(:label, text ? text : field.to_s.humanize, .reverse_merge(for: field.to_s)) end |
#nav(name, url, pages = nil, active = false) ⇒ Object
Renders a navigation element and marks it as active where appropriate. See active_page? for details
44 45 46 |
# File 'app/helpers/masq/application_helper.rb', line 44 def nav(name, url, pages = nil, active = false) content_tag(:li, link_to(name, url), class: ((active || (pages && active_page?(pages))) ? "act" : nil)) end |
#page_title ⇒ Object
3 4 5 |
# File 'app/helpers/masq/application_helper.rb', line 3 def page_title (@page_title ||= nil) ? "#{@page_title} | #{Masq::Engine.config.masq["name"]}" : Masq::Engine.config.masq["name"] end |
#property_label_text(property) ⇒ Object
Custom label names for request properties (like SReg data)
28 29 30 31 32 33 34 35 |
# File 'app/helpers/masq/application_helper.rb', line 28 def property_label_text(property) case property.to_sym when :image_default then t(:image_url) when :web_default then t(:website_url) when :web_blog then t(:blog_url) else t(property.to_sym) end end |
#property_label_text_for_type_uri(type_uri) ⇒ Object
37 38 39 40 |
# File 'app/helpers/masq/application_helper.rb', line 37 def property_label_text_for_type_uri(type_uri) property = Persona.attribute_name_for_type_uri(type_uri) property ? property_label_text(property) : type_uri end |