views: refactor open graph / twitter <meta> tags.

* Fix og:site to og:site_name.
* Fix open graph properties to use <meta property="...">, not <meta name="...">>
* Set og:type, og:site_name, twitter:site globally (not just on post pages).
* Set og:url.
* Remove unused always-resize-images, report-server <meta> tags from
  post show pages.
This commit is contained in:
evazion
2020-01-26 21:22:30 -06:00
parent aeec46b212
commit aa442121bb
3 changed files with 13 additions and 18 deletions

View File

@@ -61,13 +61,21 @@
window.addthis_config = { ui_click: true };
</script>
<%= tag.meta name: "twitter:title", content: page_title %>
<%= tag.meta name: "og:title", content: page_title %>
<% if meta_description.present? %>
<%= tag.meta name: "description", content: meta_description %>
<%= tag.meta name: "og:description", content: meta_description %>
<%= tag.meta name: "description", content: meta_description %>
<%= tag.meta property: "og:type", content: "website" %>
<%= tag.meta property: "og:site_name", content: Danbooru.config.app_name %>
<%= tag.meta property: "og:title", content: page_title %>
<%= tag.meta property: "og:description", content: meta_description %>
<%= tag.meta property: "og:url", content: request.original_url %>
<% if Danbooru.config.twitter_site.present? %>
<%= tag.meta name: "twitter:site", content: Danbooru.config.twitter_site %>
<%= tag.meta name: "twitter:title", content: page_title %>
<%= tag.meta name: "twitter:description", content: meta_description %>
<% end %>
<%= yield :html_header %>
<%= raw Danbooru.config.custom_html_header_content %>
</head>

View File

@@ -27,9 +27,6 @@
<%= tag.meta name: "canonical", content: posts_url(tags: params[:tags], host: Danbooru.config.hostname, protocol: "https") %>
<%= tag.meta name: "og:type", content: "website" %>
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
<% if @post_set.best_post.present? %>
<%= tag.meta name: "twitter:image", content: @post_set.best_post.open_graph_image_url %>
<%= tag.meta name: "og:image", content: @post_set.best_post.open_graph_image_url %>

View File

@@ -160,22 +160,15 @@
<% content_for(:html_header) do %>
<meta name="post-id" content="<%= @post.id %>">
<meta name="post-has-embedded-notes" content="<%= @post.has_embedded_notes? %>">
<meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
<% if @post.visible? %>
<%= tag.meta name: "og:image", content: @post.open_graph_image_url %>
<% end %>
<% if Danbooru.config.enable_post_search_counts %>
<meta name="report-server" content="<%= Danbooru.config.reportbooru_server %>">
<% end %>
<%= tag.meta name: "canonical", content: post_url(@post, host: Danbooru.config.hostname, protocol: "https") %>
<%# Twitter properties %>
<% if @post.twitter_card_supported? %>
<meta name="twitter:card" content="summary_large_image">
<%= tag.meta name: "twitter:site", content: Danbooru.config.twitter_site %>
<% if @post.visible? %>
<%= tag.meta name: "twitter:image", content: @post.open_graph_image_url %>
@@ -185,7 +178,4 @@
<% if @post.rating == "e" %>
<meta name="rating" content="adult">
<% end %>
<%= tag.meta name: "og:type", content: "website" %>
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
<% end %>