This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push: new 897e23408 [#8469] added missing canonical tags to user profile, discussion, blog, list and tickets 897e23408 is described below commit 897e234088997f1f07df593c9b70fd365290b828 Author: Guillermo Cruz <guillermo.c...@slashdotmedia.com> AuthorDate: Thu Sep 22 15:05:33 2022 -0600 [#8469] added missing canonical tags to user profile, discussion, blog, list and tickets --- Allura/allura/ext/user_profile/templates/user_index.html | 13 +++++++------ Allura/allura/templates/jinja_master/lib.html | 15 +++++++++------ Allura/allura/templates/tool_list.html | 6 ++++-- ForgeBlog/forgeblog/templates/blog/post.html | 5 +++++ .../forgediscussion/templates/discussionforums/index.html | 7 ++++--- ForgeTracker/forgetracker/templates/tracker/ticket.html | 10 ++++++---- ForgeWiki/forgewiki/templates/wiki/browse_tags.html | 5 +++-- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/Allura/allura/ext/user_profile/templates/user_index.html b/Allura/allura/ext/user_profile/templates/user_index.html index 6d9b238c3..feace956b 100644 --- a/Allura/allura/ext/user_profile/templates/user_index.html +++ b/Allura/allura/ext/user_profile/templates/user_index.html @@ -18,18 +18,19 @@ -#} {% set hide_left_bar = True %} {% extends g.theme.master %} - +{% from 'allura:templates/jinja_master/lib.html' import canonical_tag %} {% block title %}{{user.username}} / Profile{% endblock %} {% block header %}{{ user.display_name|default(user.username) }}{% endblock %} -{% block head %} +{%- block head -%} {% if noindex %} - <meta name="robots" content="noindex, follow"> + <meta name="robots" content="noindex, follow"> {% endif %} - <link rel="alternate" type="application/rss+xml" title="RSS" href="feed.rss"> - <link rel="alternate" type="application/atom+xml" title="Atom" href="feed.atom"> -{% endblock %} + <link rel="alternate" type="application/rss+xml" title="RSS" href="feed.rss"> + <link rel="alternate" type="application/atom+xml" title="Atom" href="feed.atom"> + {{ canonical_tag() }} +{%- endblock -%} {% block actions %} {{ g.icons['feed'].render(href=c.app.url + 'feed.rss', title='Follow', rel='nofollow') }} diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html index 91b4d3e80..1a47884e2 100644 --- a/Allura/allura/templates/jinja_master/lib.html +++ b/Allura/allura/templates/jinja_master/lib.html @@ -884,13 +884,16 @@ This page is based on some examples from Greg Schueler, <a href="mailto:greg@var {%- endmacro %} {% macro canonical_tag(page=None) %} - {# in case is inherithed from a child template and has no access to a page value #} - {% set page = request.GET['page'] if not page and 'page=' in request.query_string else page %} - {% if page == '0' %} - <link rel="canonical" href="{{ h.querystring(request, dict(page=None,limit=None)) }}"/> + {% if not page and not 'page=' in request.query_string %} + <link rel="canonical" href="{{ request.path_url }}" /> {% else %} - <link rel="canonical" href="{{ h.querystring(request, dict(limit=None)) }}"/> - + {# in case is inherithed from a child template and has no access to a page value #} + {% set page = request.GET['page'] if not page and 'page=' in request.query_string else page %} + {% if page == '0' %} + <link rel="canonical" href="{{ h.querystring(request, dict(page=None,limit=None)) }}"/> + {% else %} + <link rel="canonical" href="{{ h.querystring(request, dict(limit=None)) }}"/> + {% endif %} {% endif %} {% endmacro %} diff --git a/Allura/allura/templates/tool_list.html b/Allura/allura/templates/tool_list.html index 499c532af..60cfa4421 100644 --- a/Allura/allura/templates/tool_list.html +++ b/Allura/allura/templates/tool_list.html @@ -18,9 +18,11 @@ -#} {% set hide_left_bar = True %} {% extends g.theme.master %} -{% block head %} +{% from 'allura:templates/jinja_master/lib.html' import canonical_tag %} +{%- block head -%} <meta name="robots" content="noindex, follow"> -{% endblock %} + {{ canonical_tag() }} +{%- endblock -%} {% block title %}{{c.project.name}} / {{type}} tools{% endblock %} diff --git a/ForgeBlog/forgeblog/templates/blog/post.html b/ForgeBlog/forgeblog/templates/blog/post.html index 0b1ff6497..dacb8c1dd 100644 --- a/ForgeBlog/forgeblog/templates/blog/post.html +++ b/ForgeBlog/forgeblog/templates/blog/post.html @@ -17,6 +17,11 @@ under the License. -#} {% extends g.theme.master %} +{% from 'allura:templates/jinja_master/lib.html' import canonical_tag %} + +{%- block head -%} + {{ canonical_tag() }} +{%- endblock -%} {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}}: {{post.title}}{% endblock %} diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/index.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/index.html index 1db6d49f4..74b052111 100644 --- a/ForgeDiscussion/forgediscussion/templates/discussionforums/index.html +++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/index.html @@ -17,15 +17,16 @@ under the License. -#} {% extends g.theme.master %} -{% import 'allura:templates/jinja_master/lib.html' as lib with context %} +{% from 'allura:templates/jinja_master/lib.html' import canonical_tag %} {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}}{% endblock %} -{% block head %} +{%- block head -%} {% if noindex %} <meta name="robots" content="noindex, follow"> {% endif %} -{% endblock %} + {{ canonical_tag() }} +{%- endblock -%} {% block header %}{{c.app.config.options.mount_label}}{% endblock %} diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html index 59bd0a3d3..9136127f5 100644 --- a/ForgeTracker/forgetracker/templates/tracker/ticket.html +++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html @@ -18,16 +18,18 @@ -#} {% extends g.theme.master %} {% from 'allura:templates/jinja_master/lib.html' import abbr_date with context %} +{% from 'allura:templates/jinja_master/lib.html' import canonical_tag %} {% do g.register_forge_css('css/forge/hilite.css') %} {% do g.register_app_css('css/tracker.css') %} {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / #{{ticket.ticket_num}} {{ticket.summary}}{% endblock %} -{% block head %} - <link rel="alternate" type="application/rss+xml" title="RSS" href="feed.rss"/> - <link rel="alternate" type="application/atom+xml" title="Atom" href="feed.atom"/> -{% endblock %} +{%- block head -%} + <link rel="alternate" type="application/rss+xml" title="RSS" href="feed.rss"/> + <link rel="alternate" type="application/atom+xml" title="Atom" href="feed.atom"/> + {{ canonical_tag() }} +{%- endblock -%} {% block header %}#{{ticket.ticket_num}} {{ticket.summary}}{% if ticket.deleted %}<span> (deleted)</span>{% endif %}{% endblock %} diff --git a/ForgeWiki/forgewiki/templates/wiki/browse_tags.html b/ForgeWiki/forgewiki/templates/wiki/browse_tags.html index 7225526b6..77a417493 100644 --- a/ForgeWiki/forgewiki/templates/wiki/browse_tags.html +++ b/ForgeWiki/forgewiki/templates/wiki/browse_tags.html @@ -17,12 +17,13 @@ under the License. -#} {% extends 'forgewiki:templates/wiki/master.html' %} -{% import 'allura:templates/jinja_master/lib.html' as lib with context %} +{% from 'allura:templates/jinja_master/lib.html' import pagination_meta_tags %} {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Browse Labels{% endblock %} {% block head %} {{ super() }} - {{ lib.pagination_meta_tags(request, page, count, limit) }} + <meta name="robots" content="noindex, follow"/> + {{ pagination_meta_tags(request, page, count, limit) }} {% endblock %} {% block header %}Browse Labels{% endblock %}