add rel-alternate link to /r/ HTML response to make posts discoverable

pull/538/head
Ryan Barrett 2023-06-08 21:11:06 -07:00
rodzic 7066a935e6
commit bca0878bb2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 13 dodań i 2 usunięć

Wyświetl plik

@ -104,6 +104,17 @@ def redir(to):
'Access-Control-Allow-Origin': '*',
}
# redirect
# redirect. include rel-alternate link to make posts discoverable by entering
# https://fed.brid.gy/r/[URL] in a fediverse instance's search.
logger.info(f'redirecting to {to}')
return redirect(to, code=301)
return f"""\
<!doctype html>
<html>
<head>
<link href="{to}" type="application/activity+json">
</head>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="{to}">{to}</a>. If not, click the link.
</html>
""", 301, {'Location': to}