You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2022/09/22 21:05:41 UTC
[allura] 01/01: [#8469] added missing canonical tags to user profile, discussion, blog, list and tickets
This is an automated email from the ASF dual-hosted git repository.
gcruz pushed a commit to branch gc/8469
in repository https://gitbox.apache.org/repos/asf/allura.git
commit dd98fc6fcf88c4e984ef09d628cec55f8ebec9df
Author: Guillermo Cruz <gu...@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 | 5 +++++
ForgeBlog/forgeblog/templates/blog/post.html | 5 +++++
.../forgediscussion/templates/discussionforums/index.html | 5 +++--
ForgeTracker/forgetracker/templates/tracker/ticket.html | 10 ++++++----
6 files changed, 35 insertions(+), 18 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..3678b5fbd 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 %}
-
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
{% 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">
+ {{ lib.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 e3f2f4486..3a3287dc9 100644
--- a/Allura/allura/templates/tool_list.html
+++ b/Allura/allura/templates/tool_list.html
@@ -19,6 +19,11 @@
{% set hide_left_bar = True %}
{% extends g.theme.master %}
+{%- block head -%}
+ <meta name="robots" content="noindex, follow"/>
+ <link rel="canonical" href="{{ request.host_url }}/{{ prefix }}{{ c.project.shortname }}/{{ type|lower }}" />
+{%- endblock -%}
+
{% block title %}{{c.project.name}} / {{type}} tools{% endblock %}
{% block extra_css %}
diff --git a/ForgeBlog/forgeblog/templates/blog/post.html b/ForgeBlog/forgeblog/templates/blog/post.html
index 0b1ff6497..d89063c80 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 %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+{%- block head -%}
+ {{ lib.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..7e3b97791 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/index.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/index.html
@@ -21,11 +21,12 @@
{% 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 %}
+ {{ lib.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..4cc747e23 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 with context %}
{% 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"/>
+ {{ lib.canonical_tag() }}
+{%- endblock -%}
{% block header %}#{{ticket.ticket_num}} {{ticket.summary}}{% if ticket.deleted %}<span> (deleted)</span>{% endif %}{% endblock %}