diff --git a/app/helpers/blacklight/blacklight_helper_behavior.rb b/app/helpers/blacklight/blacklight_helper_behavior.rb index 2fc3588327..1d81a40b30 100644 --- a/app/helpers/blacklight/blacklight_helper_behavior.rb +++ b/app/helpers/blacklight/blacklight_helper_behavior.rb @@ -274,6 +274,13 @@ def document_heading document=nil render_field_value(document[blacklight_config.view_config(:show).title_field] || document.id) end + ## + # Assign the @page_title instance variable to its default value + def document_page_title + t('blacklight.search.show.title_html', :document_title => document_show_html_title, :application_name => application_name) + end + + ## # Get the document's "title" to display in the element. # (by default, use the #document_heading) diff --git a/app/views/catalog/show.html.erb b/app/views/catalog/show.html.erb index fbcc9cc4ed..178c3bc10b 100644 --- a/app/views/catalog/show.html.erb +++ b/app/views/catalog/show.html.erb @@ -2,8 +2,7 @@ <%= render 'previous_next_doc' %> - -<% @page_title = t('blacklight.search.show.title', :document_title => document_show_html_title, :application_name => application_name) -%> + <% @page_title = document_page_title %> <% content_for(:head) { render_link_rel_alternates } -%> <%# this should be in a partial -%> diff --git a/config/locales/blacklight.en.yml b/config/locales/blacklight.en.yml index 541e2350da..473d193308 100644 --- a/config/locales/blacklight.en.yml +++ b/config/locales/blacklight.en.yml @@ -194,7 +194,7 @@ en: index: label: '%{label}:' show: - title: '%{document_title} - %{application_name}' + title_html: '%{document_title} - %{application_name}' label: '%{label}:' rss_feed: 'RSS for results' atom_feed: 'Atom for results' diff --git a/spec/helpers/blacklight_helper_spec.rb b/spec/helpers/blacklight_helper_spec.rb index 7e26403eee..6e38fab540 100644 --- a/spec/helpers/blacklight_helper_spec.rb +++ b/spec/helpers/blacklight_helper_spec.rb @@ -216,6 +216,15 @@ def mock_document_app_helper_url *args end end + describe "document_page_title" do + before do + helper.stub(:document_show_html_title => 'Document title') + end + subject { helper.document_page_title } + it { should == "Document title - Blacklight" } + it { should be_html_safe } + end + describe "render_document_show_field_value" do before do @config = Blacklight::Configuration.new.configure do |config|