Show ⚠️ icon on /admin when an article is not indexed on search engines (#20713)
* Add in icon when an article is not indexed on admin * tests * rubocop * rubocop
This commit is contained in:
parent
3e337e9cf3
commit
751e9d70d2
6 changed files with 73 additions and 1 deletions
1
app/assets/images/twemoji/warning.svg
Normal file
1
app/assets/images/twemoji/warning.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><path fill="#FFCC4D" d="M2.653 35C.811 35-.001 33.662.847 32.027L16.456 1.972c.849-1.635 2.238-1.635 3.087 0l15.609 30.056c.85 1.634.037 2.972-1.805 2.972H2.653z"/><path fill="#231F20" d="M15.583 28.953c0-1.333 1.085-2.418 2.419-2.418 1.333 0 2.418 1.085 2.418 2.418 0 1.334-1.086 2.419-2.418 2.419-1.334 0-2.419-1.085-2.419-2.419zm.186-18.293c0-1.302.961-2.108 2.232-2.108 1.241 0 2.233.837 2.233 2.108v11.938c0 1.271-.992 2.108-2.233 2.108-1.271 0-2.232-.807-2.232-2.108V10.66z"/></svg>
|
||||
|
After Width: | Height: | Size: 548 B |
|
|
@ -638,6 +638,15 @@ class Article < ApplicationRecord
|
|||
score < -1
|
||||
end
|
||||
|
||||
def skip_indexing_reason
|
||||
return "unpublished" unless published
|
||||
return "negative_score" if score < -1
|
||||
return "below_minimum_score" if score < Settings::UserExperience.index_minimum_score && !featured
|
||||
return "below_minimum_date" if published_at.to_i < Settings::UserExperience.index_minimum_date.to_i
|
||||
|
||||
"unknown"
|
||||
end
|
||||
|
||||
def privileged_reaction_counts
|
||||
@privileged_reaction_counts ||= reactions.privileged_category.group(:category).count
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,7 +46,13 @@
|
|||
<%= article.title %>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="flex items-center gap-1">
|
||||
<div class="flex items-stretch gap-1">
|
||||
<% if article.skip_indexing? %>
|
||||
<span class="crayons-card crayons-card--secondary px-3 py-1 flex items-center" title="<%= t("views.admin.articles.noindex.reason") %><%= t("views.admin.articles.noindex.reasons." + article.skip_indexing_reason) %>">
|
||||
<%= crayons_icon_tag("twemoji/warning", native: true, width: 18, height: 18) %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<span class="crayons-card crayons-card--secondary px-3 py-1 flex gap-2 items-center" title="<%= t("views.moderations.actions.thumb_up") %>">
|
||||
<%= crayons_icon_tag("twemoji/thumb-up", native: true, width: 16, height: 16) %>
|
||||
<span class="fs-s fw-medium lh-base"><%= article.privileged_reaction_counts["thumbsup"] || "0" %></span>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ en:
|
|||
no_flags: Article has no flags.
|
||||
no_quality_reactions: Article has no quality reactions by trusted users.
|
||||
title: Moderator actions
|
||||
noindex:
|
||||
reason: "Not indexed on search engines: "
|
||||
reasons:
|
||||
unpublished: Unpublished
|
||||
below_minimum_score: Below minimum indexing score and not featured
|
||||
below_minimum_date: Published before minimum index date
|
||||
negative_score: Negative score
|
||||
unknown: Unknown
|
||||
comments:
|
||||
flags:
|
||||
score: Score affected by a particular flag
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ fr:
|
|||
no_flags: Article has no flags.
|
||||
no_quality_reactions: Article has no quality reactions by trusted users.
|
||||
title: Moderator actions
|
||||
noindex:
|
||||
reason: "Non indexé sur les moteurs de recherche: "
|
||||
reasons:
|
||||
unpublished: Non publié
|
||||
below_minimum_score: En dessous du score d'indexation minimum et non présenté
|
||||
below_minimum_date: Publié avant la date d'indexation minimale
|
||||
negative_score: Note négative
|
||||
unknown: Inconnue
|
||||
comments:
|
||||
flags:
|
||||
score: Score affecté par un drapeau particulier
|
||||
|
|
|
|||
|
|
@ -1632,4 +1632,44 @@ RSpec.describe Article do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#skip_indexing_reason" do
|
||||
before do
|
||||
allow(Settings::UserExperience).to receive_messages(
|
||||
index_minimum_score: 5,
|
||||
index_minimum_date: 2.days.ago.to_i,
|
||||
)
|
||||
end
|
||||
|
||||
it "returns reasons.unpublished for unpublished articles" do
|
||||
article.published = false
|
||||
expect(article.skip_indexing_reason).to eq("unpublished")
|
||||
end
|
||||
|
||||
it "returns reasons.below_minimum_score for articles with score below minimum and not featured" do
|
||||
article.published = true
|
||||
article.score = 3
|
||||
article.featured = false
|
||||
expect(article.skip_indexing_reason).to eq("below_minimum_score")
|
||||
end
|
||||
|
||||
it "returns reasons.below_minimum_date for articles published before the minimum date" do
|
||||
article.published_at = 3.days.ago
|
||||
article.score = 5
|
||||
expect(article.skip_indexing_reason).to eq("below_minimum_date")
|
||||
end
|
||||
|
||||
it "returns reasons.negative_score for articles with a negative score" do
|
||||
article.score = -2
|
||||
expect(article.skip_indexing_reason).to eq("negative_score")
|
||||
end
|
||||
|
||||
it "returns reasons.none for articles that do not meet any skip criteria" do
|
||||
article.published = true
|
||||
article.score = 6
|
||||
article.featured = true
|
||||
article.published_at = 1.day.ago
|
||||
expect(article.skip_indexing_reason).to eq("unknown")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue