From f41328156e9d145fae5f46f666df4622de319625 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 1 Oct 2015 10:58:03 +0900 Subject: [PATCH] Remove unused pagination lib Change-Id: I018fa65ecdb550156ac52afb202ff6cb42771570 --- lodgeit/controllers/pastes.py | 1 - lodgeit/lib/pagination.py | 85 ----------------------------------- 2 files changed, 86 deletions(-) delete mode 100644 lodgeit/lib/pagination.py diff --git a/lodgeit/controllers/pastes.py b/lodgeit/controllers/pastes.py index 085f95d..78c6085 100644 --- a/lodgeit/controllers/pastes.py +++ b/lodgeit/controllers/pastes.py @@ -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 diff --git a/lodgeit/lib/pagination.py b/lodgeit/lib/pagination.py deleted file mode 100644 index 7d4e877..0000000 --- a/lodgeit/lib/pagination.py +++ /dev/null @@ -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='%(page)d', - active='%(page)d', - 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' Next »') % - link_builder(next)) - elif gray_next_link: - result.append(_(u' Next »')) - if prev_link: - if prev is not None: - result.insert(0, _(u'« Prev ') % - link_builder(prev)) - elif gray_prev_link: - result.insert(0, _(u'« Prev ')) - - return u''.join(result)