timeline view by default
This commit is contained in:
parent
dee3b376f5
commit
188813cc76
10 changed files with 48 additions and 26 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
{% if request.user.is_authenticated %}
|
||||
|
||||
<a class="navbar__link" href="{% url 'common:home' %}">{% trans '主页' %}</a>
|
||||
<a class="navbar__link" href="{% url 'common:home' %}">{% trans '首页' %}</a>
|
||||
<a class="navbar__link" id="logoutLink" href="{% url 'users:data' %}">{% trans '数据' %}</a>
|
||||
<a class="navbar__link" id="logoutLink" href="{% url 'users:preferences' %}">{% trans '设置' %}</a>
|
||||
<a class="navbar__link" id="logoutLink" href="{% url 'users:logout' %}">{% trans '登出' %}</a>
|
||||
|
|
|
@ -24,6 +24,6 @@ def prettydate(d):
|
|||
elif s < 120:
|
||||
return '刚刚'
|
||||
elif s < 3600:
|
||||
return '{} 分钟前'.format(s / 60)
|
||||
return '{} 分钟前'.format(s // 60)
|
||||
else:
|
||||
return '{} 小时前'.format(s / 3600)
|
||||
return '{} 小时前'.format(s // 3600)
|
||||
|
|
|
@ -17,6 +17,7 @@ from music.models import Album, Song, AlbumMark, SongMark
|
|||
from users.models import Report, User, Preference
|
||||
from mastodon.decorators import mastodon_request_included
|
||||
from users.views import home as user_home
|
||||
from timeline.views import timeline as user_timeline
|
||||
from common.models import MarkStatusEnum
|
||||
from common.utils import PageLinksGenerator
|
||||
from common.scraper import get_scraper_by_url, get_normalized_url
|
||||
|
@ -33,7 +34,15 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
@login_required
|
||||
def home(request):
|
||||
return user_home(request, request.user.id)
|
||||
try:
|
||||
classic = request.user.preference.classic_homepage
|
||||
except ObjectDoesNotExist:
|
||||
Preference.objects.create(user=user)
|
||||
classic = request.user.preference.classic_homepage
|
||||
if classic:
|
||||
return user_home(request, request.user.id)
|
||||
else:
|
||||
return user_timeline(request)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ site_name }} - {{ user.mastodon_username }} {{ list_title }}</title>
|
||||
<title>{{ site_name }} - 首页</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.6.1"></script>
|
||||
<script src="{% static 'lib/js/rating-star.js' %}"></script>
|
||||
|
|
|
@ -12,8 +12,6 @@ from mastodon import mastodon_request_included
|
|||
from mastodon.models import MastodonApplication
|
||||
from mastodon.api import post_toot, TootVisibilityEnum
|
||||
from common.utils import PageLinksGenerator
|
||||
from common.views import PAGE_LINK_NUMBER, jump_or_scrape
|
||||
from common.models import SourceSiteEnum
|
||||
from .models import *
|
||||
from django.conf import settings
|
||||
import re
|
||||
|
|
|
@ -49,9 +49,10 @@ from common.importers.douban import DoubanImporter
|
|||
def preferences(request):
|
||||
if request.method == 'POST':
|
||||
request.user.preference.default_visibility = int(request.POST.get('default_visibility'))
|
||||
request.user.preference.classic_homepage = bool(request.POST.get('classic_homepage'))
|
||||
request.user.preference.mastodon_publish_public = bool(request.POST.get('mastodon_publish_public'))
|
||||
request.user.preference.mastodon_append_tag = request.POST.get('mastodon_append_tag', '').strip()
|
||||
request.user.preference.save()
|
||||
request.user.preference.save(update_fields=['default_visibility', 'classic_homepage', 'mastodon_publish_public', 'mastodon_append_tag'])
|
||||
return render(request, 'users/preferences.html')
|
||||
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ class Preference(models.Model):
|
|||
export_status = models.JSONField(blank=True, null=True, encoder=DjangoJSONEncoder, default=dict)
|
||||
import_status = models.JSONField(blank=True, null=True, encoder=DjangoJSONEncoder, default=dict)
|
||||
default_visibility = models.PositiveSmallIntegerField(default=0)
|
||||
classic_homepage = models.BooleanField(null=False, default=False)
|
||||
mastodon_publish_public = models.BooleanField(null=False, default=False)
|
||||
mastodon_append_tag = models.CharField(max_length=2048, default='')
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
{% if user == request.user %}
|
||||
<title>{{ site_name }} - {% trans '我的主页' %}</title>
|
||||
<title>{{ site_name }} - {% trans '我的个人主页' %}</title>
|
||||
{% else %}
|
||||
<title>{{ site_name }} - {{user.username}}{% trans '的主页' %}</title>
|
||||
<title>{{ site_name }} - {{user.display_name}}</title>
|
||||
{% endif %}
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'common:home' %}" class="button">{% trans '前往我的主页' %}</a>
|
||||
<a href="{% url 'common:home' %}" class="button">{% trans '前往首页' %}</a>
|
||||
{% elif allow_any_site %}
|
||||
<form action="/users/connect" onsubmit="return /^(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,})$/.test($('#domain').val())">
|
||||
<input type="search" name="domain" id="domain" placeholder="实例域名,如mastodon.social (不含@)" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
||||
|
|
|
@ -27,15 +27,14 @@
|
|||
<div class="grid grid--reverse-order">
|
||||
<div class="grid__main grid__main--reverse-order">
|
||||
<div class="main-section-wrapper">
|
||||
<div class="tools-section-wrapper">
|
||||
<div class="import-panel">
|
||||
<h5 class="import-panel__label">{% trans '社交网络分享相关设置' %}</h5>
|
||||
<div class="import-panel__body">
|
||||
<form action="{% url 'users:preferences' %}" method="POST">
|
||||
<form action="{% url 'users:preferences' %}" method="POST">
|
||||
<div class="tools-section-wrapper">
|
||||
<div class="import-panel">
|
||||
<h5 class="import-panel__label">{% trans 'NeoDB使用偏好设置' %}</h5>
|
||||
<div class="import-panel__body">
|
||||
{% csrf_token %}
|
||||
<span>{% trans '新标记默认可见性:' %}</span>
|
||||
<div class="import-panel__checkbox import-panel__checkbox--last">
|
||||
可见性:
|
||||
<label for="id_visibility_0"><input type="radio" name="default_visibility" value="0" required="" id="id_visibility_0" {%if request.user.preference.default_visibility == 0 %}checked{% endif %}>
|
||||
公开</label>
|
||||
<label for="id_visibility_1"><input type="radio" name="default_visibility" value="1" required="" id="id_visibility_1" {%if request.user.preference.default_visibility == 1 %}checked{% endif %}>
|
||||
|
@ -44,25 +43,39 @@
|
|||
仅自己</label>
|
||||
</div>
|
||||
<br>
|
||||
<span>{% trans '使用个人主页作为首页:' %}</span>
|
||||
<div class="import-panel__checkbox import-panel__checkbox--last">
|
||||
<input type="checkbox" name="classic_homepage" id="classic_homepage" {%if request.user.preference.classic_homepage %}checked{% endif %}>
|
||||
<label for="classic_homepage">{% trans '默认启用时间轴视图作为首页,如果希望使用原版风格首页可选中此处' %}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tools-section-wrapper" style="margin-top: 2em;">
|
||||
<div class="import-panel">
|
||||
<h5 class="import-panel__label">{% trans '社交网络分享相关设置' %}</h5>
|
||||
<div class="import-panel__body">
|
||||
{% csrf_token %}
|
||||
<span>{% trans '在联邦网络上以公开方式分享的帖文是否发布到公共时间轴上:' %}</span>
|
||||
<div class="import-panel__checkbox import-panel__checkbox--last">
|
||||
<input type="checkbox" name="mastodon_publish_public" id="visibility" {%if request.user.preference.mastodon_publish_public%}checked{% endif %}>
|
||||
<input type="checkbox" name="mastodon_publish_public" id="visibility" {%if request.user.preference.mastodon_publish_public %}checked{% endif %}>
|
||||
<label for="visibility">{% trans '选中时为public,未选中时为unlisted' %}</label>
|
||||
</div>
|
||||
<br><br>
|
||||
<span>{% trans '分享帖文时附加标签:' %}</span>
|
||||
<span>{% trans '在联邦网络上分享帖文时附加标签:' %}</span>
|
||||
<div class="import-panel__checkbox import-panel__checkbox--last">
|
||||
<input name="mastodon_append_tag" id="tag" placeholder="#我的书影音" value="{{ request.user.preference.mastodon_append_tag }}" >
|
||||
<label for="tag">{% trans '输入标签文字会被添加到帖文结尾' %}</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="submit" class="import-panel__button" value="{% trans '保存' %}">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<input type="submit" class="import-panel__button" value="{% trans '保存' %}">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -71,7 +84,7 @@
|
|||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% include "partial/_footer.html" %}
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue