Module: Spotlight::TitleHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/spotlight/title_helper.rb

Overview

Page title helpers

Instance Method Summary collapse

Instance Method Details

#configuration_page_title(title = nil) ⇒ Object



11
12
13
# File 'app/helpers/spotlight/title_helper.rb', line 11

def configuration_page_title(title = nil)
  page_title t(:'spotlight.configuration.header'), title
end

#curation_page_title(title = nil) ⇒ Object



7
8
9
# File 'app/helpers/spotlight/title_helper.rb', line 7

def curation_page_title(title = nil)
  page_title t(:'spotlight.curation.header'), title
end

#page_title(section, title = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/spotlight/title_helper.rb', line 15

def page_title(section, title = nil)
  title ||= t(:'.header', default: '').presence

  head_content = t(:'spotlight.html_admin_title', section: section, title: title) if section && title
  head_content ||= section || title
  set_html_page_title(head_content)

  html_content = safe_join([
    section.presence,
    ((:small, title) if title.present?)
  ].compact, "\n")

  (:h1, html_content, class: 'page-header')
end

#set_html_page_title(title = nil) ⇒ Object



30
31
32
# File 'app/helpers/spotlight/title_helper.rb', line 30

def set_html_page_title(title = nil)
  @page_title = strip_tags(t(:'spotlight.html_title', title: title || t(:'.title', default: :'.header'), application_name: application_name)).html_safe
end