~roshless/nnrss

09b0c4c773bad15afc4f08f024fe9db3a6754a18 — Roshless 1 year, 3 months ago 80f30d2
web_interface: move pagination to macro
M nnrss/templates/entries_list.html => nnrss/templates/entries_list.html +2 -26
@@ 36,30 36,6 @@
    </ul>
{% endblock %}
{% block footer %}
    <ul class="pagination justify-content-center pt-3">
	<li class="page-item {% if not entries.has_prev %}disabled{% endif %}">
	    <a class="page-link" href="{{ url_for("default_web.view_feed_entries", feed_id=feed['id'], page=entries.prev_num) }}" tabindex="-1">Previous</a>
	</li>
	{%- for page in entries.iter_pages() %}
	    {% if page %}
		{% if page != entries.page %}
		    <li class="page-item">
			<a class="page-link" href="{{ url_for("default_web.view_feed_entries", feed_id=feed['id'], page=page) }}">{{ page }}</a>
		    </li>
		{% else %}
		    <li class="page-item active">
			<a class="page-link" href="#" >{{ page }}</a>
		    </li>
		{% endif %}
	    {% else %}
		<li class="page-item disabled">
		    <a href="#" class="page-link">...</a>
		</li>
	    {% endif %}
	{%- endfor %}
	<li class="page-item {% if not entries.has_next %}disabled{% endif %}">
	    <a class="page-link" href="{{ url_for("default_web.view_feed_entries", feed_id=feed['id'], page=entries.next_num) }}">Next</a>
	</li>
    </ul>
</div>
    {% from "macros/renderpagination.html" import render_pagination %}
    {{ render_pagination("default_web.view_feed_entries", feed, entries) }}
{% endblock %}

M nnrss/templates/entries_list_unread.html => nnrss/templates/entries_list_unread.html +3 -26
@@ 1,4 1,5 @@
{% extends 'base.html' %}
{% set request_path = request.path|replace("/unread", "") %}

{% block header %}
<h2 class="text-center">{% block title %}{{ feed['title'] }}{% endblock %}</h2>


@@ 27,30 28,6 @@
    </ul>
{% endblock %}
{% block footer %}
    <ul class="pagination justify-content-center pt-3">
	<li class="page-item {% if not entries.has_prev %}disabled{% endif %}">
	    <a class="page-link" href="{{ url_for("default_web.view_feed_entries", feed_id=feed['id'], page=entries.prev_num) }}" tabindex="-1">Previous</a>
	</li>
	{%- for page in entries.iter_pages() %}
	    {% if page %}
		{% if page != entries.page %}
		    <li class="page-item">
			<a class="page-link" href="{{ url_for("default_web.view_feed_entries", feed_id=feed['id'], page=page) }}">{{ page }}</a>
		    </li>
		{% else %}
		    <li class="page-item active">
			<a class="page-link" href="#" >{{ page }}</a>
		    </li>
		{% endif %}
	    {% else %}
		<li class="page-item disabled">
		    <a href="#" class="page-link">...</a>
		</li>
	    {% endif %}
	{%- endfor %}
	<li class="page-item {% if not entries.has_next %}disabled{% endif %}">
	    <a class="page-link" href="{{ url_for("default_web.view_feed_entries", feed_id=feed['id'], page=entries.next_num) }}">Next</a>
	</li>
    </ul>
</div>
    {% from "macros/renderpagination.html" import render_pagination %}
    {{ render_pagination("default_web.view_feed_entries_unread", feed, entries) }}
{% endblock %}

A nnrss/templates/macros/renderpagination.html => nnrss/templates/macros/renderpagination.html +27 -0
@@ 0,0 1,27 @@
{% macro render_pagination(template_name, feed, entries) %}
    <ul class="pagination justify-content-center pt-3">
	<li class="page-item {% if not entries.has_prev %}disabled{% endif %}">
	    <a class="page-link" href="{{ url_for(template_name, feed_id=feed['id'], page=entries.prev_num) }}" tabindex="-1">Previous</a>
	</li>
	{%- for page in entries.iter_pages() %}
	    {% if page %}
		{% if page != entries.page %}
		    <li class="page-item">
			<a class="page-link" href="{{ url_for(template_name, feed_id=feed['id'], page=page) }}">{{ page }}</a>
		    </li>
		{% else %}
		    <li class="page-item active">
			<a class="page-link" href="#" >{{ page }}</a>
		    </li>
		{% endif %}
	    {% else %}
		<li class="page-item disabled">
		    <a href="#" class="page-link">...</a>
		</li>
	    {% endif %}
	{%- endfor %}
	<li class="page-item {% if not entries.has_next %}disabled{% endif %}">
	    <a class="page-link" href="{{ url_for(template_name, feed_id=feed['id'], page=entries.next_num) }}">Next</a>
	</li>
    </ul>
{% endmacro %}