mirror of
https://0xacab.org/johnxina/rat.git
synced 2024-12-23 13:09:08 +00:00
fix paging issue, bring back the popularity sort
This commit is contained in:
parent
ac0da85e5c
commit
c92afa9436
5
app.py
5
app.py
@ -133,7 +133,7 @@ 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 5)
|
sort = int(request.args.get('sort') or 0)
|
||||||
|
|
||||||
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),
|
||||||
@ -142,7 +142,8 @@ async def forum_view():
|
|||||||
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,
|
||||||
|
tp = ((115 if threads.page.total_page > 115 else threads.page.total_page) if sort == 0 else threads.page.total_page))
|
||||||
|
|
||||||
@app.route('/home/main')
|
@app.route('/home/main')
|
||||||
async def user_view():
|
async def user_view():
|
||||||
|
@ -23,9 +23,8 @@
|
|||||||
</header>
|
</header>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="vlist">
|
<div class="vlist">
|
||||||
<!-- POPULAR SORT IS UNAVAILABLE -->
|
<div><a {% if sort == 0 %} class="current-sel" {% endif %}
|
||||||
<!-- <div><a {% if sort == 0 %} 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=0">时下热门</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'] }}&sort=5">最新回复</a></div>
|
href="/f?kw={{ info['name'] }}&sort=5">最新回复</a></div>
|
||||||
<div><a {% if sort == 1 %} class="current-sel" {% endif %}
|
<div><a {% if sort == 1 %} class="current-sel" {% endif %}
|
||||||
@ -75,13 +74,13 @@
|
|||||||
|
|
||||||
{% for i in range(5) %}
|
{% for i in range(5) %}
|
||||||
{% set np = threads.page.current_page + 1 + i %}
|
{% set np = threads.page.current_page + 1 + i %}
|
||||||
{% if np <= threads.page.total_page %}
|
{% if np <= tp %}
|
||||||
<a href="/f?kw={{ info['name'] }}&pn={{ np }}&sort={{ sort }}">{{ np }}</a>
|
<a href="/f?kw={{ info['name'] }}&pn={{ np }}&sort={{ sort }}">{{ np }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if threads.page.current_page < threads.page.total_page %}
|
{% if threads.page.current_page < tp %}
|
||||||
<a href="/f?kw={{ info['name'] }}&pn={{ threads.page.total_page }}&sort={{ sort }}">尾页</a>
|
<a href="/f?kw={{ info['name'] }}&pn={{ tp }}&sort={{ sort }}">尾页</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user