You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2022/06/30 20:45:54 UTC
[allura] 01/02: [#8442] added nofollow to links inside code repositories including the sidebar
This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 2e5f24b9de697ef4fb8c2b76edc2e1700ca69d9d
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Wed Jun 22 12:56:50 2022 -0600
[#8442] added nofollow to links inside code repositories including the sidebar
---
Allura/allura/lib/repository.py | 26 ++++++++++++++--------
Allura/allura/templates/jinja_master/lib.html | 4 ++--
Allura/allura/templates/repo/commit.html | 12 +++++-----
Allura/allura/templates/repo/commit_basic.html | 18 +++++++--------
Allura/allura/templates/repo/diff.html | 6 ++---
Allura/allura/templates/repo/file.html | 4 ++--
Allura/allura/templates/repo/forks.html | 2 +-
Allura/allura/templates/repo/merge_request.html | 8 +++----
Allura/allura/templates/repo/merge_requests.html | 10 ++++-----
Allura/allura/templates/repo/repo_master.html | 2 +-
Allura/allura/templates/repo/tags.html | 2 +-
Allura/allura/templates/repo/tarball.html | 2 +-
Allura/allura/templates/repo/tree.html | 4 ++--
.../allura/templates/widgets/repo/tree_widget.html | 10 ++++-----
14 files changed, 59 insertions(+), 51 deletions(-)
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 36eb3d7bc..24789f971 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -129,21 +129,25 @@ class RepositoryApp(Application):
links = []
if not self.repo.is_empty():
links.append(SitemapEntry('Browse Commits', c.app.url + 'commit_browser',
- ui_icon=g.icons['browse_commits']))
+ ui_icon=g.icons['browse_commits'],
+ extra_html_attrs=dict(rel='nofollow')))
if self.forkable and self.repo.status == 'ready' and not self.repo.is_empty():
links.append(
- SitemapEntry('Fork', c.app.url + 'fork', ui_icon=g.icons['fork']))
+ SitemapEntry('Fork', c.app.url + 'fork', ui_icon=g.icons['fork'],
+ extra_html_attrs=dict(rel='nofollow')))
merge_request_count = self.repo.merge_requests_by_statuses(
'open').count()
if self.forkable:
links += [
SitemapEntry(
'Merge Requests', c.app.url + 'merge-requests/',
- small=merge_request_count)]
+ small=merge_request_count,
+ extra_html_attrs=dict(rel='nofollow'))]
if self.repo.forks:
links += [
SitemapEntry('Forks', c.app.url + 'forks/',
- small=len(self.repo.forks))
+ small=len(self.repo.forks),
+ extra_html_attrs=dict(rel='nofollow'))
]
has_upstream_repo = False
@@ -170,14 +174,14 @@ class RepositoryApp(Application):
if getattr(c, 'revision', None):
merge_url = merge_url + '?branch=' + h.urlquote(c.revision)
links.append(SitemapEntry('Request Merge', merge_url,
- ui_icon=g.icons['merge'],
+ ui_icon=g.icons['merge'], extra_html_attrs=dict(rel='nofollow')
))
pending_upstream_merges = self.repo.pending_upstream_merges()
if pending_upstream_merges:
links.append(SitemapEntry(
'Pending Merges',
self.repo.upstream_repo.name + 'merge-requests/',
- small=pending_upstream_merges))
+ small=pending_upstream_merges, extra_html_attrs=dict(rel='nofollow')))
ref_url = self.repo.url_for_commit(
self.default_branch_name, url_type='ref')
branches = self.repo.get_branches()
@@ -192,17 +196,19 @@ class RepositoryApp(Application):
for branch in branches[:max_branches]:
links.append(SitemapEntry(
branch.name,
- h.urlquote(self.repo.url_for_commit(branch.name) + 'tree/')))
+ h.urlquote(self.repo.url_for_commit(branch.name) + 'tree/'),
+ extra_html_attrs=dict(rel='nofollow')))
if len(branches) > max_branches:
links.append(
SitemapEntry(
'More Branches',
ref_url + 'branches/',
+ extra_html_attrs=dict(rel='nofollow')
))
elif not self.repo.is_empty():
# SVN repos, for example, should have a sidebar link to get to the main view
links.append(
- SitemapEntry('Browse Files', c.app.url)
+ SitemapEntry('Browse Files', c.app.url, extra_html_attrs=dict(rel='nofollow'))
)
tags = self.repo.get_tags()
@@ -212,12 +218,14 @@ class RepositoryApp(Application):
for b in tags[:max_tags]:
links.append(SitemapEntry(
b.name,
- h.urlquote(self.repo.url_for_commit(b.name) + 'tree/')))
+ h.urlquote(self.repo.url_for_commit(b.name) + 'tree/'),
+ extra_html_attrs=dict(rel='nofollow')))
if len(tags) > max_tags:
links.append(
SitemapEntry(
'More Tags',
ref_url + 'tags/',
+ extra_html_attrs=dict(rel='nofollow')
))
return links
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index 250682e49..41689b43f 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -174,10 +174,10 @@
{% macro path_links(parts) %}
{% if parts != [''] %}
- <a href="{{'./' + '../' * parts|length }}"><b class="fa fa-folder-open-o" title="Root directory"></b></a> /
+ <a href="{{'./' + '../' * parts|length }}" rel="nofollow"><b class="fa fa-folder-open-o" title="Root directory"></b></a> /
{% endif %}
{% for part in parts %}
- <a href="{{'./' + '../' * loop.revindex0 }}">{{part}}</a> /
+ <a href="{{'./' + '../' * loop.revindex0 }}" rel="nofollow">{{part}}</a> /
{% endfor %}
{% endmacro %}
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index 781164182..b00b9a7b5 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -27,12 +27,12 @@
{% endblock %}
{% block header -%}
-Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
+Commit <a href="{{commit.url()}}" rel="nofollow">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
{%- endblock %}
{% block actions %}
{{ lib.maximize_content_button() }}
-{{ g.icons['history'].render(href='{}log/'.format(commit.url()), show_title=True) }}
+{{ g.icons['history'].render(href='{}log/'.format(commit.url()), show_title=True, rel='nofollow') }}
{% endblock %}
{% block body_top_js %}
@@ -144,7 +144,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
<h6>
{% if type in ('added', 'changed') %}
{% set file_url = commit.url() + 'tree/' + h.urlquote(h.really_unicode(file)) %}
- <a href="{{ file_url }}">{{h.really_unicode(file)}}</a>
+ <a href="{{ file_url }}" rel="nofollow">{{h.really_unicode(file)}}</a>
{% if obj_type != 'tree' and is_text %}
{% set diff_url = file_url + '?barediff=' + (prev[0]._id if prev else '') %}
<a class="commit-diff-link" rel="nofollow" href="{{ diff_url.replace('?barediff=', '?diff=') }}">Diff</a>
@@ -152,12 +152,12 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
{% endif %}
{% elif type == 'removed' %}
{% set file_url = prev[0].url() + 'tree/' + h.urlquote(h.really_unicode(file)) %}
- <a href="{{ file_url }}">{{h.really_unicode(file)}}</a>
+ <a href="{{ file_url }}" rel="nofollow">{{h.really_unicode(file)}}</a>
{% elif type in ('copied', 'renamed') %}
- <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}">{{h.really_unicode(file.old)}}</a>
+ <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}" rel="nofollow">{{h.really_unicode(file.old)}}</a>
to
{% set new_file_url = commit.url() + 'tree/' + h.urlquote(h.really_unicode(file.new)) %}
- <a href="{{ new_file_url }}">{{h.really_unicode(file.new)}}</a>
+ <a href="{{ new_file_url }}" rel="nofollow">{{h.really_unicode(file.new)}}</a>
{% if file.ratio != 1 %}
{% set diff_url = new_file_url + '?barediff=' + (prev[0]._id if prev else '') + '&prev_file=' + h.urlquote(h.really_unicode(file['old'])) %}
<a class="commit-diff-link" rel="nofollow" href="{{ diff_url.replace('?barediff=', '?diff=') }}">Diff</a>
diff --git a/Allura/allura/templates/repo/commit_basic.html b/Allura/allura/templates/repo/commit_basic.html
index c023822b0..d7db8157e 100644
--- a/Allura/allura/templates/repo/commit_basic.html
+++ b/Allura/allura/templates/repo/commit_basic.html
@@ -22,28 +22,28 @@
{% for diff in commit.diffs.added %}
<tr>
<td>add</td>
- <td><a href="{{commit.url()}}tree/{{h.really_unicode(diff)}}">{{h.really_unicode(diff)}}</a></td>
+ <td><a href="{{commit.url()}}tree/{{h.really_unicode(diff)}}" rel="nofollow">{{h.really_unicode(diff)}}</a></td>
</tr>
{% endfor %}{% for diff in commit.diffs.removed %}
<tr>
<td>remove</td>
- <td><a href="{{prev[0].url()}}tree/{{h.really_unicode(diff)}}">{{h.really_unicode(diff)}}</a></td>
+ <td><a href="{{prev[0].url()}}tree/{{h.really_unicode(diff)}}" rel="nofollow">{{h.really_unicode(diff)}}</a></td>
</tr>
{% endfor %}{% for diff in commit.diffs.changed %}
<tr>
<td>change</td>
<td>
- <a href="{{commit.url()}}tree/{{h.really_unicode(diff)}}">{{h.really_unicode(diff)}}</a>
- <a href="{{commit.url()}}tree/{{h.really_unicode(diff)}}?diff={{prev[0]._id}}">(diff)</a>
+ <a href="{{commit.url()}}tree/{{h.really_unicode(diff)}}" rel="nofollow">{{h.really_unicode(diff)}}</a>
+ <a href="{{commit.url()}}tree/{{h.really_unicode(diff)}}?diff={{prev[0]._id}}" rel="nofollow">(diff)</a>
</td>
</tr>
{% endfor %}{% for diff in commit.diffs.copied %}
<tr>
<td>copy</td>
<td>
- <a href="{{prev[0].url()}}tree/{{h.really_unicode(diff.old)}}">{{h.really_unicode(diff.old)}}</a>
+ <a href="{{prev[0].url()}}tree/{{h.really_unicode(diff.old)}}" rel="nofollow">{{h.really_unicode(diff.old)}}</a>
<br/>to<br/>
- <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}">{{h.really_unicode(diff.new)}}</a>
+ <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}" rel="nofollow">{{h.really_unicode(diff.new)}}</a>
</td>
</tr>
{% endfor %}{% for diff in commit.diffs.renamed %}
@@ -54,13 +54,13 @@
<td>rename</td>
{% endif %}
<td>
- <a href="{{prev[0].url()}}tree/{{h.really_unicode(diff.old)}}">{{h.really_unicode(diff.old)}}</a>
+ <a href="{{prev[0].url()}}tree/{{h.really_unicode(diff.old)}}" rel="nofollow">{{h.really_unicode(diff.old)}}</a>
<br/>to<br/>
- <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}">{{h.really_unicode(diff.new)}}</a>
+ <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}" rel="nofollow">{{h.really_unicode(diff.new)}}</a>
</td>
<td>
{% if diff.ratio < 1 %}
- <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}?diff={{prev[0]._id}}?prev-file={{h.really_unicode(diff.old)}}">(diff)</a>
+ <a href="{{commit.url()}}tree/{{h.really_unicode(diff.new)}}?diff={{prev[0]._id}}?prev-file={{h.really_unicode(diff.old)}}" rel="nofollow">(diff)</a>
{% endif %}
</td>
</tr>
diff --git a/Allura/allura/templates/repo/diff.html b/Allura/allura/templates/repo/diff.html
index 87ad53b6e..df74c6c66 100644
--- a/Allura/allura/templates/repo/diff.html
+++ b/Allura/allura/templates/repo/diff.html
@@ -26,14 +26,14 @@
{% endblock %}
{% block header %}Diff of
-<a href="{{b.url()}}">{{b.path()}}</a>
+<a href="{{b.url()}}" rel="nofollow">{{b.path()}}</a>
{% if a %}
-<a href="{{a.url()}}">{{a.commit.shorthand_id()}}</a>
+<a href="{{a.url()}}" rel="nofollow">{{a.commit.shorthand_id()}}</a>
{% else %}
[000000]
{% endif %}
..
-<a href="{{b.url()}}">{{b.commit.shorthand_id()}}</a>
+<a href="{{b.url()}}" rel="nofollow">{{b.commit.shorthand_id()}}</a>
{% endblock %}
{% block actions %}
diff --git a/Allura/allura/templates/repo/file.html b/Allura/allura/templates/repo/file.html
index 8acb678b1..42f8bb20a 100644
--- a/Allura/allura/templates/repo/file.html
+++ b/Allura/allura/templates/repo/file.html
@@ -27,13 +27,13 @@
{% endblock %}
{% block header %}
-<a href="{{blob.commit.url()}}">{{blob.commit.shorthand_id()}}</a>:
+<a href="{{blob.commit.url()}}" rel="nofollow">{{blob.commit.shorthand_id()}}</a>:
{{lib.path_links(blob.path().split('/')[1:-1])}} {{h.really_unicode(blob.name)}}
{% endblock %}
{% block actions %}
{{ lib.maximize_content_button() }}
-{{ g.icons['history'].render(href='%slog/?path=%s' % (blob.commit.url(), blob.path()), show_title=True) }}
+{{ g.icons['history'].render(href='%slog/?path=%s' % (blob.commit.url(), blob.path()), show_title=True, rel='nofollow') }}
{% endblock %}
{% block extra_js %}
diff --git a/Allura/allura/templates/repo/forks.html b/Allura/allura/templates/repo/forks.html
index 089abb9c0..a55af9c93 100644
--- a/Allura/allura/templates/repo/forks.html
+++ b/Allura/allura/templates/repo/forks.html
@@ -25,7 +25,7 @@
{% block content %}
<ul>
{% for link in links %}
-<li><a href="{{link.repo_url}}">{{link.repo}}</a></li>
+<li><a href="{{link.repo_url}}" rel="nofollow">{{link.repo}}</a></li>
{% endfor %}
</ul>
{% endblock %}
diff --git a/Allura/allura/templates/repo/merge_request.html b/Allura/allura/templates/repo/merge_request.html
index a4027d317..61a4de8e3 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -58,9 +58,9 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
{% if req.downstream_repo %}
<p>
- <a href="{{req.creator_url}}">{{req.creator_name}}</a>
+ <a href="{{req.creator_url}}" rel="nofollow">{{req.creator_name}}</a>
wants to merge {{h.text.plural(commits|count, 'commit', 'commits')}}
- from <a href="{{req.downstream_url}}">{{req.downstream_url}}</a>
+ from <a href="{{req.downstream_url}}" rel="nofollow">{{req.downstream_url}}</a>
to {{ req.target_branch }},
{{lib.abbr_date(req.mod_date)}}
</p>
@@ -70,7 +70,7 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
{% if error %}
<div class='grid-19 error'>
Can't find commits to merge. Please checkout
- <a href="{{req.downstream_url}}">{{req.downstream_url}}</a>
+ <a href="{{req.downstream_url}}" rel="nofollow">{{req.downstream_url}}</a>
and follow the instructions to merge manually.
</div>
{% endif %}
@@ -145,7 +145,7 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
{% else %}
<p>
Original repository by
- <a href="{{req.creator_url}}">{{req.creator_name}}</a>
+ <a href="{{req.creator_url}}" rel="nofollow">{{req.creator_name}}</a>
is deleted
</p>
<div>{{g.markdown.convert(req.description)}}</div>
diff --git a/Allura/allura/templates/repo/merge_requests.html b/Allura/allura/templates/repo/merge_requests.html
index 2d6b8ae81..8ca297ca7 100644
--- a/Allura/allura/templates/repo/merge_requests.html
+++ b/Allura/allura/templates/repo/merge_requests.html
@@ -53,15 +53,15 @@
<tbody>
{% for req in requests %}
<tr>
- <td><a href="{{req.request_number}}/">{{req.request_number}}</a></td>
- <td><a href="{{req.request_number}}/">{{req.status}}</a></td>
- <td><a href="{{req.request_number}}/">{{req.summary}}</a></td>
+ <td><a href="{{req.request_number}}/" rel="nofollow">{{req.request_number}}</a></td>
+ <td><a href="{{req.request_number}}/" rel="nofollow">{{req.status}}</a></td>
+ <td><a href="{{req.request_number}}/" rel="nofollow">{{req.summary}}</a></td>
<td>{% if req.downstream_repo %}
- <a href="{{req.downstream_url}}">{{req.downstream_url}}</a>
+ <a href="{{req.downstream_url}}" rel="nofollow">{{req.downstream_url}}</a>
{% else %}
<i>(deleted)</i>
{% endif %}</td>
- <td><a href="{{req.creator_url}}">{{req.creator_name}}</a></td>
+ <td><a href="{{req.creator_url}}" rel="nofollow">{{req.creator_name}}</a></td>
<td>{{lib.abbr_date(req.created)}}</td>
<td>{{lib.abbr_date(req.mod_date)}}</td>
</tr>
diff --git a/Allura/allura/templates/repo/repo_master.html b/Allura/allura/templates/repo/repo_master.html
index 53e729691..e6f5b3a9f 100644
--- a/Allura/allura/templates/repo/repo_master.html
+++ b/Allura/allura/templates/repo/repo_master.html
@@ -69,7 +69,7 @@
$.get('{{repo.url()}}status', function(data) {
if (data.status === 'ready') {
$('.spinner').hide()
- $('#repo_status h2').html('Repo status: ready. <a href=".">Click here to refresh this page.</a>');
+ $('#repo_status h2').html('Repo status: ready. <a href="." rel="nofollow">Click here to refresh this page.</a>');
}
else {
$('#repo_status h2 span').html(data.status);
diff --git a/Allura/allura/templates/repo/tags.html b/Allura/allura/templates/repo/tags.html
index 579b294b3..5ee0578b2 100644
--- a/Allura/allura/templates/repo/tags.html
+++ b/Allura/allura/templates/repo/tags.html
@@ -31,7 +31,7 @@
{% block content %}
<div class="grid-19">
{% for b in tags %}
- <a href="{{c.app.repo.url_for_commit(b.name)}}tree/">{{b.name}}</a><br>
+ <a href="{{c.app.repo.url_for_commit(b.name)}}tree/" rel="nofollow">{{b.name}}</a><br>
{% endfor %}
</div>
{% endblock %}
diff --git a/Allura/allura/templates/repo/tarball.html b/Allura/allura/templates/repo/tarball.html
index 55bb3aedb..e026b2a01 100644
--- a/Allura/allura/templates/repo/tarball.html
+++ b/Allura/allura/templates/repo/tarball.html
@@ -22,7 +22,7 @@
{% endblock %}
{% block header -%}
-Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
+Commit <a href="{{commit.url()}}" rel="nofollow">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
{%- endblock %}
{% block extra_js %}
diff --git a/Allura/allura/templates/repo/tree.html b/Allura/allura/templates/repo/tree.html
index 391314cc7..d4cc8d81d 100644
--- a/Allura/allura/templates/repo/tree.html
+++ b/Allura/allura/templates/repo/tree.html
@@ -25,7 +25,7 @@
{% endblock %}
{% block header %}
-Tree <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
+Tree <a href="{{commit.url()}}" rel="nofollow">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
{{lib.path_links(path.strip('/').split('/'))}}
{% endblock %}
@@ -64,7 +64,7 @@ form.tarball button:hover {
</form>
{% endif %}
-{{ g.icons['history'].render(href='%slog/?path=%s' % (commit.url(), path), show_title=True) }}
+{{ g.icons['history'].render(href='%slog/?path=%s' % (commit.url(), path), show_title=True, rel='nofollow') }}
{% if c.user and c.user != c.user.anonymous() %}
{{c.subscribe_form.display(value=tool_subscribed, action='subscribe', style='icon')}}
{% endif %}
diff --git a/Allura/allura/templates/widgets/repo/tree_widget.html b/Allura/allura/templates/widgets/repo/tree_widget.html
index 5e75fcba4..6645aff85 100644
--- a/Allura/allura/templates/widgets/repo/tree_widget.html
+++ b/Allura/allura/templates/widgets/repo/tree_widget.html
@@ -31,7 +31,7 @@
{% if tree._parent %}
<tr>
<td></td>
- <td><a href="..">[Up one dir]</a></td>
+ <td><a href=".." rel="nofollow">[Up one dir]</a></td>
<td></td>
<td></td>
<td></td>
@@ -53,19 +53,19 @@
{{ g.icons[icon_name].render(
href=h.urlquote(dirent.href),
title=h.really_unicode(dirent.name),
- show_title=True) }}
+ show_title=True, rel='nofollow') }}
</td>
<td class="nowrap">{{lib.abbr_date(dirent.last_commit.date)}}</td>
<td class="nowrap">
{% if dirent.last_commit.author_url %}
- <a href="{{dirent.last_commit.author_url}}">{{lib.email_gravatar(dirent.last_commit.author_email, title=h.really_unicode(dirent.last_commit.author), size=16)}}</a>
- <a href="{{dirent.last_commit.author_url}}">{{h.really_unicode(dirent.last_commit.author)}}</a>
+ <a href="{{dirent.last_commit.author_url}}" rel="nofollow">{{lib.email_gravatar(dirent.last_commit.author_email, title=h.really_unicode(dirent.last_commit.author), size=16)}}</a>
+ <a href="{{dirent.last_commit.author_url}}" rel="nofollow">{{h.really_unicode(dirent.last_commit.author)}}</a>
{% else %}
{{lib.email_gravatar(dirent.last_commit.author_email, title=h.really_unicode(dirent.last_commit.author), size=16)}} {{h.really_unicode(dirent.last_commit.author)}}
{% endif %}
</td>
<td>
- <a href="{{dirent.last_commit.href}}">
+ <a href="{{dirent.last_commit.href}}" rel="nofollow">
{{dirent.last_commit.shortlink}}
{{ h.hide_private_info(dirent.last_commit.summary) }}
</a>