convert pagination into a macro
parent
f15fe9bc6e
commit
6d6ba89a9a
|
@ -59,5 +59,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -17,5 +17,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
</div>
|
||||
{% endblock %}
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -30,5 +30,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -37,5 +37,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination("pb-0 pl-0 pt-1")}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -37,5 +37,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -37,5 +37,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{% if not request.headers.get("xhr") %}
|
||||
{% if focused_comment %}
|
||||
<script defer src="{{'js/focused_comment.js' | asset}}"></script>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{% extends "default.html" %}
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{% block pagetitle %}!{{group}}{% endblock %}
|
||||
{% block content %}
|
||||
<div class="mx-2">
|
||||
|
|
|
@ -89,8 +89,7 @@
|
|||
<button type="submit" class="btn btn-{{pcolor}} text-{{pcolor}} mx-2"><i type="submit" class="fas fas fa-thumbtack fa-rotate--45 mr-2"></i>Pins</button>
|
||||
</form>
|
||||
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.sorting_buttons(POST_SORTS, True) -}}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -102,8 +101,8 @@
|
|||
{% block PseudoSubmitForm %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if SITE_NAME == 'WPD' and listing %}
|
||||
{% include "pagination.html" %}
|
||||
{% if (SITE_NAME == 'WPD' and listing) or True %}
|
||||
{{macros.pagination("pl-1 py-0")}}
|
||||
{% endif %}
|
||||
|
||||
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %}">
|
||||
|
@ -117,7 +116,7 @@
|
|||
|
||||
{% block pagenav %}
|
||||
{% if listing %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endif %}
|
||||
|
||||
{% if request.path == '/' and v %}
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mt-1 mb-2">
|
||||
<div class="d-flex px-2 align-items-center mt-4">
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS) -}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -23,5 +22,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<div class="p-3">There's nothing here right now.</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
|
||||
{% block pagenav %}
|
||||
{% if notifications %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endif %}
|
||||
|
||||
<link rel="stylesheet" href="{{('css/notifications.css') | asset}}">
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
|
||||
<nav>
|
||||
<ul class="pagination pagination-sm mb-0 {% if request.path.endswith('/bank_statement') %}pb-0 pl-0 pt-1{% else %}pl-1 mt-4{% endif %}">
|
||||
{% if not size %}
|
||||
{% set size = PAGE_SIZE %}
|
||||
{% endif %}
|
||||
{% set num_pages = (total / size) | round(0, 'ceil') | int %}
|
||||
|
||||
{% set start_point = page - 2 %}
|
||||
{% if start_point < 1 %}
|
||||
{% set start_point = 1 %}
|
||||
{% endif %}
|
||||
|
||||
{% set end_point = start_point+4 %}
|
||||
{% if end_point > num_pages %}
|
||||
{% set start_point = start_point-(end_point-num_pages) %}
|
||||
{% set end_point = num_pages %}
|
||||
{% endif %}
|
||||
|
||||
{% if start_point < 1 %}
|
||||
{% set start_point = 1 %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if start_point > 1 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{'page'|change_arg(1, request.full_path)|safe}}">1</a></small>
|
||||
</li>
|
||||
|
||||
{% if start_point == 3 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{'page'|change_arg(2, request.full_path)|safe}}">2</a></small>
|
||||
</li>
|
||||
{% elif start_point != 2 %}
|
||||
<li class="page-item">
|
||||
<small class="page-link dots">...</small>
|
||||
</li>
|
||||
{% set start_point = start_point + 1 %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for x in range(start_point, end_point+1) %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link {% if x == page %}active disabled{% endif %}" href="{{'page'|change_arg(x, request.full_path)|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="{{'page'|change_arg(num_pages-1, request.full_path)|safe}}">{{num_pages-1}}</a></small>
|
||||
</li>
|
||||
{% elif end_point != num_pages-1 %}
|
||||
<li class="page-item">
|
||||
<small class="page-link dots">...</small>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{'page'|change_arg(num_pages, request.full_path)|safe}}">{{num_pages}}</a></small>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
|
@ -305,8 +305,7 @@
|
|||
<div class="row border-md-0 comment-section pb-3">
|
||||
<div class="col border-top">
|
||||
<div class="comments-count py-3">
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS, True) -}}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS, True) -}}
|
||||
</div>
|
||||
|
||||
{{macros.comment_reply_box(p.fullname, 'comment-reply-' + p.fullname, subwrapper_css_classes='mb-3', enable_cancel_button=false)}}
|
||||
|
|
|
@ -49,8 +49,7 @@
|
|||
</div>
|
||||
|
||||
<div class="comments-count py-3">
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS, True) -}}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS, True) -}}
|
||||
</div>
|
||||
|
||||
<div class="comment-section">
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{%- import 'util/macros.html' as macros with context -%}
|
||||
|
||||
{% if v %}
|
||||
{% include "modals/award.html" %}
|
||||
|
|
|
@ -103,8 +103,7 @@
|
|||
|
||||
{% if not '/users' in request.path %}
|
||||
<div class="mt-3 d-flex align-items-center fl-r">
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{% if "/posts" in request.path %}
|
||||
{{- macros.sorting_buttons(POST_SORTS) -}}
|
||||
{% else %}
|
||||
|
@ -148,5 +147,5 @@
|
|||
</div>
|
||||
{% endblock %}
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{%- import 'util/macros.html' as macros with context -%}
|
||||
|
||||
{% macro toggle_section(title, id, name, flag, below_text, disabled) %}
|
||||
<div id="{{id}}_toggle" class="d-lg-flex border-bottom">
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</div>
|
||||
{% endblock %}
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
<div class="toast clipboard" id="toast-success" data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
|
||||
<div class="toast-body text-center">
|
||||
<i class="fas fa-check-circle text-success mr-2"></i>Link copied to clipboard
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
</div>
|
||||
{% endblock %}
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
{% block navbar %}{% endblock %}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
||||
({{total}} user{{macros.plural(total)}})
|
||||
|
|
|
@ -36,5 +36,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
<div class="d-flex justify-content-between align-items-center" style="padding-top:10px">
|
||||
|
||||
<div class="d-flex align-items-center">
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{% if "/posts" in request.path %}
|
||||
{{- macros.sorting_buttons(POST_SORTS) -}}
|
||||
{% else %}
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
{% block pagenav %}
|
||||
{% if listing %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endif %}
|
||||
|
||||
{% if request.path.endswith('/posts') %}
|
||||
|
|
|
@ -26,5 +26,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -37,5 +37,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
{% include "pagination.html" %}
|
||||
{{macros.pagination()}}
|
||||
{% endblock %}
|
||||
|
|
|
@ -439,3 +439,68 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro pagination(classes="pl-1 mt-4") %}
|
||||
<ul class="pagination pagination-sm mb-0 {{classes}}">
|
||||
{% if not size %}
|
||||
{% set size = PAGE_SIZE %}
|
||||
{% endif %}
|
||||
{% set num_pages = (total / size) | round(0, 'ceil') | int %}
|
||||
|
||||
{% set start_point = page - 2 %}
|
||||
{% if start_point < 1 %}
|
||||
{% set start_point = 1 %}
|
||||
{% endif %}
|
||||
|
||||
{% set end_point = start_point+4 %}
|
||||
{% if end_point > num_pages %}
|
||||
{% set start_point = start_point-(end_point-num_pages) %}
|
||||
{% set end_point = num_pages %}
|
||||
{% endif %}
|
||||
|
||||
{% if start_point < 1 %}
|
||||
{% set start_point = 1 %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if start_point > 1 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{'page'|change_arg(1, request.full_path)|safe}}">1</a></small>
|
||||
</li>
|
||||
|
||||
{% if start_point == 3 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{'page'|change_arg(2, request.full_path)|safe}}">2</a></small>
|
||||
</li>
|
||||
{% elif start_point != 2 %}
|
||||
<li class="page-item">
|
||||
<small class="page-link dots">...</small>
|
||||
</li>
|
||||
{% set start_point = start_point + 1 %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for x in range(start_point, end_point+1) %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link {% if x == page %}active disabled{% endif %}" href="{{'page'|change_arg(x, request.full_path)|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="{{'page'|change_arg(num_pages-1, request.full_path)|safe}}">{{num_pages-1}}</a></small>
|
||||
</li>
|
||||
{% elif end_point != num_pages-1 %}
|
||||
<li class="page-item">
|
||||
<small class="page-link dots">...</small>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{'page'|change_arg(num_pages, request.full_path)|safe}}">{{num_pages}}</a></small>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endmacro %}
|
||||
|
|
Loading…
Reference in New Issue