views: update seo title and description of post index page.
Change the title of the post index page to look like this:
"Danbooru: Anime Image Board" (for the front page)
"Kantai Collection Art | Danbooru" (for a tag search)
Change the meta description of the front page to look like this:
Danbooru is the original anime image 'booru. Find over 3.75 million
anime pictures categorized by over 100 million tags.
Change the meta description for a tag search to look like this:
Find over 37,168 Azur Lane images on Danbooru. Azur Lane (碧蓝航线)
(벽람항로) is a Chinese shipgirl-themed side-scrolling shoot 'em up
mobile game developed by Shanghai Manjuu and Xiamen Yongshi...
This commit is contained in:
@@ -269,26 +269,34 @@ module ApplicationHelper
|
|||||||
end.to_h
|
end.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title(title = nil)
|
def page_title(title = nil, suffix: "| #{Danbooru.config.app_name}")
|
||||||
if title.present?
|
if title.present?
|
||||||
content_for(:page_title) { "#{title} | #{Danbooru.config.app_name}" }
|
content_for(:page_title) { "#{title} #{suffix}".strip }
|
||||||
elsif content_for(:page_title).present?
|
elsif content_for(:page_title).present?
|
||||||
content_for(:page_title)
|
content_for(:page_title)
|
||||||
elsif params[:action] == "index"
|
elsif params[:action] == "index"
|
||||||
"#{params[:controller].titleize} | #{Danbooru.config.app_name}"
|
"#{params[:controller].titleize} #{suffix}"
|
||||||
elsif params[:action] == "show"
|
elsif params[:action] == "show"
|
||||||
"#{params[:controller].singularize.titleize} | #{Danbooru.config.app_name}"
|
"#{params[:controller].singularize.titleize} #{suffix}"
|
||||||
elsif params[:action] == "new"
|
elsif params[:action] == "new"
|
||||||
"New #{params[:controller].singularize.titleize} | #{Danbooru.config.app_name}"
|
"New #{params[:controller].singularize.titleize} #{suffix}"
|
||||||
elsif params[:action] == "edit"
|
elsif params[:action] == "edit"
|
||||||
"Edit #{params[:controller].singularize.titleize} | #{Danbooru.config.app_name}"
|
"Edit #{params[:controller].singularize.titleize} #{suffix}"
|
||||||
elsif params[:action] == "search"
|
elsif params[:action] == "search"
|
||||||
"Search #{params[:controller].titleize} | #{Danbooru.config.app_name}"
|
"Search #{params[:controller].titleize} #{suffix}"
|
||||||
else
|
else
|
||||||
"#{Danbooru.config.app_name}/#{params[:controller]}"
|
"#{Danbooru.config.app_name}/#{params[:controller]}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def meta_description(description = nil)
|
||||||
|
if description.present?
|
||||||
|
content_for(:meta_description) { description }
|
||||||
|
elsif content_for(:meta_description).present?
|
||||||
|
content_for(:meta_description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def show_moderation_notice?
|
def show_moderation_notice?
|
||||||
CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 72.hours.ago)
|
CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 72.hours.ago)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module WikiPagesHelper
|
module WikiPagesHelper
|
||||||
def wiki_page_excerpt(wiki_page)
|
def wiki_page_excerpt(wiki_page)
|
||||||
text = strip_dtext(wiki_page.body).split(/\r\n|\r|\n/).first
|
text = strip_dtext(wiki_page.body).split(/\r\n|\r|\n/).first
|
||||||
truncate(text, length: 160)
|
text.truncate(160)
|
||||||
end
|
end
|
||||||
|
|
||||||
def wiki_page_other_names_list(wiki_page)
|
def wiki_page_other_names_list(wiki_page)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def humanized_tag_string
|
def humanized_tag_string
|
||||||
tag_array.slice(0, 25).join(" ").tr("_", " ")
|
tag_array.map { |tag| tag.tr("_", " ").titleize }.to_sentence
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_blank_wiki?
|
def has_blank_wiki?
|
||||||
|
|||||||
@@ -160,10 +160,6 @@ class PostPresenter < Presenter
|
|||||||
PostPresenter.preview(@post)
|
PostPresenter.preview(@post)
|
||||||
end
|
end
|
||||||
|
|
||||||
def humanized_tag_string
|
|
||||||
@post.tag_string.split(/ /).slice(0, 25).join(", ").tr("_", " ")
|
|
||||||
end
|
|
||||||
|
|
||||||
def humanized_essential_tag_string
|
def humanized_essential_tag_string
|
||||||
@humanized_essential_tag_string ||= tag_set_presenter.humanized_essential_tag_string(default: "##{@post.id}")
|
@humanized_essential_tag_string ||= tag_set_presenter.humanized_essential_tag_string(default: "##{@post.id}")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
"@type": "WebSite",
|
"@type": "WebSite",
|
||||||
"name": "<%= Danbooru.config.app_name %>",
|
"name": "<%= Danbooru.config.app_name %>",
|
||||||
"alternateName": "<%= Danbooru.config.description %>",
|
"alternateName": "Anime Image Board",
|
||||||
"url" : "<%= root_url %>"
|
"url" : "<%= root_url %>"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -76,6 +76,11 @@
|
|||||||
</script>
|
</script>
|
||||||
<%= tag.meta name: "twitter:title", content: page_title %>
|
<%= tag.meta name: "twitter:title", content: page_title %>
|
||||||
<%= tag.meta name: "og: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: "twitter:description", content: meta_description %>
|
||||||
|
<% end %>
|
||||||
<%= yield :html_header %>
|
<%= yield :html_header %>
|
||||||
<%= raw Danbooru.config.custom_html_header_content %>
|
<%= raw Danbooru.config.custom_html_header_content %>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -58,20 +58,6 @@
|
|||||||
<%= render "posts/partials/common/secondary_links" %>
|
<%= render "posts/partials/common/secondary_links" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% content_for(:page_title) do %>
|
|
||||||
<% if @post_set.tag_string.present? %>
|
|
||||||
<%= @post_set.humanized_tag_string %> - <%= Danbooru.config.app_name %>
|
|
||||||
<% else %>
|
|
||||||
<%= Danbooru.config.app_name %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
<% content_for(:html_header) do %>
|
||||||
<%= tag.link href: posts_path(format: "atom", tags: params[:tags]), rel: "alternate", title: "ATOM", type: "application/atom+xml" %>
|
|
||||||
<%= tag.link rel: "next", href: next_page_url %>
|
|
||||||
<% if prev_page_url %>
|
|
||||||
<%= tag.link rel: "prev", href: prev_page_url %>
|
|
||||||
<% end %>
|
|
||||||
<%= missed_post_search_count_js %>
|
|
||||||
<%= render "posts/partials/index/seo_meta_tags" %>
|
<%= render "posts/partials/index/seo_meta_tags" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
<% if @post_set.is_empty_tag? %>
|
||||||
|
<% page_title("#{Danbooru.config.app_name}: Anime Image Board", suffix: nil) %>
|
||||||
|
<% meta_description("#{Danbooru.config.canonical_app_name} is the original anime image 'booru. Find over 3.75 million anime pictures categorized by over 100 million tags.") %>
|
||||||
|
<% else %>
|
||||||
|
<% page_title("#{@post_set.humanized_tag_string} Art") %>
|
||||||
|
<% meta_description("Find over #{number_with_delimiter(@post_set.post_count)} #{@post_set.humanized_tag_string} images on #{Danbooru.config.app_name}. #{wiki_page_excerpt(@post_set.wiki_page) if @post_set.wiki_page}") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= tag.link href: posts_path(format: "atom", tags: params[:tags]), rel: "alternate", title: "ATOM", type: "application/atom+xml" %>
|
||||||
|
<%= tag.link rel: "next", href: next_page_url %>
|
||||||
|
<% if prev_page_url %>
|
||||||
|
<%= tag.link rel: "prev", href: prev_page_url %>
|
||||||
|
<% end %>
|
||||||
|
<%= missed_post_search_count_js %>
|
||||||
|
|
||||||
<% if @post_set.hide_from_crawler? %>
|
<% if @post_set.hide_from_crawler? %>
|
||||||
<meta name="robots" content="nofollow,noindex">
|
<meta name="robots" content="nofollow,noindex">
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -8,20 +23,6 @@
|
|||||||
|
|
||||||
<%= tag.meta name: "canonical", content: posts_url(tags: params[:tags], host: Danbooru.config.hostname, protocol: "https") %>
|
<%= tag.meta name: "canonical", content: posts_url(tags: params[:tags], host: Danbooru.config.hostname, protocol: "https") %>
|
||||||
|
|
||||||
<% if @post_set.is_single_tag? %>
|
|
||||||
<% "Find #{@post_set.post_count} images of #{@post_set.humanized_tag_string.titleize} on #{Danbooru.config.app_name}".tap do |desc| %>
|
|
||||||
<%= tag.meta name: "description", content: desc %>
|
|
||||||
<%= tag.meta name: "og:description", content: desc %>
|
|
||||||
<%= tag.meta name: "twitter:description", content: desc %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<% Danbooru.config.description.tap do |desc| %>
|
|
||||||
<%= tag.meta name: "description", content: desc %>
|
|
||||||
<%= tag.meta name: "og:description", content: desc %>
|
|
||||||
<%= tag.meta name: "twitter:description", content: desc %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= tag.meta name: "og:type", content: "website" %>
|
<%= tag.meta name: "og:type", content: "website" %>
|
||||||
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
|
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="addthis_toolbox addthis_default_style addthis_32x32_style"
|
<div class="addthis_toolbox addthis_default_style addthis_32x32_style"
|
||||||
addthis:title="Find more art about <%= @post_set.humanized_tag_string %> on <%= Danbooru.config.app_name %>">
|
addthis:title="Find over <%= @post_set.post_count %> <%= @post_set.humanized_tag_string %> images on <%= Danbooru.config.app_name %>">
|
||||||
<a class="addthis_button_twitter"></a>
|
<a class="addthis_button_twitter"></a>
|
||||||
<a class="addthis_button_facebook"></a>
|
<a class="addthis_button_facebook"></a>
|
||||||
<a class="addthis_button_reddit"></a>
|
<a class="addthis_button_reddit"></a>
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ module Danbooru
|
|||||||
"Danbooru"
|
"Danbooru"
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
|
||||||
"Find good anime art fast"
|
|
||||||
end
|
|
||||||
|
|
||||||
# The canonical hostname of the site.
|
# The canonical hostname of the site.
|
||||||
def hostname
|
def hostname
|
||||||
Socket.gethostname
|
Socket.gethostname
|
||||||
|
|||||||
Reference in New Issue
Block a user