Remove unused pagination lib

Change-Id: I018fa65ecdb550156ac52afb202ff6cb42771570
This commit is contained in:
David Pursehouse 2015-10-01 10:58:03 +09:00
parent c17e0a3741
commit f41328156e
2 changed files with 0 additions and 86 deletions

View File

@ -17,7 +17,6 @@ from lodgeit.utils import render_to_response, url_for
from lodgeit.models import Paste
from lodgeit.database import session
from lodgeit.lib.highlighting import list_languages, STYLES, get_style
from lodgeit.lib.pagination import generate_pagination
from lodgeit.lib.captcha import check_hashed_solution, Captcha

View File

@ -1,85 +0,0 @@
# -*- coding: utf-8 -*-
"""
lodgeit.lib.pagination
~~~~~~~~~~~~~~~~~~~~~~
Fancy Pagination.
:copyright: 2007 by Armin Ronacher.
:license: BSD
"""
import math
from lodgeit.i18n import _
def generate_pagination(page, per_page, total, link_builder=None,
normal='<a href="%(url)s">%(page)d</a>',
active='<strong>%(page)d</strong>',
commata=',\n', ellipsis=' ...\n', threshold=3,
prev_link=True, next_link=True,
gray_prev_link=True, gray_next_link=True):
"""Generates a pagination.
:param page: current page number
:param per_page: items per page
:param total: total number of items
:param link_builder: a function which is called with a page number
and has to return the link to a page. Per
default it links to ``?page=$PAGE``
:param normal: template for normal (not active) link
:param active: template for active link
:param commata: inserted into the output to separate two links
:param ellipsis: inserted into the output to display an ellipsis
:param threshold: number of links next to each node (left end,
right end and current page)
:param prev_link: display back link
:param next_link: dipslay next link
:param gray_prev_link: the back link is displayed as span class disabled
if no backlink exists. otherwise it's not
displayed at all
:param gray_next_link: like `gray_prev_link` just for the next page link
"""
page = int(page or 1)
if link_builder is None:
link_builder = lambda page: '?page=%d' % page
was_ellipsis = False
result = []
pages = int(math.ceil(total / float(per_page)))
prev = None
next = None
for num in xrange(1, pages + 1):
if num == page:
was_ellipsis = False
if num - 1 == page:
next = num
if num + 1 == page:
prev = num
if num <= threshold or num > pages - threshold or \
abs(page - num) < math.ceil(threshold / 2.0):
if result and result[-1] != ellipsis:
result.append(commata)
link = link_builder(num)
template = num == page and active or normal
result.append(template % {
'url': link,
'page': num
})
elif not was_ellipsis:
was_ellipsis = True
result.append(ellipsis)
if next_link:
if next is not None:
result.append(_(u' <a href="%s">Next &raquo;</a>') %
link_builder(next))
elif gray_next_link:
result.append(_(u' <span class="disabled">Next &raquo;</span>'))
if prev_link:
if prev is not None:
result.insert(0, _(u'<a href="%s">&laquo; Prev</a> ') %
link_builder(prev))
elif gray_prev_link:
result.insert(0, _(u'<span class="disabled">&laquo; Prev</span> '))
return u''.join(result)