mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-09 14:37:36 +01:00
parent
ba3b108239
commit
660b813ff7
@ -65,11 +65,6 @@ def list_all():
|
|||||||
search = request.args.get("q")
|
search = request.args.get("q")
|
||||||
type_name = request.args.get("type")
|
type_name = request.args.get("type")
|
||||||
|
|
||||||
next_url = url_for("packages.list_all", type=type_name, q=search, page=query.next_num) \
|
|
||||||
if query.has_next else None
|
|
||||||
prev_url = url_for("packages.list_all", type=type_name, q=search, page=query.prev_num) \
|
|
||||||
if query.has_prev else None
|
|
||||||
|
|
||||||
authors = []
|
authors = []
|
||||||
if search:
|
if search:
|
||||||
authors = User.query \
|
authors = User.query \
|
||||||
@ -83,12 +78,17 @@ def list_all():
|
|||||||
qb.show_discarded = True
|
qb.show_discarded = True
|
||||||
topics = qb.buildTopicQuery().all()
|
topics = qb.buildTopicQuery().all()
|
||||||
|
|
||||||
|
def url_builder(page):
|
||||||
|
args = dict(request.args)
|
||||||
|
args["page"] = page
|
||||||
|
return url_for("packages.list_all", **args)
|
||||||
|
|
||||||
tags = Tag.query.all()
|
tags = Tag.query.all()
|
||||||
return render_template("packages/list.html", \
|
return render_template("packages/list.html", \
|
||||||
title=title, packages=query.items, topics=topics, \
|
title=title, packages=query.items, topics=topics, \
|
||||||
query=search, tags=tags, type=type_name, \
|
query=search, tags=tags, type=type_name, \
|
||||||
authors = authors, \
|
authors=authors, packages_count=query.total, \
|
||||||
next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, packages_count=query.total)
|
pagination=query, url_builder=url_builder)
|
||||||
|
|
||||||
|
|
||||||
def getReleases(package):
|
def getReleases(package):
|
||||||
|
29
app/templates/macros/pagination.html
Normal file
29
app/templates/macros/pagination.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{% macro render_pagination(pagination, url_builder) %}
|
||||||
|
<ul class="pagination mt-4">
|
||||||
|
{% set prev_url = url_builder(pagination.prev_num) if pagination.has_prev %}
|
||||||
|
{% set next_url = url_builder(pagination.next_num) if pagination.has_next %}
|
||||||
|
|
||||||
|
<li class="page-item {% if not prev_url %}disabled{% endif %}">
|
||||||
|
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>«</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{%- for page in pagination.iter_pages() %}
|
||||||
|
{% if page %}
|
||||||
|
<li class="page-item {% if page == pagination.page %}active{% endif %}">
|
||||||
|
<a class="page-link"
|
||||||
|
href="{{ url_builder(page) }}">
|
||||||
|
{{ page }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item disabled">
|
||||||
|
&ellipsis;
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
<li class="page-item {% if not next_url %}disabled{% endif %}">
|
||||||
|
<a class="page-link" {% if next_url %}href="{{ next_url }}"{% endif %}>»</a>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
@ -23,22 +23,10 @@
|
|||||||
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
||||||
{{ render_pkggrid(packages) }}
|
{{ render_pkggrid(packages) }}
|
||||||
|
|
||||||
<ul class="pagination mt-4">
|
|
||||||
<li class="page-item {% if not prev_url %}disabled{% endif %}">
|
{% from "macros/pagination.html" import render_pagination %}
|
||||||
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>«</a>
|
{{ render_pagination(pagination, url_builder) }}
|
||||||
</li>
|
|
||||||
{% for n in range(1, page_max+1) %}
|
|
||||||
<li class="page-item {% if n == page %}active{% endif %}">
|
|
||||||
<a class="page-link"
|
|
||||||
href="{{ url_for('packages.list_all', type=type, q=query, page=n) }}">
|
|
||||||
{{ n }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
<li class="page-item {% if not next_url %}disabled{% endif %}">
|
|
||||||
<a class="page-link" {% if next_url %}href="{{ next_url }}"{% endif %}>»</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{% if topics %}
|
{% if topics %}
|
||||||
<h2 style="margin-top:2em;">More content from the forums</h2>
|
<h2 style="margin-top:2em;">More content from the forums</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user