Skip to content

Commit

Permalink
Merge pull request #1244 from projectblacklight/release-5.x-backports
Browse files Browse the repository at this point in the history
Release 5.x backports
  • Loading branch information
mejackreed committed Sep 15, 2015
2 parents dae8d41 + bc3be14 commit 6e2b36f
Show file tree
Hide file tree
Showing 21 changed files with 386 additions and 185 deletions.
16 changes: 2 additions & 14 deletions app/helpers/blacklight/blacklight_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def render_page_title

##
# Create <link rel="alternate"> links from a documents dynamically
# provided export formats. Currently not used by standard BL layouts,
# but available for your custom layouts to provide link rel alternates.
# provided export formats.
#
# Returns empty string if no links available.
#
Expand All @@ -46,18 +45,7 @@ def render_page_title
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
def render_link_rel_alternates(document=@document, options = {})
return if document.nil?

options = { unique: false, exclude: [] }.merge(options)

seen = Set.new

safe_join(document.export_formats.map do |format, spec|
next if options[:exclude].include?(format) || (options[:unique] && seen.include?(spec[:content_type]))

seen.add(spec[:content_type])

tag(:link, rel: "alternate", title: format, type: spec[:content_type], href: polymorphic_url(document, format: format))
end.compact, "\n")
presenter(document).link_rel_alternates(options)
end

##
Expand Down
31 changes: 31 additions & 0 deletions app/helpers/blacklight/catalog_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,35 @@ def render_sms_action? config, options = {}
!sms_mappings.blank?
end

def render_search_to_page_title_filter(facet, values)
facet_config = facet_configuration_for_field(facet)
filter_label = facet_field_label(facet_config.key)
filter_value = if values.size < 3
values.map {|value| facet_display_value(facet, value)}.to_sentence
else
t('blacklight.search.page_title.many_constraint_values', values: values.size)
end
t('blacklight.search.page_title.constraint', label: filter_label, value: filter_value)
end

def render_search_to_page_title(params)
constraints = []

if params['q'].present?
q_label = label_for_search_field(params[:search_field]) unless default_search_field && params[:search_field] == default_search_field[:key]

if q_label.present?
constraints += [t('blacklight.search.page_title.constraint', label: q_label, value: params['q'])]
else
constraints += [params['q']]
end
end

if params['f'].present?
constraints += params['f'].collect{ |key, value| render_search_to_page_title_filter(key, value) } unless params['f'].blank?
end

constraints.join(' / ')
end

end
2 changes: 2 additions & 0 deletions app/views/bookmarks/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% @page_title = t('blacklight.bookmarks.page_title', :application_name => application_name) %>

<div id="content" class="col-md-12">
<h1 class='page-heading'><%= t('blacklight.bookmarks.title') %></h1>

Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_search_results.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2 class="sr-only top-content-title"><%= t('blacklight.search.search_results_header') %></h2>

<% @page_title = t('blacklight.search.title', :application_name => application_name) %>
<% @page_title = t('blacklight.search.page_title.title', :constraints => render_search_to_page_title(params), :application_name => application_name) %>
<% content_for(:head) do -%>
Expand Down
2 changes: 2 additions & 0 deletions app/views/saved_searches/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% @page_title = t('blacklight.saved_searches.page_title', :application_name => application_name) %>

<div id="content" class="col-md-9">

<h1 class='page-heading'><%= t('blacklight.saved_searches.title') %></h1>
Expand Down
2 changes: 2 additions & 0 deletions app/views/search_history/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% @page_title = t('blacklight.search_history.page_title', :application_name => application_name) %>

<div id="content" class="col-md-12">
<h1 class='page-heading'><%=t('blacklight.search_history.title')%></h1>
<%- if @searches.blank? -%>
Expand Down
8 changes: 8 additions & 0 deletions config/locales/blacklight.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ de:

bookmarks:
title: 'Lesezeichen'
page_title: 'Lesezeichen - %{application_name}'
no_bookmarks: 'Sie haben keine Lesezeichen'
add:
button: 'Lesezeichen'
Expand Down Expand Up @@ -61,6 +62,7 @@ de:
success: 'Dein gespeicherte Suchen gab gelöscht.'
failure: 'Es gab ein Problem beim löschen von Suchen.'
title: 'Gespeicherte Suchen'
page_title: 'Gespeicherte Suchen - %{application_name}'
need_login: 'Bitte melden Sie sich an, um dein gespeicherte Suchen anschauen und wervalten.'
no_searches: 'Sie haben keine gespeicherte Suchen'
list_title: 'Dein gespeicherte Suchen'
Expand All @@ -73,6 +75,7 @@ de:
success: 'Suchverlauf gelöscht.'
failure: 'Es gab ein Problem beim löschen von Suchverlauf.'
title: 'Suchverlauf'
page_title: 'Suchverlauf - %{application_name}'
no_history: 'Sie haben keine Suchverlauf'
recent: 'Deine neueste Suchen'
forget: 'vergessen'
Expand Down Expand Up @@ -139,7 +142,12 @@ de:
back_to_bookmarks: 'Zuruch nach Lesezeichen'

search:
# i18n key 'title' is deprecated and will be removed in Blacklight 6.0
title: '%{application_name} Suchergebnisse'
page_title:
title: '%{constraints} - %{application_name} Suchergebnisse'
constraint: '%{label}: %{value}'
many_constraint_values: '%{values} ausgewählt'
search_results_header: 'Suchen'
search_results: 'Suchergebnisse'
errors:
Expand Down
8 changes: 8 additions & 0 deletions config/locales/blacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ en:

bookmarks:
title: 'Bookmarks'
page_title: 'Bookmarks - %{application_name}'
no_bookmarks: 'You have no bookmarks'
add:
button: 'Bookmark'
Expand Down Expand Up @@ -61,6 +62,7 @@ en:
success: 'Cleared your saved searches.'
failure: 'There was a problem clearing your searches.'
title: 'Saved Searches'
page_title: 'Saved Searches - %{application_name}'
need_login: 'Please log in to manage and view your saved searches.'
no_searches: 'You have no saved searches'
list_title: 'Your saved searches'
Expand All @@ -73,6 +75,7 @@ en:
success: 'Cleared your search history.'
failure: 'There was a problem clearing your search history.'
title: 'Search History'
page_title: 'Search History - %{application_name}'
no_history: 'You have no search history'
recent: 'Your recent searches'
forget: 'forget'
Expand Down Expand Up @@ -139,7 +142,12 @@ en:
back_to_bookmarks: 'Back to Bookmarks'

search:
# i18n key 'title' is deprecated and will be removed in Blacklight 6.0
title: '%{application_name} Search Results'
page_title:
title: '%{constraints} - %{application_name} Search Results'
constraint: '%{label}: %{value}'
many_constraint_values: '%{values} selected'
search_results_header: 'Search'
search_results: 'Search Results'
errors:
Expand Down
8 changes: 8 additions & 0 deletions config/locales/blacklight.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ es:

bookmarks:
title: 'Favoritos'
page_title: 'Favoritos - %{application_name}'
no_bookmarks: 'Usted no tiene favoritos'
add:
button: 'Favoritos'
Expand Down Expand Up @@ -61,6 +62,7 @@ es:
success: 'Se borraron sus búsquedas guardadas'
failure: 'Hubo un problema al borrar sus búsquedas.'
title: 'Búsquedas guardadas'
page_title: 'Búsquedas guardadas - %{application_name}'
need_login: 'Por favor, inicie sesión para administrar y ver sus búsquedas guardadas.'
no_searches: 'No tienes búsquedas guardadas'
list_title: 'Sus búsquedas guardadas'
Expand All @@ -73,6 +75,7 @@ es:
success: 'Se borro el historial de búsqueda.'
failure: 'Hubo un problema al borrar su historial de búsqueda.'
title: 'Historia'
page_title: 'Historia - %{application_name}'
no_history: 'Usted no tiene historial de búsqueda'
recent: 'Sus búsquedas recientes'
forget: 'Olvidar'
Expand Down Expand Up @@ -139,7 +142,12 @@ es:
back_to_bookmarks: 'Volver a sus favoritos'

search:
# i18n key 'title' is deprecated and will be removed in Blacklight 6.0
title: '%{application_name} Resultados de la búsqueda'
page_title:
title: '%{constraints} - %{application_name} Resultados de la búsqueda'
constraint: '%{label}: %{value}'
many_constraint_values: '%{values} seleccionado'
search_results_header: 'Buscar'
search_results: 'Resultados de la búsqueda'
errors:
Expand Down
8 changes: 8 additions & 0 deletions config/locales/blacklight.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fr:

bookmarks:
title: 'Favoris'
page_title: 'Favoris - %{application_name}'
no_bookmarks: 'Accédez à votre compte pour conserver des références dans votre panier'
add:
button: 'Panier'
Expand Down Expand Up @@ -61,6 +62,7 @@ fr:
success: 'Recherches effacées.'
failure: 'Un problème est survenu lors de la suppression.'
title: 'Recherches sauvegardées'
page_title: 'Recherches sauvegardées - %{application_name}'
need_login: 'Veuillez vous connecter pour accéder à vos recherches.'
no_searches: 'Vous n''avez sauvegardé aucune recherche.'
list_title: 'Vos recherches'
Expand All @@ -73,6 +75,7 @@ fr:
success: 'Votre historique de recherche a bien été effacé.'
failure: 'Un problème est survenu lors de la suppression.'
title: 'Historique de recherche'
title: 'Historique de recherche - %{application_name}'
no_history: 'Il n''y a aucun historique en cours.'
recent: 'Dernières recherches'
forget: 'Supprimer'
Expand Down Expand Up @@ -142,7 +145,12 @@ fr:
back_to_bookmarks: 'Retour aux favoris'

search:
# i18n key 'title' is deprecated and will be removed in Blacklight 6.0
title: '%{application_name} Résultats de recherche'
page_title:
title: '%{constraints} - %{application_name} Résultats de recherche'
constraint: '%{label}: %{value}'
many_constraint_values: '%{values} sélectionné'
search_results_header: 'Recherche'
search_results: 'Résultats de recherche'
errors:
Expand Down
8 changes: 8 additions & 0 deletions config/locales/blacklight.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ it:

bookmarks:
title: 'Preferiti'
page_title: 'Preferiti - %{application_name}'
no_bookmarks: 'Non è stato salvato nessun preferito.'
add:
button: 'Preferiti'
Expand Down Expand Up @@ -61,6 +62,7 @@ it:
success: 'Tutte le ricerche salvate sono state cancellate.'
failure: 'Si è verificato un errore nel cancellare le ricerche salvate.'
title: 'Ricerche salvate'
page_title: 'Ricerche salvate - %{application_name}'
need_login: 'Effettuare il login per gestire e visualizzare le ricerche salvate.'
no_searches: 'Non è stata salvata nessuna ricerca.'
list_title: 'Ricerche salvate'
Expand All @@ -73,6 +75,7 @@ it:
success: 'Le ricerche effettuate sono state cancellate.'
failure: 'Si è verificato un errore nel cancellare le ricerche effettuate.'
title: 'Ricerche effettuate'
page_title: 'Ricerche effettuate - %{application_name}'
no_history: 'Non è stata effettuata nessuna ricerca'
recent: 'Ricerche effettuate'
forget: 'dimentica'
Expand Down Expand Up @@ -139,7 +142,12 @@ it:
back_to_bookmarks: 'Torna ai preferiti'

search:
# i18n key 'title' is deprecated and will be removed in Blacklight 6.0
title: 'Risultati della ricerca per %{application_name}'
page_title:
title: '%{constraints} - %{application_name} Risultati della ricerca'
constraint: '%{label}: %{value}'
many_constraint_values: '%{values} selezionato'
search_results_header: 'Ricerca'
search_results: 'Risultati della ricerca'
errors:
Expand Down
8 changes: 8 additions & 0 deletions config/locales/blacklight.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pt-BR:

bookmarks:
title: 'Favoritos'
page_title: 'Favoritos - %{application_name}'
no_bookmarks: 'Você não salvou nenhum Favorito'
add:
button: 'Favorito'
Expand Down Expand Up @@ -60,6 +61,7 @@ pt-BR:
success: 'As buscas foram removidas.'
failure: 'Xiii, ocorreu um erro ao remover suas pesquisas.'
title: 'Pesquisas Salvas'
page_title: 'Pesquisas Salvas - %{application_name}'
need_login: 'Por favor faça o login para gerenciar suas buscas salvas.'
no_searches: 'Você não salvou nenhuma busca'
list_title: 'Suas Buscas'
Expand All @@ -72,6 +74,7 @@ pt-BR:
success: 'Histórico de Busca removido.'
failure: 'Xiii, ocorreu um erro ao remover o histórico de busca.'
title: 'Histórico de Busca'
page_title: 'Histórico de Busca - %{application_name}'
no_history: 'Não existe nada em seu histórico'
recent: 'Buscas Recentes'
forget: 'limpar'
Expand Down Expand Up @@ -137,7 +140,12 @@ pt-BR:
back_to_bookmarks: 'Voltar aos Favoritos'

search:
# i18n key 'title' is deprecated and will be removed in Blacklight 6.0
title: '%{application_name} Resultado da Busca'
page_title:
title: '%{constraints} - %{application_name} Resultado da Busca'
constraint: '%{label}: %{value}'
many_constraint_values: '%{values} selecionado'
search_results_header: 'Busca'
search_results: 'Resultados da Busca'
errors:
Expand Down
1 change: 1 addition & 0 deletions lib/blacklight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Blacklight

autoload :SolrResponse, 'blacklight/solr_response'
autoload :Facet, 'blacklight/facet'
autoload :FacetPaginator, 'blacklight/facet_paginator'

extend SearchFields
extend Deprecation
Expand Down
23 changes: 23 additions & 0 deletions lib/blacklight/document_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ def document_heading
end
end

##
# Create <link rel="alternate"> links from a documents dynamically
# provided export formats. Returns empty string if no links available.
#
# @params [SolrDocument] document
# @params [Hash] options
# @option options [Boolean] :unique ensures only one link is output for every
# content type, e.g. as required by atom
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
def link_rel_alternates(options = {})
options = { unique: false, exclude: [] }.merge(options)

seen = Set.new

safe_join(@document.export_formats.map do |format, spec|
next if options[:exclude].include?(format) || (options[:unique] && seen.include?(spec[:content_type]))

seen.add(spec[:content_type])

tag(:link, rel: "alternate", title: format, type: spec[:content_type], href: @controller.polymorphic_url(@document, format: format))
end.compact, "\n")
end

##
# Get the document's "title" to display in the <title> element.
# (by default, use the #document_heading)
Expand Down
Loading

0 comments on commit 6e2b36f

Please sign in to comment.