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/06/27 17:12:05 UTC

[allura] branch gc/8443 updated (65b3491be -> 32e0963db)

This is an automated email from the ASF dual-hosted git repository.

gcruz pushed a change to branch gc/8443
in repository https://gitbox.apache.org/repos/asf/allura.git


 discard 65b3491be [#8443] included nofollow attr to public links in user profile and activity
     new 32e0963db [#8443] nofollow on links that point to code tool repositories

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (65b3491be)
            \
             N -- N -- N   refs/heads/gc/8443 (32e0963db)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Allura/allura/ext/user_profile/templates/sections/projects.html | 2 +-
 Allura/allura/ext/user_profile/templates/sections/tools.html    | 4 ++--
 Allura/allura/model/project.py                                  | 9 +++++++++
 ForgeActivity/forgeactivity/main.py                             | 4 +++-
 ForgeActivity/forgeactivity/templates/macros.html               | 8 +++++---
 5 files changed, 20 insertions(+), 7 deletions(-)


[allura] 01/01: [#8443] nofollow on links that point to code tool repositories

Posted by gc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gcruz pushed a commit to branch gc/8443
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 32e0963db13e8fc06167d8d6a1fc64b25c65e409
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
---
 Allura/allura/model/project.py                    | 9 +++++++++
 ForgeActivity/forgeactivity/main.py               | 4 +++-
 ForgeActivity/forgeactivity/templates/macros.html | 4 +++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 0e35ae309..0fc0e7529 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -337,6 +337,15 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
     def get_tool_data(self, tool, key, default=None):
         return self.tool_data.get(tool, {}).get(key, default)
 
+    def noindex_tool_name(self, activity_url, tools=None):
+        noindex_tool_names = ['git', 'svn', 'hg']
+        tools = self.app_configs if tools is None else tools
+        for c in tools:
+            if hasattr(c, 'tool_name') and c.tool_name in noindex_tool_names:
+                if c.options.mount_point in activity_url:
+                    return True
+        return False
+
     def set_tool_data(self, tool, **kw):
         d = self.tool_data.setdefault(tool, {})
         d.update(kw)
diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py
index 9b6399301..986102fa3 100644
--- a/ForgeActivity/forgeactivity/main.py
+++ b/ForgeActivity/forgeactivity/main.py
@@ -148,6 +148,7 @@ class ForgeActivityController(BaseController):
                     t.actor.activity_extras.icon_url = re.sub(r'([&?])d=[^&]*',
                                                               r'\1d={}'.format(default_avatar),
                                                               t.actor.activity_extras.icon_url)
+            t.obj.noindex = followee.noindex_tool_name(activity_obj.activity_url)
             session(t).expunge(t)  # don't save back these changes
 
         if extra_limit == limit:
@@ -329,7 +330,8 @@ class ForgeActivityProfileSection(ProfileSectionBase):
             session(activity).expunge(activity)
             activity_obj = get_activity_object(activity.obj)
             activity.obj.project = getattr(activity_obj, 'project', None)
-
+            if hasattr(c, 'project'):
+                activity.obj.noindex = c.project.noindex_tool_name(activity.obj.activity_url)
         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 %}