mirror of
https://0xacab.org/johnxina/rat.git
synced 2024-12-23 04:59:09 +00:00
Add author only viewing option
This commit is contained in:
parent
dd16ffe357
commit
ac0da85e5c
6
app.py
6
app.py
@ -104,11 +104,13 @@ async def _jinja2_filter_translate(frags, reply_id=0):
|
||||
async def thread_view(tid):
|
||||
tid = int(tid)
|
||||
pn = int(request.args.get('pn') or 1)
|
||||
ao = int(request.args.get('ao') or 0)
|
||||
|
||||
async with aiotieba.Client() as tieba:
|
||||
# Default to 15 posts per page, confirm to tieba.baidu.com
|
||||
thread_info = await tieba.get_posts(tid, rn=15, pn=pn,
|
||||
with_comments=should_fetch_comments)
|
||||
with_comments=should_fetch_comments,
|
||||
only_thread_author=ao)
|
||||
|
||||
available_users = []
|
||||
for floor in thread_info:
|
||||
@ -125,7 +127,7 @@ async def thread_view(tid):
|
||||
|
||||
await asyncio.gather(*(cache_name_from_id(tieba, i) for i in all_users))
|
||||
|
||||
return await render_template('thread.html', info=thread_info)
|
||||
return await render_template('thread.html', info=thread_info, ao=ao)
|
||||
|
||||
@app.route('/f')
|
||||
async def forum_view():
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>{{ info.thread.text }} - 自由软件吧 - RAT</title>
|
||||
<title>{{ info.thread.text }}{{ ao }} - 自由软件吧 - RAT</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="referrer" content="never">
|
||||
@ -14,6 +14,12 @@
|
||||
<div class="title">{{ info.thread.title }}</div>
|
||||
<div class="from"><a href="/f?kw={{ info.forum.fname }}">{{ info.forum.fname }}吧</a></div>
|
||||
</header>
|
||||
<div class="list">
|
||||
<div class="vlist">
|
||||
<div><a {% if not ao %} class="current-sel" {% endif %} href="/p/{{ info.thread.tid }}?ao=0">全部回复</a></div>
|
||||
<div><a {% if ao %} class="current-sel" {% endif %} href="/p/{{ info.thread.tid }}?ao=1">仅看楼主</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list">
|
||||
{% for p in info %}
|
||||
<div class="post" id="{{ p.floor }}">
|
||||
@ -61,13 +67,13 @@
|
||||
|
||||
<div class="paginator">
|
||||
{% if info.page.current_page > 1 %}
|
||||
<a href="/p/{{ info.thread.tid }}">首页</a>
|
||||
<a href="/p/{{ info.thread.tid }}&ao={{ao}}">首页</a>
|
||||
{% endif %}
|
||||
|
||||
{% for i in range(5) %}
|
||||
{% set np = info.page.current_page - 5 + i %}
|
||||
{% if np > 0 %}
|
||||
<a href="/p/{{ info.thread.tid }}?pn={{ np }}">{{ np }}</a>
|
||||
<a href="/p/{{ info.thread.tid }}?pn={{ np }}&ao={{ao}}">{{ np }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@ -76,12 +82,12 @@
|
||||
{% for i in range(5) %}
|
||||
{% set np = info.page.current_page + 1 + i %}
|
||||
{% if np <= info.page.total_page %}
|
||||
<a href="/p/{{ info.thread.tid }}?pn={{ np }}">{{ np }}</a>
|
||||
<a href="/p/{{ info.thread.tid }}?pn={{ np }}&ao={{ao}}">{{ np }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if info.page.current_page < info.page.total_page %}
|
||||
<a href="/p/{{ info.thread.tid }}?pn={{ info.page.total_page }}">尾页</a>
|
||||
<a href="/p/{{ info.thread.tid }}?pn={{ info.page.total_page }}&ao={{ao}}">尾页</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user