This is an automated email from the ASF dual-hosted git repository. gcruz pushed a commit to branch gc/8446 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 5256a46f9f63cf14fc8ca335f70296eaebdd9cab Author: Guillermo Cruz <[email protected]> AuthorDate: Fri Jul 8 11:45:11 2022 -0600 [#8446] user links inside pages link directly to profile --- Allura/allura/lib/app_globals.py | 4 ++++ Allura/allura/lib/helpers.py | 2 +- Allura/allura/templates/jinja_master/lib.html | 3 ++- Allura/allura/templates/macro/members.html | 3 ++- Allura/allura/templates/members.html | 3 ++- Allura/allura/templates/repo/merge_requests.html | 6 +++--- Allura/development.ini | 3 +++ ForgeActivity/forgeactivity/main.py | 2 ++ ForgeActivity/forgeactivity/tests/functional/test_root.py | 2 +- ForgeWiki/forgewiki/tests/functional/test_root.py | 2 +- 10 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py index 4a958b19d..7517cb6a5 100644 --- a/Allura/allura/lib/app_globals.py +++ b/Allura/allura/lib/app_globals.py @@ -579,6 +579,10 @@ class Globals: base = request.scheme + base return base + resource + @property + def user_profile_urls_with_profile_path(self): + return config['user_profile_url_with_profile_path'] + def app_static(self, resource, app=None): base = config['static.url_base'] app = app or c.app diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py index c6ec0e973..bf7b4d04a 100644 --- a/Allura/allura/lib/helpers.py +++ b/Allura/allura/lib/helpers.py @@ -1291,4 +1291,4 @@ def username_project_url(user_or_username): user = user_or_username url = user.url() - return url + return f'{url}profile/' diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html index 41689b43f..3aa3366ca 100644 --- a/Allura/allura/templates/jinja_master/lib.html +++ b/Allura/allura/templates/jinja_master/lib.html @@ -112,7 +112,8 @@ {% macro user_link(user, avatar=False, size=16) -%} {% if user %} {% if not user.is_anonymous() %} - <a href="{{user.url()}}" class="user-mention"> + {% set profile_path = user.url() + 'profile/' if g.user_profile_urls_with_profile_path == 'true' else user.url() %} + <a href="{{profile_path}}" class="user-mention"> {% if avatar %} {{ gravatar_or_name(user, size) }} {% else %} diff --git a/Allura/allura/templates/macro/members.html b/Allura/allura/templates/macro/members.html index 8ed27fcfb..a3e3db472 100644 --- a/Allura/allura/templates/macro/members.html +++ b/Allura/allura/templates/macro/members.html @@ -18,8 +18,9 @@ -#} <h6>Project Members:</h6> <ul class="md-users-list"> + {% set profile_path = 'profile/' if g.user_profile_urls_with_profile_path == 'true' else '' %} {% for user in users -%} - <li><a href="{{user.url}}">{{user.name}}</a>{{user.admin}}</li> + <li><a href="{{ user.url ~ profile_path}}">{{user.name}}</a>{{user.admin}}</li> {%- endfor %} {% if over_limit -%} <li class="md-users-list-more"><a href="{{c.project.url()}}_members">All Members</a></li> diff --git a/Allura/allura/templates/members.html b/Allura/allura/templates/members.html index 5b4edff8d..8088eb999 100644 --- a/Allura/allura/templates/members.html +++ b/Allura/allura/templates/members.html @@ -18,6 +18,7 @@ -#} {% set hide_left_bar = True %} {% set h1_text = c.project.name ~ ' ' ~ 'Project' ~ ' ' ~ 'Member List' %} +{% set profile_path = 'profile/' if g.user_profile_urls_with_profile_path == 'true' else '' %} {% extends g.theme.master %} {% block title %}{{ h1_text }}{% endblock %} {% block header %}Members{% endblock %} @@ -35,7 +36,7 @@ {%for user in users%} <tr> <td>{{ user.display_name }}</td> - <td><a href="{{ user.url }}">{{ user.username }}</a></td> + <td><a href="{{ user.url ~ profile_path }}">{{ user.username }}</a></td> <td>{{user.roles}}</td> </tr> {%endfor%} diff --git a/Allura/allura/templates/repo/merge_requests.html b/Allura/allura/templates/repo/merge_requests.html index 8ca297ca7..8deeb118d 100644 --- a/Allura/allura/templates/repo/merge_requests.html +++ b/Allura/allura/templates/repo/merge_requests.html @@ -17,9 +17,9 @@ under the License. -#} {% extends 'allura:templates/repo/repo_master.html' %} - +{% import 'allura:templates/jinja_master/lib.html' as lib with context %} {% set status = request.params.get('status' , '') %} - +{% set profile_path = 'profile/' if g.user_profile_urls_with_profile_path == 'true' else '' %} {% block title %} {{c.project.name}} / {{c.app.config.options.mount_label}} / Merge Requests {% endblock %} @@ -61,7 +61,7 @@ {% else %} <i>(deleted)</i> {% endif %}</td> - <td><a href="{{req.creator_url}}" rel="nofollow">{{req.creator_name}}</a></td> + <td><a href="{{req.creator_url ~ profile_path}}" 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/development.ini b/Allura/development.ini index 12332a257..9787444fa 100644 --- a/Allura/development.ini +++ b/Allura/development.ini @@ -253,6 +253,9 @@ user_prefs.maximum_claimed_emails = 20 ; Control the order of sections on the user profile page user_profile_sections.order = activity, personal-data, skills, social, tools, projects +# append /profile to user profile's urls +user_profile_url_with_profile_path = true + ; Control the order of sections on the personal dashboard page personal_dashboard_sections.order = activity, tickets, merge_requests, projects diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py index a1155a72d..d074f02fc 100644 --- a/ForgeActivity/forgeactivity/main.py +++ b/ForgeActivity/forgeactivity/main.py @@ -149,6 +149,8 @@ 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.actor.activity_url = f'{t.actor.activity_url}profile/' + should_noindex = any(name in noindex_tags for name in t.tags) t.obj.noindex = should_noindex t.target.noindex = should_noindex diff --git a/ForgeActivity/forgeactivity/tests/functional/test_root.py b/ForgeActivity/forgeactivity/tests/functional/test_root.py index cdbf679af..2948e560b 100644 --- a/ForgeActivity/forgeactivity/tests/functional/test_root.py +++ b/ForgeActivity/forgeactivity/tests/functional/test_root.py @@ -101,7 +101,7 @@ class TestActivityController(TestController): h1 = """\ <h1> <img alt="Administrator 1" class="emboss x32 avatar" src="/u/test-admin/user_icon" title="Administrator 1"/> - <a href="/u/test-admin/"> + <a href="/u/test-admin/profile/"> Administrator 1 </a> posted diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py index 698e0feb3..6c98b5ffc 100644 --- a/ForgeWiki/forgewiki/tests/functional/test_root.py +++ b/ForgeWiki/forgewiki/tests/functional/test_root.py @@ -830,7 +830,7 @@ class TestRootController(TestController): def test_user_browse_page(self): r = self.app.get('/wiki/browse_pages/') - assert '<td><a href="/u/test-admin/" class="user-mention">test-admin</a></td>' in r + assert '<td><a href="/u/test-admin/profile/" class="user-mention">test-admin</a></td>' in r def test_subscribe(self): user = M.User.query.get(username='test-user')
