Skip to content

Commit

Permalink
update a few user page links in the web UI, /user/ => /web/
Browse files Browse the repository at this point in the history
for #512
  • Loading branch information
snarfed committed Jun 3, 2023
1 parent c41b55a commit daba73c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
6 changes: 5 additions & 1 deletion models.py
Expand Up @@ -271,8 +271,12 @@ def ap_actor(self, rest=None):
def user_page_path(self, rest=None):
"""Returns the user's Bridgy Fed user page path."""
path = f'/{self.LABEL}/{self.label_id()}'

if rest:
path += f'/{rest}'
if not rest.startswith('?'):
path += '/'
path += rest

return path

def user_page_link(self):
Expand Down
2 changes: 1 addition & 1 deletion protocol.py
Expand Up @@ -281,7 +281,7 @@ def accept_follow(cls, obj):
followee_actor_url = g.user.ap_actor()
accept = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': common.host_url(f'/user/{g.user.key.id()}/followers#accept-{obj.key.id()}'),
'id': common.host_url(f'/web/{g.user.key.id()}/followers#accept-{obj.key.id()}'),
'type': 'Accept',
'actor': followee_actor_url,
'object': as2.from_as1(obj.as1),
Expand Down
2 changes: 1 addition & 1 deletion templates/activities.html
Expand Up @@ -17,7 +17,7 @@
{% if loop.index0 == 3 %}
<span id="more-domains" style="display: none">
{% endif %}
<a href="/user/{{ domain }}">馃寪 {{ domain }}</a>
<a href="/web/{{ domain }}">馃寪 {{ domain }}</a>
<br>
{% endfor %}
{% if obj.domains|length > 3 %}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_activitypub.py
Expand Up @@ -193,7 +193,7 @@
ACCEPT = {
'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Accept',
'id': 'http://localhost/user/user.com/followers#accept-https://mas.to/6d1a',
'id': 'http://localhost/web/user.com/followers#accept-https://mas.to/6d1a',
'actor': 'http://localhost/user.com',
'object': {
**ACCEPT_FOLLOW,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_webfinger.py
Expand Up @@ -50,7 +50,7 @@
'href': 'http://localhost/ap/sharedInbox',
}, {
'rel': 'http://ostatus.org/schema/1.0/subscribe',
'template': 'http://localhost/user/user.com?url={uri}',
'template': 'http://localhost/web/user.com?url={uri}',
}],
}
WEBFINGER_NO_HCARD = {
Expand Down Expand Up @@ -78,7 +78,7 @@
'href': 'http://localhost/ap/sharedInbox',
}, {
'rel': 'http://ostatus.org/schema/1.0/subscribe',
'template': 'http://localhost/user/user.com?url={uri}',
'template': 'http://localhost/web/user.com?url={uri}',
}],
}

Expand Down
2 changes: 1 addition & 1 deletion web.py
Expand Up @@ -349,7 +349,7 @@ def webmention_interactive():
except HTTPException as e:
flash(util.linkify(str(e.description), pretty=True))

path = f'/user/{g.user.key.id()}' if g.user else '/'
path = g.user.user_page_path() if g.user else '/'
return redirect(path, code=302)


Expand Down
6 changes: 5 additions & 1 deletion webfinger.py
Expand Up @@ -110,7 +110,11 @@ def template_vars(self, domain=None, allow_indirect=False):
# https://github.com/snarfed/bridgy-fed/issues/60#issuecomment-1325589750
{
'rel': 'http://ostatus.org/schema/1.0/subscribe',
'template': common.host_url(f'user/{domain}?url={{uri}}'),
# TODO(#512) switch to:
# 'template': common.host_url(g.user.user_page_path('?url={uri}')),
# the problem is that user_page_path() uses label_id(), which uses
# custom username instead of domain, which may not be unique
'template': common.host_url(f'web/{domain}?url={{uri}}'),
}]
})

Expand Down

0 comments on commit daba73c

Please sign in to comment.