verified link to user home for Mastodon users
This commit is contained in:
parent
8fdb119d21
commit
7db12b9a82
2 changed files with 31 additions and 1 deletions
17
users/templates/users/home_anonymous.html
Normal file
17
users/templates/users/home_anonymous.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
{% load static %}
|
||||
{% load i18n %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="0;URL={{ login_url }}" />
|
||||
<title>{{ site_name }} - {{ username }}@{{ site }}</title>
|
||||
<meta property="og:title" content="{{ site_name }} - {{ username }}@{{ site }}的书影音">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="{{ request.build_absolute_uri }}">
|
||||
<meta property="og:image" content="{{ request.scheme }}://{{ request.get_host }}{% static 'img/logo_square.jpg' %}">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://{{ site }}/@{{ username }}" rel="me" style="display:none;">Mastodon homepage</a>
|
||||
</body>
|
||||
</html>
|
|
@ -184,10 +184,23 @@ def register(request):
|
|||
def delete(request):
|
||||
raise NotImplementedError
|
||||
|
||||
def home_anonymous(request, id):
|
||||
login_url = settings.LOGIN_URL + "?next=" + request.get_full_path()
|
||||
try:
|
||||
username = id.split('@')[0]
|
||||
site = id.split('@')[1]
|
||||
return render(request, 'users/home_anonymous.html', {
|
||||
'login_url': login_url,
|
||||
'username': username,
|
||||
'site': site,
|
||||
})
|
||||
except:
|
||||
return redirect(login_url)
|
||||
|
||||
@mastodon_request_included
|
||||
@login_required
|
||||
def home(request, id):
|
||||
if not request.user.is_authenticated:
|
||||
return home_anonymous(request, id)
|
||||
if request.method == 'GET':
|
||||
if isinstance(id, str):
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue