diff --git a/app.py b/app.py index 0d98efe8b30daa09075f9b286102fd3efe8a6418..fd546cbbad963602ec9f31ea233a4bbe925494ae 100644 --- a/app.py +++ b/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(): diff --git a/templates/thread.html b/templates/thread.html index 8abcdfde62adf0c1ba778771cee11dd08b31c927..3b88050022e38c8db24f68dddd33b1f328a3adfd 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -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>