move some templates into one macro
This commit is contained in:
40
app/templates/common/macros.html
Normal file
40
app/templates/common/macros.html
Normal file
@ -0,0 +1,40 @@
|
||||
{% macro pager(current_page, page_count) %}
|
||||
{% set left_start = (1, current_page - 5) | max %}
|
||||
{% set right_end = (page_count, current_page + 5) | min %}
|
||||
|
||||
<div class="pager">
|
||||
<span>Page:</span>
|
||||
{% if current_page > 5 %}
|
||||
<a href="?page=1" class="pagebutton">1</a>
|
||||
{% if left_start > 2 %}
|
||||
<span class="currentpage">…</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% for i in range(left_start, current_page - 1) %}
|
||||
<a href="?page={{i}}" class="pagebutton">{{i}}</a>
|
||||
{% endfor %}
|
||||
{% if page_count > 0 %}
|
||||
<span class="currentpage">{{current_page}}</span>
|
||||
{% endif %}
|
||||
{% for i in range(current_page + 1, right_end) %}
|
||||
<a href="?page={{i}}" class="pagebutton">{{i}}</a>
|
||||
{% endfor %}
|
||||
{% if right_end < page_count %}
|
||||
{% if right_end < page_count - 1 %}
|
||||
<span class="currentpage">…</span>
|
||||
{% endif %}
|
||||
<a href="?page={{page_count}}" class="pagebutton">{{page_count}}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro infobox(message, kind=InfoboxKind.INFO) %}
|
||||
<div class="{{ "infobox " + InfoboxHTMLClass[kind] }}">
|
||||
<span>
|
||||
<div class="infobox-icon-container">
|
||||
<img src="{{ InfoboxIcons[kind] }}">
|
||||
</div>
|
||||
{{ message }}
|
||||
</span>
|
||||
</div>
|
||||
{% endmacro %}
|
Reference in New Issue
Block a user