Module: Spotlight::PagesHelper

Defined in:
app/helpers/spotlight/pages_helper.rb

Instance Method Summary collapse

Instance Method Details

#available_index_fieldsObject



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

def available_index_fields
  [{key: document_show_link_field, label: t(:'.title_placeholder')}] + (@page.exhibit.blacklight_configuration.default_blacklight_config.index_fields.map { |k,v| { key: k, label: index_field_label(nil, k) }})
end

#disable_save_pages_button?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/helpers/spotlight/pages_helper.rb', line 15

def disable_save_pages_button?
  page_collection_name == "about_pages" && @pages.empty?
end

#get_search_widget_search_results(block) ⇒ Object



18
19
20
21
22
23
24
# File 'app/helpers/spotlight/pages_helper.rb', line 18

def get_search_widget_search_results block
  if block.searches?
    get_search_results(block.query_params.with_indifferent_access.merge(params))
  else
    []
  end
end

#has_title?(document) ⇒ Boolean

Returns:

  • (Boolean)


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

def has_title? document
  document_heading(document) != document.id
end

#nestable_data_attributes(type) ⇒ Object



25
26
27
28
29
# File 'app/helpers/spotlight/pages_helper.rb', line 25

def nestable_data_attributes(type)
  nestable_data_attributes_hash(type).map do |attr, val|
    "#{attr}='#{val}'"
  end.join(' ')
end

#nestable_data_attributes_hash(type) ⇒ Object



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

def nestable_data_attributes_hash(type)
  case type
  when "feature_pages"
    {:"data-max-depth" => '2',
     :"data-expand-btn-HTML" => '',
     :"data-collapse-btn-HTML" => ''}
  when "about_pages"
    {:"data-max-depth" => '1'}
  else
    {}
  end
end

#render_contact_email_address(address) ⇒ Object



42
43
44
# File 'app/helpers/spotlight/pages_helper.rb', line 42

def render_contact_email_address(address)
  mail_to address, address
end

#sir_trevor_markdown(text) ⇒ Object



3
4
5
# File 'app/helpers/spotlight/pages_helper.rb', line 3

def sir_trevor_markdown text
  GitHub::Markup.render(".md", text.gsub("<br>", "\n").gsub("<p>", "").gsub("</p>", "\n\n")).html_safe
end