margin-top: .7em;
margin-bottom: .3em;
padding: .3em 0;
- font-size: .9em;
+ font-size: 1em;
background-color: #fff;
border-bottom: 1px solid #aaa;
color: #333;
font-weight: bold;
}
.pagination a {
- background-color: #eee;
+ background-color: #fff;
border-bottom: none;
- font-size: .9em;
+ font-size: 1em;
padding: .3em;
}
--- /dev/null
+{% extends "telemeta_default/paginator.html" %}
{% block head_title %}{% trans "Media Collections" %} - {{ block.super }}{% endblock %}
{% block title%}
- <h1>{% trans "Media Collections" %}</h1>
+ <h1>{% trans "Media Collections" %}</h1>
{% endblock %}
-{% block title_buttons %}
+{% block title_buttons %}
<a href="{% url telemeta-collections %}" class="component_icon button icon_search">{% trans "All" %}</a>
<a href="{% url telemeta-collections-novel %}" class="component_icon button icon_filter">{% trans "Unpublished" %}</a>
<a href="{% url telemeta-collections-published %}" class="component_icon button icon_filter">{% trans "Published" %}</a>
<p class="pagination">
{% blocktrans %}Collections {{ first_on_page }} to {{ last_on_page }} on {{ hits }}{% endblocktrans %}
-{% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %}
-{% if has_next %} <a href="?page={{ next }}&{{criteria|build_query_string}}">>></a> {% endif %}
+{% if is_paginated %}{% load paginator %}{% paginator 5 %}{% endif %}
</p>
{% endif %}
<table class="listing">
<p class="pagination">
{% blocktrans %}Items {{ first_on_page }} to {{ last_on_page }} on {{ hits }}{% endblocktrans %}
-{% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %}
-{% if has_next %} <a href="?page={{ next }}&{{criteria|build_query_string}}">>></a> {% endif %}
+{% if is_paginated %}{% load paginator %}{% paginator 5 %}{% endif %}
</p>
{% endif %}
{% block head_title %}{% trans "Media Items" %} - {{ block.super }}{% endblock %}
{% block title %}
- <img src="images/item.png" style="vertical-align:middle" /> <h1>{% trans "Media Items" %}</h1>
+ <img src="images/item.png" style="vertical-align:middle" /> <h1>{% trans "Media Items" %}</h1>
{% endblock %}
{% block title_buttons %}
{% if user.is_authenticated and perms.telemeta.add_mediaitem %}
--- /dev/null
+{% load i18n %}
+
+{% if has_previous %}
+ <a href="?page={{ previous }}">< {% trans "Previous" %}</a>
+{% endif %}
+
+{% if show_first %}
+<a href="?page=1">1</a> ...
+{% endif %}
+{% for linkpage in page_numbers %}
+ {% ifequal linkpage page %}
+ {{ page }}
+ {% else %}
+ <a href="?page={{ linkpage }}">{{ linkpage }}</a>
+ {% endifequal %}
+{% endfor %}
+{% if show_last %}
+ ...
+ <a href="?page=last">{{ pages }}</a>
+{% endif %}
+{% if has_next %}
+ <a href="?page={{ next }}">{% trans "Next" %} ></a>
+{% endif %}
--- /dev/null
+from django import template
+
+register = template.Library()
+
+def paginator(context, adjacent_pages=2):
+ """
+ To be used in conjunction with the object_list generic view.
+
+ Adds pagination context variables for use in displaying first, adjacent and
+ last page links in addition to those created by the object_list generic
+ view.
+
+ Thanks to tummy.com, ltd.
+ http://www.tummy.com/Community/Articles/django-pagination/
+
+ """
+ startPage = max(context['page'] - adjacent_pages, 1)
+ if startPage <= 3: startPage = 1
+ endPage = context['page'] + adjacent_pages + 1
+ if endPage >= context['pages'] - 1: endPage = context['pages'] + 1
+ page_numbers = [n for n in range(startPage, endPage) \
+ if n > 0 and n <= context['pages']]
+ page_obj = context['page_obj']
+ paginator = context['paginator']
+
+ return {
+ 'page_obj': page_obj,
+ 'paginator': paginator,
+ 'hits': context['hits'],
+ 'results_per_page': context['results_per_page'],
+ 'page': context['page'],
+ 'pages': context['pages'],
+ 'page_numbers': page_numbers,
+ 'next': context['next'],
+ 'previous': context['previous'],
+ 'has_next': context['has_next'],
+ 'has_previous': context['has_previous'],
+ 'show_first': 1 not in page_numbers,
+ 'show_last': context['pages'] not in page_numbers,
+ }
+
+register.inclusion_tag('telemeta_default/paginator.html', takes_context=True)(paginator)
+
raise template.TemplateSyntaxError("'set' tag must be of the form: {% set <var_name> = <var_value> %}")
return SetVarNode(parts[1], parts[3])
+def paginator(context, adjacent_pages=2):
+ """
+ To be used in conjunction with the object_list generic view.
+
+ Adds pagination context variables for use in displaying first, adjacent and
+ last page links in addition to those created by the object_list generic
+ view.
+
+ """
+ startPage = max(context['page'] - adjacent_pages, 1)
+ if startPage <= 3: startPage = 1
+ endPage = context['page'] + adjacent_pages + 1
+ if endPage >= context['pages'] - 1: endPage = context['pages'] + 1
+ page_numbers = [n for n in range(startPage, endPage) \
+ if n > 0 and n <= context['pages']]
+ page_obj = context['page_obj']
+ paginator = context['paginator']
+
+ return {
+ 'page_obj': page_obj,
+ 'paginator': paginator,
+ 'hits': context['hits'],
+ 'results_per_page': context['results_per_page'],
+ 'page': context['page'],
+ 'pages': context['pages'],
+ 'page_numbers': page_numbers,
+ 'next': context['next'],
+ 'previous': context['previous'],
+ 'has_next': context['has_next'],
+ 'has_previous': context['has_previous'],
+ 'show_first': 1 not in page_numbers,
+ 'show_last': context['pages'] not in page_numbers,
+ }
+
+register.inclusion_tag('paginator.html', takes_context=True)(paginator)