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 6a309567cda979a4dae1a074163d11b9bcfefd78 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 | 1 + 8 files changed, 18 insertions(+), 7 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 f53b9aa75..8680ee77c 100644 --- a/Allura/development.ini +++ b/Allura/development.ini @@ -252,6 +252,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..a5b227373 100644 --- a/ForgeActivity/forgeactivity/main.py +++ b/ForgeActivity/forgeactivity/main.py @@ -136,6 +136,7 @@ class ForgeActivityController(BaseController): if not use_gravatar: # force current user icon (overwrites previous gravatar urls or defaults) if t.actor.activity_url: + t.actor.activity_url = f'{t.actor.activity_url}profile/' t.actor.activity_extras.icon_url = icon_base + t.actor.activity_url + 'user_icon' # ideally ?{icon_timestamp} would be appended to URL for cache-busting when CDN is used, but that # value would only be available by querying and loading the user-project
