From 8299c969fb9e21a5533971677bf7bd4613512c17 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 30 Apr 2020 19:57:06 -0500 Subject: [PATCH] Fix #2061: elements for pools. Add and tags to the forum topic show page, the pool show page, and the favgroup show page. This is kind of useless now since Google hasn't used these tags for SEO for years ([1]), and userscripts can use `#paginator-next` and `#paginator-prev` to find the next/prev pages, but whatever. [1]: https://yoast.com/google-doesnt-use-rel-prev-next-for-pagination --- app/views/application/_meta_links.html.erb | 11 +++++++++++ app/views/favorite_groups/show.html.erb | 1 + app/views/forum_topics/show.html.erb | 1 + app/views/layouts/default.html.erb | 9 +-------- app/views/pools/show.html.erb | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 app/views/application/_meta_links.html.erb diff --git a/app/views/application/_meta_links.html.erb b/app/views/application/_meta_links.html.erb new file mode 100644 index 000000000..7b398ed83 --- /dev/null +++ b/app/views/application/_meta_links.html.erb @@ -0,0 +1,11 @@ +<%# collection %> + +<% content_for(:html_header) do %> + <% if collection.try(:prev_page) %> + <%= tag.link rel: "prev", href: url_for(nav_params_for(collection.prev_page)) %> + <% end %> + + <% if collection.try(:next_page) %> + <%= tag.link rel: "next", href: url_for(nav_params_for(collection.next_page)) %> + <% end %> +<% end %> diff --git a/app/views/favorite_groups/show.html.erb b/app/views/favorite_groups/show.html.erb index 43281a872..ee2277728 100644 --- a/app/views/favorite_groups/show.html.erb +++ b/app/views/favorite_groups/show.html.erb @@ -1,4 +1,5 @@ <% page_title "Favgroup: #{@favorite_group.pretty_name}" %> +<%= render "meta_links", collection: @posts %> <%= render "secondary_links" %>
diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index 84b8b1ea5..ecd4fdca0 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -2,6 +2,7 @@ <% meta_description(DText.excerpt(@forum_topic.original_post&.body)) %> <% atom_feed_tag(@forum_topic.title, forum_topic_url(@forum_topic.id, format: :atom)) %> +<%= render "meta_links", collection: @forum_posts %> <%= render "secondary_links" %>
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 3216a50ad..4c8cd4c2a 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -4,14 +4,7 @@ <%= page_title %> - - <% if @current_item.try(:prev_page) %> - <%= tag.link rel: "prev", href: url_for(nav_params_for(@current_item.prev_page)) %> - <% end %> - - <% if @current_item.try(:next_page) %> - <%= tag.link rel: "next", href: url_for(nav_params_for(@current_item.next_page)) %> - <% end %> + <%= render "meta_links", collection: @current_item %> <%= csrf_meta_tag %> <% unless CurrentUser.enable_desktop_mode? %> diff --git a/app/views/pools/show.html.erb b/app/views/pools/show.html.erb index 03047fd21..29dbb1191 100644 --- a/app/views/pools/show.html.erb +++ b/app/views/pools/show.html.erb @@ -1,6 +1,7 @@ <% page_title @pool.pretty_name %> <% meta_description("#{number_with_delimiter(@pool.post_count)} posts. #{DText.excerpt(@pool.description)}") %> +<%= render "meta_links", collection: @posts %> <%= render "secondary_links" %>