forked from rDrama/rDrama
remove useless parameters from paginations
parent
8cb34f1d91
commit
b6e27f29b9
|
@ -5,7 +5,7 @@ from os import environ, listdir, path
|
|||
|
||||
import user_agents
|
||||
|
||||
from flask import g, session, has_request_context
|
||||
from flask import g, session, has_request_context, request
|
||||
from jinja2 import pass_context
|
||||
|
||||
from files.classes.user import User
|
||||
|
@ -18,6 +18,8 @@ from files.helpers.sorting_and_time import make_age_string
|
|||
from files.routes.routehelpers import get_alt_graph, get_formkey
|
||||
from files.__main__ import app, cache
|
||||
|
||||
from urllib.parse import parse_qs, urlencode, urlsplit
|
||||
|
||||
@app.template_filter("formkey")
|
||||
def formkey(u):
|
||||
return get_formkey(u)
|
||||
|
@ -37,6 +39,15 @@ def template_asset(ctx, asset_path):
|
|||
return assetcache_path(asset_path)
|
||||
|
||||
|
||||
@app.template_filter("change_page")
|
||||
def template_change_page(new_page):
|
||||
parsed = urlsplit(request.full_path)
|
||||
query_dict = parse_qs(parsed.query)
|
||||
query_dict["page"] = new_page
|
||||
query_new = urlencode(query_dict, doseq=True)
|
||||
parsed = parsed._replace(query=query_new)
|
||||
return parsed.geturl()
|
||||
|
||||
@app.template_filter("asset_siteimg")
|
||||
def template_asset_siteimg(asset_path):
|
||||
# TODO: Add hashing for these using files.helpers.assetcache
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
<nav>
|
||||
<ul class="pagination pagination-sm mb-0 mt-4 pl-1">
|
||||
{% set num_pages = (next_exists / size) | round(0, 'ceil') | int %}
|
||||
|
@ -20,12 +21,12 @@
|
|||
|
||||
{% if start_point > 1 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="?sort={{sort}}&page=1&t={{t}}">1</a></small>
|
||||
<small><a class="page-link" href="{{1|change_page|safe}}">1</a></small>
|
||||
</li>
|
||||
|
||||
{% if start_point == 3 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="?sort={{sort}}&page=2&t={{t}}">2</a></small>
|
||||
<small><a class="page-link" href="{{2|change_page|safe}}">2</a></small>
|
||||
</li>
|
||||
{% elif start_point != 2 %}
|
||||
<li class="page-item">
|
||||
|
@ -36,14 +37,14 @@
|
|||
|
||||
{% for x in range(start_point, end_point+1) %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link {% if x == page %}active{% endif %}" href="?sort={{sort}}&page={{x}}&t={{t}}">{{x}}</a></small>
|
||||
<small><a class="page-link {% if x == page %}active{% endif %}" href="{{x|change_page|safe}}">{{x}}</a></small>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% if end_point < num_pages %}
|
||||
{% if end_point == num_pages-2 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="?sort={{sort}}&page={{num_pages-1}}&t={{t}}">{{num_pages-1}}</a></small>
|
||||
<small><a class="page-link" href="{{(num_pages-1)|change_page|safe}}">{{num_pages-1}}</a></small>
|
||||
</li>
|
||||
{% elif end_point != num_pages-1 %}
|
||||
<li class="page-item">
|
||||
|
@ -52,7 +53,7 @@
|
|||
{% endif %}
|
||||
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="?sort={{sort}}&page={{num_pages}}&t={{t}}">{{num_pages}}</a></small>
|
||||
<small><a class="page-link" href="{{num_pages|change_page|safe}}">{{num_pages}}</a></small>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue