Skip to content

Commit

Permalink
Add rel="me" to profile links
Browse files Browse the repository at this point in the history
  • Loading branch information
huntertur committed Nov 12, 2024
1 parent a3f29e7 commit 502ad51
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions weasyl/templates/user/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ <h3>Contact</h3>
<dt>${name}</dt>
$ info = M.SOCIAL_SITES_BY_NAME.get(name, {})
$if value.startswith(('http://', 'https://')):
<dd><a href="${value}" rel="nofollow ugc">${value}</a></dd>
<dd><a href="${value}" rel="me nofollow ugc">${value}</a></dd>
$elif value.startswith('mailto:'):
<dd><a href="${value}">${value.partition('mailto:')[2]}</a></dd>
$elif info.get("url"):
<dd><a href="${info["url"] % value}">${value}</a></dd>
<dd><a href="${info["url"] % value}" rel="me">${value}</a></dd>
$else:
<dd>${value}</dd>
</dl>
Expand Down
29 changes: 29 additions & 0 deletions weasyl/test/web/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,32 @@ def test_assert_adult(app, create_post, expect_assertion):
with _guest(app):
resp = app.get("/~forwarduser")
assert resp.html.find(id="user-id").text.strip() == "17"


@pytest.mark.usefixtures("db", "cache")
@pytest.mark.parametrize(("site_names", "site_values", "rel_me_expected"), [
("Bluesky", "weasyl.invalid", True),
("Email", "[email protected]", False),
("Something non-default", "not a URL", False),
("Something non-default", "https://weasyl.invalid/", True),
])
def test_profile_links_rel_me(app, site_names: str, site_values: str, rel_me_expected: bool):
user = db_utils.create_user(username="profiletest")
app.set_cookie(*db_utils.create_session(user).split("=", 1))

app.post("/control/editprofile", {
# Unrelated, but necessary for successful form submission
"set_commish": "e",
"set_request": "e",
"set_trade": "e",

"site_names": site_names,
"site_values": site_values,
})

resp = app.get("/~profiletest")
assert resp.html.find(string=site_names)
assert resp.html.find(string=site_values)

rel = resp.html.find(string=site_values).parent.get("rel", [])
assert ("me" in rel) is rel_me_expected

0 comments on commit 502ad51

Please sign in to comment.