app/helpers/spotlight/application_helper.rb in blacklight-spotlight-0.24.0 vs app/helpers/spotlight/application_helper.rb in blacklight-spotlight-0.25.0

- old
+ new

@@ -3,24 +3,29 @@ # General spotlight application helpers module ApplicationHelper include CrudLinkHelpers include TitleHelper include JcropHelper + include MetaHelper ## # Give the application name a chance to include the exhibit title def application_name - name = current_site.title if current_site.title.present? + name = site_title name ||= super if current_exhibit t :'spotlight.application_name', exhibit: current_exhibit.title, application_name: name else name end end + def site_title + current_site.title if current_site.title.present? + end + # Can search for named routes directly in the main app, omitting # the "main_app." prefix def method_missing(method, *args, &block) if main_app_url_helper?(method) main_app.send(method, *args) @@ -77,24 +82,28 @@ end # Return a copy of the blacklight configuration # that only includes views conifgured by our block def blacklight_view_config_for_search_block(block) + return {} unless block.view.present? + # Reject any views that aren't configured to display for this block blacklight_config.view.select do |view, _| block.view.include? view.to_s end end def block_document_index_view_type(block) views = blacklight_view_config_for_search_block(block) - if views.key? document_index_view_type - document_index_view_type - else - views.keys.first - end + selected_view = if views.key? document_index_view_type + document_index_view_type + else + views.keys.first + end + + selected_view || default_document_index_view_type end # Return the list of views that are configured to display for a block def selected_search_block_views(block) block.as_json[:data].select do |_key, value| @@ -110,30 +119,9 @@ behavior: 'metadata-select', 'deselect-text' => t(:".deselect_all"), 'select-text' => t(:".select_all") } ) - end - - def add_exhibit_twitter_card_content - twitter_card('summary') do |card| - card.url exhibit_root_url(current_exhibit) - card.title current_exhibit.title - card.description current_exhibit.subtitle - card.image carrierwave_url(current_exhibit.thumbnail.image.thumb) if current_exhibit.thumbnail - end - end - - def carrierwave_url(upload) - # Carrierwave's #url returns either a full url (if asset path was configured) - # or just the path to the image. We'll try to normalize it to a url. - url = upload.url - - if url.nil? || url.starts_with?('http') - url - else - (URI.parse(Rails.application.config.asset_host || root_url) + url).to_s - end end def uploaded_field_label(config) solr_field = Array(config.solr_field || config.field_name).first.to_s config.label || blacklight_config.index_fields[solr_field].try(:label) || t(".#{solr_field}")