Temporary remove popularity sort, Bump up aiotieba version

This commit is contained in:
John Xina 2023-07-13 19:45:43 +08:00
parent 965c8f2cc0
commit dd16ffe357
3 changed files with 9 additions and 9 deletions

5
app.py
View File

@ -131,16 +131,15 @@ async def thread_view(tid):
async def forum_view(): async def forum_view():
fname = request.args['kw'] fname = request.args['kw']
pn = int(request.args.get('pn') or 1) pn = int(request.args.get('pn') or 1)
sort = int(request.args.get('sort') or 0) sort = int(request.args.get('sort') or 5)
async with aiotieba.Client() as tieba: async with aiotieba.Client() as tieba:
forum_info, threads = await asyncio.gather(awaitify(find_tieba_info)(fname), forum_info, threads = await asyncio.gather(awaitify(find_tieba_info)(fname),
tieba.get_threads(fname, rn=50, pn=pn, sort=sort)) tieba.get_threads(fname, pn=pn, sort=sort))
if threads.page.current_page > threads.page.total_page or pn < 1: if threads.page.current_page > threads.page.total_page or pn < 1:
return await render_template('error.html', msg = \ return await render_template('error.html', msg = \
f'请求越界,本贴吧共有 { threads.page.total_page }' f'请求越界,本贴吧共有 { threads.page.total_page }'
f'而您查询了第 { threads.page.current_page}') f'而您查询了第 { threads.page.current_page}')
return await render_template('bar.html', info=forum_info, threads=threads, sort=sort) return await render_template('bar.html', info=forum_info, threads=threads, sort=sort)
@app.route('/home/main') @app.route('/home/main')

View File

@ -1,6 +1,6 @@
aioflask==0.4.0 aioflask==0.4.0
flask==2.1.3 flask==2.1.3
aiotieba==3.4.5 aiotieba==3.5.0
Flask-Caching Flask-Caching
beautifulsoup4 beautifulsoup4
requests requests

View File

@ -23,12 +23,13 @@
</header> </header>
<div class="list"> <div class="list">
<div class="vlist"> <div class="vlist">
<div><a {% if sort == 0 %} class="current-sel" {% endif %} <!-- POPULAR SORT IS UNAVAILABLE -->
href="/f?kw={{ info['name'] }}&pn={{ threads.page.current_page }}&sort=0">时下热门</a></div> <!-- <div><a {% if sort == 0 %} class="current-sel" {% endif %}
<div><a {% if sort == 1 %} class="current-sel" {% endif %} href="/f?kw={{ info['name'] }}&pn={{ threads.page.current_page }}&sort=0">时下热门</a></div> -->
href="/f?kw={{ info['name'] }}&pn={{ threads.page.current_page }}&sort=1">最新发布</a></div>
<div><a {% if sort == 5 %} class="current-sel" {% endif %} <div><a {% if sort == 5 %} class="current-sel" {% endif %}
href="/f?kw={{ info['name'] }}&pn={{ threads.page.current_page }}&sort=5">最新回复</a></div> href="/f?kw={{ info['name'] }}&sort=5">最新回复</a></div>
<div><a {% if sort == 1 %} class="current-sel" {% endif %}
href="/f?kw={{ info['name'] }}&sort=1">最新发布</a></div>
</div> </div>
</div> </div>
<div class="list"> <div class="list">