Put specific page titles at the start

The makes the shortened titles commonly shown on browser tabs more
useful.
This commit is contained in:
Andy Allan 2017-11-22 14:57:26 +00:00
parent cb87f02642
commit 1b181d4c1d
3 changed files with 8 additions and 8 deletions

View file

@ -2,7 +2,7 @@ module OpenGraphHelper
def opengraph_tags(title = nil) def opengraph_tags(title = nil)
tags = { tags = {
"og:site_name" => t("layouts.project_name.title"), "og:site_name" => t("layouts.project_name.title"),
"og:title" => [t("layouts.project_name.title"), title].compact.join(" | "), "og:title" => [title, t("layouts.project_name.title")].compact.join(" | "),
"og:type" => "website", "og:type" => "website",
"og:image" => image_url("osm_logo_256.png", :protocol => "http"), "og:image" => image_url("osm_logo_256.png", :protocol => "http"),
"og:image:secure_url" => image_url("osm_logo_256.png", :protocol => "https"), "og:image:secure_url" => image_url("osm_logo_256.png", :protocol => "https"),

View file

@ -37,5 +37,5 @@
<%= yield :head %> <%= yield :head %>
<%= yield :auto_discovery_link_tag %> <%= yield :auto_discovery_link_tag %>
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<title><%= t 'layouts.project_name.title' %><%= ' | ' + @title if @title %></title> <title><%= @title + ' | ' if @title %><%= t 'layouts.project_name.title' %></title>
<% end %> <% end %>

View file

@ -63,7 +63,7 @@ class MessageControllerTest < ActionController::TestCase
get :new, :params => { :display_name => recipient_user.display_name } get :new, :params => { :display_name => recipient_user.display_name }
assert_response :success assert_response :success
assert_template "new" assert_template "new"
assert_select "title", "OpenStreetMap | Send message" assert_select "title", "Send message | OpenStreetMap"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 assert_select "input#message_title", :count => 1
assert_select "textarea#message_body", :count => 1 assert_select "textarea#message_body", :count => 1
@ -89,7 +89,7 @@ class MessageControllerTest < ActionController::TestCase
end end
assert_response :success assert_response :success
assert_template "new" assert_template "new"
assert_select "title", "OpenStreetMap | Send message" assert_select "title", "Send message | OpenStreetMap"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do assert_select "input#message_title", :count => 1 do
assert_select "[value='Test Message']" assert_select "[value='Test Message']"
@ -117,7 +117,7 @@ class MessageControllerTest < ActionController::TestCase
end end
assert_response :success assert_response :success
assert_template "new" assert_template "new"
assert_select "title", "OpenStreetMap | Send message" assert_select "title", "Send message | OpenStreetMap"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do assert_select "input#message_title", :count => 1 do
assert_select "[value='Test Message']" assert_select "[value='Test Message']"
@ -145,7 +145,7 @@ class MessageControllerTest < ActionController::TestCase
end end
assert_response :success assert_response :success
assert_template "new" assert_template "new"
assert_select "title", "OpenStreetMap | Send message" assert_select "title", "Send message | OpenStreetMap"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do assert_select "input#message_title", :count => 1 do
assert_select "[value='']" assert_select "[value='']"
@ -244,7 +244,7 @@ class MessageControllerTest < ActionController::TestCase
get :reply, :params => { :message_id => unread_message.id } get :reply, :params => { :message_id => unread_message.id }
assert_response :success assert_response :success
assert_template "new" assert_template "new"
assert_select "title", "OpenStreetMap | Re: #{unread_message.title}" assert_select "title", "Re: #{unread_message.title} | OpenStreetMap"
assert_select "form[action='#{new_message_path(:display_name => user.display_name)}']", :count => 1 do assert_select "form[action='#{new_message_path(:display_name => user.display_name)}']", :count => 1 do
assert_select "input#message_title[value='Re: #{unread_message.title}']", :count => 1 assert_select "input#message_title[value='Re: #{unread_message.title}']", :count => 1
assert_select "textarea#message_body", :count => 1 assert_select "textarea#message_body", :count => 1