views: adjust more <meta> descriptions.
* Add <meta> descriptions to more pages. * Adjust wiki/pool/forum pages to use an excerpt of the first paragraph.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
module WikiPagesHelper
|
||||
def wiki_page_excerpt(wiki_page)
|
||||
text = strip_dtext(wiki_page.body).split(/\r\n|\r|\n/).first
|
||||
text.truncate(160)
|
||||
end
|
||||
|
||||
def wiki_page_other_names_list(wiki_page)
|
||||
names_html = wiki_page.other_names.map {|name| link_to(name, "http://www.pixiv.net/search.php?s_mode=s_tag_full&word=#{u(name)}", :class => "wiki-other-name")}
|
||||
names_html.join(" ").html_safe
|
||||
|
||||
@@ -262,9 +262,13 @@ class DText
|
||||
end
|
||||
|
||||
# extract the first paragraph `needle` occurs in.
|
||||
def self.excerpt(dtext, needle)
|
||||
def self.extract_mention(dtext, needle)
|
||||
dtext = dtext.gsub(/\r\n|\r|\n/, "\n")
|
||||
excerpt = ActionController::Base.helpers.excerpt(dtext, needle, separator: "\n\n", radius: 1, omission: "")
|
||||
excerpt
|
||||
end
|
||||
|
||||
def self.excerpt(text, length: 160)
|
||||
strip_dtext(text).split(/\r\n|\r|\n/).first.to_s.truncate(length)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ class Comment < ApplicationRecord
|
||||
mentionable(
|
||||
:message_field => :body,
|
||||
:title => ->(user_name) {"#{creator.name} mentioned you in a comment on post ##{post_id}"},
|
||||
:body => ->(user_name) {"@#{creator.name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.excerpt(body, "@" + user_name)}\n[/quote]\n"}
|
||||
:body => ->(user_name) {"@#{creator.name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n"}
|
||||
)
|
||||
|
||||
api_attributes including: [:creator_name, :updater_name]
|
||||
|
||||
@@ -32,7 +32,7 @@ class ForumPost < ApplicationRecord
|
||||
mentionable(
|
||||
:message_field => :body,
|
||||
:title => ->(user_name) {%{#{creator.name} mentioned you in topic ##{topic_id} (#{topic.title})}},
|
||||
:body => ->(user_name) {%{@#{creator.name} mentioned you in topic ##{topic_id} ("#{topic.title}":[/forum_topics/#{topic_id}?page=#{forum_topic_page}]):\n\n[quote]\n#{DText.excerpt(body, "@" + user_name)}\n[/quote]\n}}
|
||||
:body => ->(user_name) {%{@#{creator.name} mentioned you in topic ##{topic_id} ("#{topic.title}":[/forum_topics/#{topic_id}?page=#{forum_topic_page}]):\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n}}
|
||||
)
|
||||
|
||||
module SearchMethods
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<% meta_description "Search thousands of anime & hentai artists on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<div id="c-artists">
|
||||
<div id="a-index">
|
||||
<%= render "search" %>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<% meta_description "See comments on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<div id="p-index-by-post">
|
||||
<% if !CurrentUser.user.is_builder? %>
|
||||
<div style="margin-bottom: 1em;">
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "Popular Posts" %>
|
||||
<% meta_description "The most popular posts per #{@scale}" %>
|
||||
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
|
||||
<div id="c-explore-posts">
|
||||
@@ -26,7 +28,3 @@
|
||||
<%= post_previews_html(@posts) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="description" content="The most popular posts per <%= @scale %>">
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "Most Viewed" %>
|
||||
<% meta_description "The most viewed posts per #{@scale}" %>
|
||||
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
|
||||
<div id="c-explore-posts">
|
||||
@@ -17,7 +19,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="description" content="The most viewed posts per day">
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% page_title "Favgroup: #{@favorite_group.pretty_name.titleize}" %>
|
||||
<% page_title "Favgroup: #{@favorite_group.pretty_name}" %>
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-favorite-groups">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<% page_title @forum_topic.title %>
|
||||
<% meta_description(DText.excerpt(@forum_topic.original_post&.body)) %>
|
||||
|
||||
<div id="c-forum-topics">
|
||||
<div id="a-show">
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<% meta_description "See thousands of translated anime & hentai comics on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<div id="c-notes">
|
||||
<div id="a-index">
|
||||
<h1>Notes</h1>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% page_title "Pool Comparison: #{@pool_version.pretty_name.titleize}" %>
|
||||
<% page_title "Pool Comparison: #{@pool_version.pretty_name}" %>
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-pool-versions">
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "Pool Gallery" %>
|
||||
<% meta_description "See thousands of translated anime & hentai comics, galleries, doujins, and more on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-pools">
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
<% page_title "Pools" %>
|
||||
<% meta_description "See thousands of translated anime & hentai comics, galleries, doujins, and more on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-pools">
|
||||
<div id="a-index">
|
||||
<%= render "search", :path => pools_path %>
|
||||
@@ -20,9 +25,3 @@
|
||||
<%= numbered_paginator(@pools) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="description" content="Pools are groups of posts with something in common. The most common use of pools is for posts that are part of a series (such as a comic, or a group of images released by an artist).">
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "#{@pool.pretty_name.titleize} | Pool" %>
|
||||
<% page_title @pool.pretty_name %>
|
||||
<% meta_description("#{number_with_delimiter(@pool.post_count)} pages. #{DText.excerpt(@pool.description)}") %>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-pools">
|
||||
@@ -28,7 +30,3 @@
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="description" content="<%= strip_dtext(@pool.description) %>">
|
||||
<% end %>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<% 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}") %>
|
||||
<% meta_description("See over #{number_with_delimiter(@post_set.post_count)} #{@post_set.humanized_tag_string} images on #{Danbooru.config.app_name}. #{DText.excerpt(@post_set.wiki_page&.body)}") %>
|
||||
<% end %>
|
||||
|
||||
<%= tag.link href: posts_path(format: "atom", tags: params[:tags]), rel: "alternate", title: "ATOM", type: "application/atom+xml" %>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title @post.presenter.humanized_essential_tag_string %>
|
||||
<% meta_description "View this #{@post.image_width}x#{@post.image_height} #{number_to_human_size(@post.file_size)} image" %>
|
||||
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
|
||||
<% content_for(:sidebar) do %>
|
||||
@@ -155,7 +157,6 @@
|
||||
<%= post_view_count_js %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<%= tag.meta name: "description", content: "View this #{@post.image_width}x#{@post.image_height} #{number_to_human_size(@post.file_size)} image" %>
|
||||
<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? %>">
|
||||
@@ -174,7 +175,6 @@
|
||||
<% if @post.twitter_card_supported? %>
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<%= tag.meta name: "twitter:site", content: Danbooru.config.twitter_site %>
|
||||
<%= tag.meta name: "twitter:description", content: "View this #{@post.image_width}x#{@post.image_height} #{number_to_human_size(@post.file_size)} image" %>
|
||||
|
||||
<% if @post.visible? %>
|
||||
<%= tag.meta name: "twitter:image", content: @post.open_graph_image_url %>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "Login" %>
|
||||
<% meta_description "Login to #{Danbooru.config.app_name}" %>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-sessions">
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<% meta_description "Search thousands of tags on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<div id="c-tags">
|
||||
<div id="a-index" class="fixed-width-container">
|
||||
<%= render "search" %>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "Account Upgrade" %>
|
||||
<% meta_description "Upgrade to a Gold or Platinum account on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
|
||||
<div id="c-user-upgrades">
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<% page_title "Sign up" %>
|
||||
<% meta_description "Create a new account for free on #{Danbooru.config.app_name}." %>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<div id="c-users">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<% page_title "#{@wiki_page.pretty_title.titleize} Wiki" %>
|
||||
<% meta_description DText.excerpt(@wiki_page.body) %>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
<%= render "sidebar" %>
|
||||
@@ -40,7 +41,3 @@
|
||||
|
||||
<%= render "wiki_pages/posts", wiki_page: @wiki_page %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<%= tag.meta name: "description", content: wiki_page_excerpt(@wiki_page) %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user