Module: Spotlight::PagesHelper
- Includes:
- RenderingHelper
- Defined in:
- app/helpers/spotlight/pages_helper.rb
Overview
Sir-trevor helpers methods
Instance Method Summary collapse
- #available_index_fields ⇒ Object
- #configurations_for_current_page ⇒ Object
- #disable_save_pages_button? ⇒ Boolean
- #get_search_widget_search_results(block) ⇒ Object
- #nestable_data_attributes(type) ⇒ Object
- #nestable_data_attributes_hash(type) ⇒ Object
- #render_contact_email_address(address) ⇒ Object
-
#sir_trevor_markdown(text) ⇒ Object
Override the default #sir_trevor_markdown so we can use a more complete markdown rendered.
Methods included from RenderingHelper
Instance Method Details
#available_index_fields ⇒ Object
22 23 24 25 26 27 |
# File 'app/helpers/spotlight/pages_helper.rb', line 22 def available_index_fields fields = blacklight_config.index_fields.map { |k, _v| { key: k, label: index_field_label(nil, k) } } fields.unshift(key: document_show_link_field, label: t(:'spotlight.pages.form.title_placeholder')) unless index_fields.include? document_show_link_field fields end |
#configurations_for_current_page ⇒ Object
64 65 66 |
# File 'app/helpers/spotlight/pages_helper.rb', line 64 def configurations_for_current_page Spotlight::PageConfigurations.new(context: self, page: @page).as_json end |
#disable_save_pages_button? ⇒ Boolean
29 30 31 |
# File 'app/helpers/spotlight/pages_helper.rb', line 29 def page_collection_name == 'about_pages' && @pages.empty? end |
#get_search_widget_search_results(block) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/helpers/spotlight/pages_helper.rb', line 33 def (block) if block.search.present? search_results(block.search.merge_params_for_search(params, blacklight_config)) else [] end end |
#nestable_data_attributes(type) ⇒ Object
41 42 43 44 45 |
# File 'app/helpers/spotlight/pages_helper.rb', line 41 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
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/spotlight/pages_helper.rb', line 47 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
60 61 62 |
# File 'app/helpers/spotlight/pages_helper.rb', line 60 def render_contact_email_address(address) mail_to address, address end |
#sir_trevor_markdown(text) ⇒ Object
Override the default #sir_trevor_markdown so we can use a more complete markdown rendered
12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/spotlight/pages_helper.rb', line 12 def sir_trevor_markdown(text) clean_text = if text text.gsub('<br>', "\n").gsub('<p>', '').gsub('</p>', "\n\n") else '' end render_markdown(clean_text) end |