From e62e879b3bb70bb93fe96d3cc669f219cd23ed8d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 26 Oct 2015 22:27:00 +0000 Subject: [PATCH] Add more detail to OpenGraph tags Closes #1073 --- app/helpers/open_graph_helper.rb | 16 ++++++++++++++++ app/views/layouts/_head.html.erb | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/helpers/open_graph_helper.rb diff --git a/app/helpers/open_graph_helper.rb b/app/helpers/open_graph_helper.rb new file mode 100644 index 000000000..12c794dd0 --- /dev/null +++ b/app/helpers/open_graph_helper.rb @@ -0,0 +1,16 @@ +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:type" => "website", + "og:image" => image_path("osm_logo.svg", :host => SERVER_URL), + "og:image:width" => "200", + "og:image:height" => "200" + } + + tags.map do |property, content| + tag(:meta, :property => property, :content => content) + end.join("").html_safe + end +end diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index ee23358ce..bd2ad441d 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -26,7 +26,7 @@ <%= tag("link", { :rel => "publisher", :href => "https://plus.google.com/111953119785824514010" }) %> <%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => asset_path("osm.xml") }) %> <%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %> - <%= tag("meta", :property => "og:image", :content => image_path("osm_logo.png")) %> + <%= opengraph_tags %> <% if flash[:piwik_goal] -%> <%= tag("meta", :name => "piwik-goal", :content => flash[:piwik_goal]) %> <% end -%> -- 2.39.5