]> git.openstreetmap.org Git - rails.git/commitdiff
Put specific page titles at the start
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Nov 2017 14:57:26 +0000 (14:57 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Nov 2017 14:57:26 +0000 (14:57 +0000)
The makes the shortened titles commonly shown on browser tabs more
useful.

app/helpers/open_graph_helper.rb
app/views/layouts/_head.html.erb
test/controllers/message_controller_test.rb

index ab7e230cbec768a7745192934bc5d7ebb40965b1..11cfe50306ee4d1e4fe1b08ea647735e6b565379 100644 (file)
@@ -2,7 +2,7 @@ module OpenGraphHelper
   def opengraph_tags(title = nil)
     tags = {
       "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:image" => image_url("osm_logo_256.png", :protocol => "http"),
       "og:image:secure_url" => image_url("osm_logo_256.png", :protocol => "https"),
index 6fce3f01fc3d336ac1f81eb56295393ffa365037..bf9f78b4376c3774129afd2d05e8f9c5a14bbe86 100644 (file)
   <%= opengraph_tags(@title) %>
   <% if flash[:piwik_goal] -%>
   <%= tag("meta", :name => "piwik-goal", :content => flash[:piwik_goal]) %>
-  <% end -%>  
+  <% end -%>
   <%= style_rules %>
   <%= yield :head %>
   <%= yield :auto_discovery_link_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 %>
index 8a7ae70de6c34a96f1a92194839819f56a5ccc95..930341f29364fe88042c52e8c6f8cb3d63c6fa7f 100644 (file)
@@ -63,7 +63,7 @@ class MessageControllerTest < ActionController::TestCase
     get :new, :params => { :display_name => recipient_user.display_name }
     assert_response :success
     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 "input#message_title", :count => 1
       assert_select "textarea#message_body", :count => 1
@@ -89,7 +89,7 @@ class MessageControllerTest < ActionController::TestCase
     end
     assert_response :success
     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 "input#message_title", :count => 1 do
         assert_select "[value='Test Message']"
@@ -117,7 +117,7 @@ class MessageControllerTest < ActionController::TestCase
     end
     assert_response :success
     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 "input#message_title", :count => 1 do
         assert_select "[value='Test Message']"
@@ -145,7 +145,7 @@ class MessageControllerTest < ActionController::TestCase
     end
     assert_response :success
     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 "input#message_title", :count => 1 do
         assert_select "[value='']"
@@ -244,7 +244,7 @@ class MessageControllerTest < ActionController::TestCase
     get :reply, :params => { :message_id => unread_message.id }
     assert_response :success
     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 "input#message_title[value='Re: #{unread_message.title}']", :count => 1
       assert_select "textarea#message_body", :count => 1