You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2022/06/30 22:01:55 UTC
[allura] branch master updated: [#8443] nofollow on links that point to code tool repositories
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 ba5a4d716 [#8443] nofollow on links that point to code tool repositories
ba5a4d716 is described below
commit ba5a4d716a059bef207e8b847f7f2d935f8b6f32
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Mon Jun 27 11:11:47 2022 -0600
[#8443] nofollow on links that point to code tool repositories
---
ForgeActivity/forgeactivity/main.py | 6 ++++--
ForgeActivity/forgeactivity/templates/macros.html | 4 +++-
ForgeActivity/forgeactivity/templates/timeline.html | 1 -
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py
index 9b6399301..a1155a72d 100644
--- a/ForgeActivity/forgeactivity/main.py
+++ b/ForgeActivity/forgeactivity/main.py
@@ -99,6 +99,7 @@ class ForgeActivityController(BaseController):
g.register_app_css('css/activity.css', app=self.app)
def _get_activities_data(self, **kw):
+ noindex_tags = ['git', 'svn', 'hg', 'commit', 'merge-request']
activity_enabled = asbool(config.get('activitystream.enabled', False))
if not activity_enabled:
raise exc.HTTPNotFound()
@@ -148,8 +149,10 @@ class ForgeActivityController(BaseController):
t.actor.activity_extras.icon_url = re.sub(r'([&?])d=[^&]*',
r'\1d={}'.format(default_avatar),
t.actor.activity_extras.icon_url)
+ should_noindex = any(name in noindex_tags for name in t.tags)
+ t.obj.noindex = should_noindex
+ t.target.noindex = should_noindex
session(t).expunge(t) # don't save back these changes
-
if extra_limit == limit:
# if we didn't ask for extra, then we expect there's more if we got all we asked for
has_more = len(timeline) == limit
@@ -329,7 +332,6 @@ class ForgeActivityProfileSection(ProfileSectionBase):
session(activity).expunge(activity)
activity_obj = get_activity_object(activity.obj)
activity.obj.project = getattr(activity_obj, 'project', None)
-
context.update({
'follow_toggle': W.follow_toggle,
'following': g.director.is_connected(c.user, self.user),
diff --git a/ForgeActivity/forgeactivity/templates/macros.html b/ForgeActivity/forgeactivity/templates/macros.html
index 4f877324a..8b08adbf0 100644
--- a/ForgeActivity/forgeactivity/templates/macros.html
+++ b/ForgeActivity/forgeactivity/templates/macros.html
@@ -19,7 +19,9 @@
{% macro activity_obj(o) %}
{% if o.activity_url %}
- <a href="{{o.activity_url}}">{{o.activity_name}}</a>
+ <a href="{{o.activity_url}}"
+ {% if 'noindex' in o and o.noindex %} rel="nofollow" {% endif %}
+ >{{o.activity_name}}</a>
{% else %}
{{o.activity_name}}
{% endif %}
diff --git a/ForgeActivity/forgeactivity/templates/timeline.html b/ForgeActivity/forgeactivity/templates/timeline.html
index c2365d211..37bf126db 100644
--- a/ForgeActivity/forgeactivity/templates/timeline.html
+++ b/ForgeActivity/forgeactivity/templates/timeline.html
@@ -18,7 +18,6 @@
-#}
{% import 'forgeactivity:templates/macros.html' as am with context %}
-
{% for a in timeline %}
<li id="{{a._id}}" data-page="{{page}}" {% if h.has_access(c.project.neighborhood, 'admin') %}data-can-delete{% endif %}>
<time datetime="{{a.published|datetimeformat}}" title="{{a.published|datetimeformat}}">{{h.ago(a.published, show_date_after=None)}}</time>