Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jmcclell/django-bootstrap-pagination
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.5.0
Choose a base ref
...
head repository: jmcclell/django-bootstrap-pagination
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jan 14, 2014

  1. add waffle.io badge

    waffle-with-pears committed Jan 14, 2014
    Copy the full SHA
    a4f841a View commit details
  2. Merge pull request #17 from waffleio/master

    waffle.io Badge
    jmcclell committed Jan 14, 2014
    Copy the full SHA
    e15dd01 View commit details

Commits on Jan 25, 2014

  1. Copy the full SHA
    acde8f6 View commit details
  2. Copy the full SHA
    338e79c View commit details
  3. Merge pull request #18 from ctulek/patch-1

    Removed alignment related documentation
    jmcclell committed Jan 25, 2014
    Copy the full SHA
    c4b6025 View commit details
  4. Merge pull request #19 from ctulek/patch-2

    Removed alignment related documentation
    jmcclell committed Jan 25, 2014
    Copy the full SHA
    4d0805a View commit details

Commits on Feb 14, 2014

  1. Copy the full SHA
    ada39d8 View commit details
  2. Merge pull request #20 from bitdeli-chef/master

    Add a Bitdeli Badge to README
    jmcclell committed Feb 14, 2014
    Copy the full SHA
    12a2352 View commit details

Commits on May 16, 2014

  1. Added PyPI badges

    jmcclell committed May 16, 2014
    Copy the full SHA
    3dae21f View commit details

Commits on Dec 3, 2014

  1. python3 installation support

    miki725 committed Dec 3, 2014
    Copy the full SHA
    74a4c94 View commit details

Commits on Dec 7, 2014

  1. Copy the full SHA
    b06b7a4 View commit details
  2. proper exception handling

    miki725 committed Dec 7, 2014
    Copy the full SHA
    001d2f6 View commit details

Commits on Jan 9, 2015

  1. Merge pull request #26 from miki725/master

    python3 compatibility
    jmcclell committed Jan 9, 2015
    Copy the full SHA
    5fcdf78 View commit details
  2. Copy the full SHA
    d633499 View commit details
  3. Bumped version

    jmcclell committed Jan 9, 2015
    Copy the full SHA
    0d9ddb3 View commit details

Commits on Jun 8, 2015

  1. Added call for help note

    jmcclell committed Jun 8, 2015
    Copy the full SHA
    9754a6f View commit details

Commits on Jun 15, 2015

  1. feat: add url_anchor parameter

    Gagaro committed Jun 15, 2015
    Copy the full SHA
    46c5704 View commit details
  2. update README

    Gagaro committed Jun 15, 2015
    Copy the full SHA
    37c16df View commit details
  3. fixup! update README

    Gagaro committed Jun 15, 2015
    Copy the full SHA
    1053a9f View commit details
  4. feat: allow empty anchor

    Gagaro committed Jun 15, 2015
    Copy the full SHA
    497801e View commit details

Commits on Aug 25, 2015

  1. Merge pull request #25 from Gagaro/master

    Adding a parameter to set url anchor
    jmcclell committed Aug 25, 2015
    Copy the full SHA
    1744207 View commit details

Commits on Dec 29, 2015

  1. adding show_index_range option

    Providing an option to show the index range in preference to the page number.
    richardbrockie committed Dec 29, 2015
    Copy the full SHA
    c6c3a4c View commit details
  2. adding show_index_range option

    template options to show_index_range
    richardbrockie committed Dec 29, 2015
    Copy the full SHA
    2998ec6 View commit details

Commits on Dec 30, 2015

  1. Merge pull request #42 from richardbrockie/master

    show_index_range option
    jmcclell committed Dec 30, 2015
    Copy the full SHA
    62d3946 View commit details

Commits on Dec 31, 2015

  1. Update README.md

    Adding definition of show_index_range option in bootstrap_paginate.
    richardbrockie committed Dec 31, 2015
    Copy the full SHA
    f5a3b00 View commit details
  2. Update setup.py

    Version bump given the new parameter?
    richardbrockie committed Dec 31, 2015
    Copy the full SHA
    a193b75 View commit details

Commits on Jan 2, 2016

  1. Merge pull request #43 from richardbrockie/master

    Update README.md
    jmcclell committed Jan 2, 2016
    Copy the full SHA
    315430d View commit details

Commits on Jan 21, 2016

  1. Copy the full SHA
    8aab8ed View commit details
  2. Merge pull request #45 from wetneb/master

    Add escape filters on URLs, fixes #41.
    jmcclell committed Jan 21, 2016
    Copy the full SHA
    b69a91d View commit details

Commits on Feb 9, 2016

  1. Compatibility with django110

    Pass template.render() a dict instead of a context. The autoencoder parameter
    is now applied by marking the labels as safe html, causing them to render
    unencoded.
    kvdveer committed Feb 9, 2016
    Copy the full SHA
    5f5a553 View commit details

Commits on Feb 16, 2016

  1. Add unit tests

    kvdveer committed Feb 16, 2016
    Copy the full SHA
    3973e99 View commit details
  2. Merge pull request #48 from ondergetekende/unit-tests

    Add unit tests
    kvdveer committed Feb 16, 2016
    Copy the full SHA
    cb6a543 View commit details

Commits on Feb 17, 2016

  1. Compatibility with django110

    Pass template.render() a dict instead of a context. The autoencoder parameter
    is now applied by marking the labels as safe html, causing them to render
    unencoded.
    kvdveer committed Feb 17, 2016
    Copy the full SHA
    081ba15 View commit details
  2. Merge pull request #46 from ondergetekende/django110

    Compatibility with Django 1.10
    kvdveer committed Feb 17, 2016
    Copy the full SHA
    9b8db89 View commit details
  3. Merge branch 'django110'

    kvdveer committed Feb 17, 2016
    Copy the full SHA
    f8beae1 View commit details
  4. Turn disabled link into span

    Gagaro authored and kvdveer committed Feb 17, 2016
    Copy the full SHA
    1ec1483 View commit details
  5. Copy the full SHA
    752cbde View commit details

Commits on Feb 28, 2016

  1. Replaced broken badges

    jmcclell committed Feb 28, 2016
    Copy the full SHA
    dff9fb3 View commit details
  2. Copy the full SHA
    78aafd9 View commit details

Commits on Mar 1, 2016

  1. Prepare for 1.6.0 on pypi

    kvdveer committed Mar 1, 2016
    Copy the full SHA
    3339b9e View commit details
  2. Copy the full SHA
    3905d11 View commit details
  3. Prepare for 1.6.1 on pypi

    kvdveer committed Mar 1, 2016
    Copy the full SHA
    bc6d4f0 View commit details

Commits on Jun 21, 2016

  1. Copy the full SHA
    e7c5a44 View commit details

Commits on Aug 12, 2016

  1. Merge pull request #53 from adilkhash/master

    fixed context.current_app in Django 1.10
    jmcclell authored Aug 12, 2016
    Copy the full SHA
    8487220 View commit details
  2. Preparing 1.6.2 release

    jmcclell committed Aug 12, 2016
    Copy the full SHA
    3ba0b6a View commit details

Commits on Nov 10, 2016

  1. Copy the full SHA
    fe3861f View commit details
  2. Merge pull request #58 from emorozov/master

    Fixed disabled previous link class.
    kvdveer authored Nov 10, 2016
    Copy the full SHA
    63322b6 View commit details

Commits on Oct 5, 2017

  1. Copy the full SHA
    fc5ff9d View commit details
  2. Simplify the way the template tags handle parameters

    Boolean attributes now also accept actual booleans (instead of just
    the string "true")
    url_get_params can now be supplied as a dict or list of 2-tuples.
    kvdveer committed Oct 5, 2017
    Copy the full SHA
    38c912c View commit details

Commits on Feb 3, 2018

  1. Update bootstrap_pagination.py (#66)

    Fixed Django 2 import error
    adilkhash authored and kvdveer committed Feb 3, 2018
    Copy the full SHA
    e85aa35 View commit details
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.settings
.project
.pydevproject
.ropeproject
*.pyc
*.pyo
*$py.class
/django_bootstrap_pagination.egg-info
/dist
/build
/build
/htmlcov
.coverage
87 changes: 87 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
language: python
sudo: required
dist: xenial
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
# - "nightly" Fails irregularly
# - "pypy" Unable to install requirements
# - "pypy3" Unable to install requirements

env:
matrix:
- DJANGO="Django<1.3"
- DJANGO="Django<1.4"
- DJANGO="Django<1.5"
- DJANGO="Django<1.6"
- DJANGO="Django<1.7"
- DJANGO="Django<1.8"
- DJANGO="Django<1.9"
- DJANGO="Django<1.10"
- DJANGO="Django<1.11"
- DJANGO="Django<2.0"
- DJANGO="Django<3.0" # Covers all of 2.x

install:
- pip install "pip<8.0.0" wheel
- pip install "$DJANGO"
- pip install -r test-requirements.txt
cache:
directories:
- $HOME/.cache/pip
matrix:
exclude:
# Python 3.7 is supported as of django 2.0
- {python: "3.7", env: DJANGO="Django<1.3"}
- {python: "3.7", env: DJANGO="Django<1.4"}
- {python: "3.7", env: DJANGO="Django<1.5"}
- {python: "3.7", env: DJANGO="Django<1.6"}
- {python: "3.7", env: DJANGO="Django<1.7"}
- {python: "3.7", env: DJANGO="Django<1.8"}
- {python: "3.7", env: DJANGO="Django<1.9"}
- {python: "3.7", env: DJANGO="Django<1.10"}
- {python: "3.7", env: DJANGO="Django<1.11"}
- {python: "3.7", env: DJANGO="Django<2.0"}

# Python 3.6 is supported as of django 1.8
- {python: "3.6", env: DJANGO="Django<1.3"}
- {python: "3.6", env: DJANGO="Django<1.4"}
- {python: "3.6", env: DJANGO="Django<1.5"}
- {python: "3.6", env: DJANGO="Django<1.6"}
- {python: "3.6", env: DJANGO="Django<1.7"}
- {python: "3.6", env: DJANGO="Django<1.8"}

# Python 3.5 is supported as of django 1.8
- {python: "3.5", env: DJANGO="Django<1.3"}
- {python: "3.5", env: DJANGO="Django<1.4"}
- {python: "3.5", env: DJANGO="Django<1.5"}
- {python: "3.5", env: DJANGO="Django<1.6"}
- {python: "3.5", env: DJANGO="Django<1.7"}
- {python: "3.5", env: DJANGO="Django<1.8"}

# Python 3.4 is supported as of django 1.5, but dropped by 2.0+
- {python: "3.4", env: DJANGO="Django<1.3"}
- {python: "3.4", env: DJANGO="Django<1.4"}
- {python: "3.4", env: DJANGO="Django<1.5"}
- {python: "3.4", env: DJANGO="Django<1.6"}
- {python: "3.4", env: DJANGO="Django<2.0"}
- {python: "3.4", env: DJANGO="Django<3.0"}

# Python 2.7 is supported up until django 2.0
- {python: "2.7", env: DJANGO="Django<2.0"}
- {python: "2.7", env: DJANGO="Django<3.0"}

# Python 2.6 is supported up until django 1.7
- {python: "2.6", env: DJANGO="Django<1.8"}
- {python: "2.6", env: DJANGO="Django<1.9"}
- {python: "2.6", env: DJANGO="Django<1.10"}
- {python: "2.6", env: DJANGO="Django<1.11"}
- {python: "2.6", env: DJANGO="Django<2.0"}
- {python: "2.6", env: DJANGO="Django<3.0"}

script: coverage run --source bootstrap_pagination ./run_tests.py
after_success:
- coverage report --fail-under=80
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include LICENSE README.markdown README.rst
recursive-include bootstrap_pagination *.py *.html
include LICENSE README.md
recursive-include bootstrap_pagination *.py *.html *.mo *.po
136 changes: 91 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
# Project No Longer Maintained

This project lived a long and useful life, but it's been inactive for quite some time and I believe its relevancy has faded.

It will remain here on Github in a read-only, archived state but there will be no more updates.





[![PyPi version](https://img.shields.io/pypi/v/django-bootstrap-pagination.svg)](https://pypi.python.org/pypi/django-bootstrap-pagination)
[![PyPi downloads](https://img.shields.io/pypi/dm/django-bootstrap-pagination.svg)](https://pypi.python.org/pypi/django-bootstrap-pagination)
[![Build Status](https://travis-ci.org/jmcclell/django-bootstrap-pagination.png?branch=master)](https://travis-ci.org/jmcclell/django-bootstrap-pagination)


## Django Bootstrap Pagination

**Note:** This version is compatible with Bootstrap 3.x only! Please use the 1.0.x branch for Bootstrap 2 support.
*Bootstrap Compatibility*

| Versions | Bootstrap Versions | Notes |
| -----------------| ------------------- | -------------------------------------------------------|
| < 1.1.0 | 2.x | |
| > 1.1.0, < 1.7.0 | 3.x | |
| >= 1.7.0 | 3.x, 4.x | bootstrap_pager is only compatible with Bootstrap 3.x |


This application serves to make using Twitter's Bootstrap Pagination styles
work seamlessly with Django Page objects. By passing in a Page object and
one or more optional arguments, Bootstrap pagination bars and pagers can
be rendered with very little effort.

Compatible with Django 1.3+
Compatible with Django **1.2+**

## Installation

@@ -29,10 +51,10 @@ Download the latest development version from:

github @ http://www.github.com/jmcclell/django-bootstrap-pagination


```
setup.py install
```

## Usage

### Setup
@@ -55,9 +77,23 @@ the pagination tags:
Finally, make sure that you have the request context processor enabled:

```
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.request",
)
# Django 1.8+
TEMPLATES = [
{
# ...
'OPTIONS': {
context_processors': [
# ...
'django.template.context_processors.request',
]
}
}
]
# Django < 1.8
TEMPLATE_CONTEXT_PROCESSORS = {
"django.core.context_processors.request",
)
```

# bootstrap_paginate
@@ -66,34 +102,40 @@ TEMPLATE_CONTEXT_PROCESSORS = (

- **range** - Defines the maximum number of page links to show
- **show_prev_next** - Boolean. Defines whether or not to show the Previous and Next
links. (Accepts "true" or "false")
links. (Accepts `"true"` or `"false"`)
- **previous_label** - The label to use for the Previous link
- **next_label** - The label to use for the Next link
- **show_first_last** - Boolean. Defines whether or not to show the First and Last links.
(Accepts "true" or "false")
(Accepts `"true"` or `"false"`)
- **first_label** - The label to use for the First page link
- **last_label** - The label to use for the Last page link
- **alignment** - How to align the pagination bar. Defaults to "center".
(Accepts "left", "center", and "right")
- **url_view_name** - A named URL reference (such as one that might get passed inti the URL
- **show_index_range** - Boolean, defaults to "false". If "true" shows index range of items instead of page numbers in the paginator. For example, if paginator is configured for 50 items per page, show_index_range="true" will display [1-50, 51-100, **101-150**, 151-200, 201-250, etc.] rather than [1, 2, **3**, 4, 5, etc.].
- **url_view_name** - A named URL reference (such as one that might get passed into the URL
template tag) to use as the URL template. Must be resolvable by the
reverse() function. **If this option is not specified, the tag simply
uses a relative url such as "?page=1" which is fine in most situations**
- **url_param_name** - Determines the name of the GET parameter for the page number. Th
default is "page". If no **url_view_name** is defined, this string
is appended to the url as "?{{url_param_name}}=1".
`reverse()` function. **If this option is not specified, the tag simply
uses a relative url such as `?page=1` which is fine in most situations**
- **url_param_name** - Determines the name of the `GET` parameter for the page number. The
default is `"page"`. If no **url_view_name** is defined, this string
is appended to the url as `?{{url_param_name}}=1`.
- **url_extra_args** - **Only valid when url_view_name is set.** Additional arguments to
pass into reverse() to resolve the URL.
- **url_extra_kwargs** - **Only valid when url_view_name is set.** Additional named
arguments to pass into reverse() to resolve the URL. Additionally,
pass into `reverse()` to resolve the URL.
- **url_extra_kwargs** - **Only valid when `url_view_name` is set.** Additional named
arguments to pass into `reverse()` to resolve the URL. Additionally,
the template tag will add an extra parameter to this for the
page, as it is assumed that if given a url_name, the page will
be a named variable in the URL regular expression. In this case,
the **url_param_name** continues to be the string used to represent
the name. That is, by default, **url_param_name** is equal to "page"
and thus it is expected that there is a named "page" argument in the
URL referenced by **url_view_name**. This allows us to use pretty
pagination URLs such as "/page/1"
the `url_param_name` continues to be the string used to represent
the name. That is, by default, `url_param_name` is equal to `page`
and thus it is expected that there is a named `page` argument in the
URL referenced by `url_view_name`. This allows us to use pretty
pagination URLs such as `/page/1`
- **extra_pagination_classes** - A space separated list of CSS class names that
will be added to the top level `<ul>` HTML element.
In particular, this can be utilized in Bootstrap 4
installations to add the appropriate alignment
classes from Flexbox utilities: eg:
`justify-content-center`


**Basic Usage**

@@ -122,12 +164,12 @@ Given a url configured such as:
```python
archive_index_view = ArchiveIndexView.as_view(
date_field='date',
paginate_by=10,
paginate_by=10,
allow_empty=True,
queryset=MyModel.all(),
template_name='example/archive.html'
template_name='example/archive.html'
)

urlpatterns = patterns(
'example.views',
url(r'^$', archive_index_view, name='archive_index'),
@@ -140,7 +182,6 @@ as the *archive_index_view* class based generic view from django doesn't care ho
the page parameter. However, if we want pretty URLs, such as those defined in the
*archive_index_paginated* URL (ie: /page/1), we need to define the URL in our template tag:


```
{% bootstrap_paginate page_obj url_view_name="archive_index_paginated" %}
```
@@ -151,7 +192,7 @@ would pass them in using the optional arguments **url_extra_args** and **url_ext
Likewise, if our page parameter had a different name, we would pass in a different
**url_param_name** argument to the template tag.

#bootstrap_pager
# bootstrap_pager

A much simpler implementation of the Bootstrap Pagination functionality is the Pager, which
simply provides a Previous and Next link.
@@ -164,26 +205,31 @@ simply provides a Previous and Next link.
- **next_title** - Defines the link title for the next link
- **centered** - Boolean. Defines whether or not the links are centered. Defaults to false.
(Accepts "true" or "false")
- **url_view_name** - A named URL reference (such as one that might get passed inti the URL
- **url_view_name** - A named URL reference (such as one that might get passed into the URL
template tag) to use as the URL template. Must be resolvable by the
reverse() function. **If this option is not specified, the tag simply
uses a relative url such as "?page=1" which is fine in most situations**
- **url_param_name** - Determines the name of the GET parameter for the page number. Th
default is "page". If no **url_view_name** is defined, this string
is appended to the url as "?{{url_param_name}}=1".
- **url_extra_args** - **Only valid when url_view_name is set.** Additional arguments to
pass into reverse() to resolve the URL.
- **url_extra_kwargs** - **Only valid when url_view_name is set.** Additional named
arguments to pass into reverse() to resolve the URL. Additionally,
`reverse()` function. **If this option is not specified, the tag simply
uses a relative url such as `?page=1` which is fine in most situations**
- **url_param_name** - Determines the name of the `GET` parameter for the page number. Th
default is `"page"`. If no `url_view_name` is defined, this string
is appended to the url as `?{{url_param_name}}=1`.
- **url_extra_args** - **Only valid when `url_view_name` is set.** Additional arguments to
pass into `reverse()` to resolve the URL.
- **url_extra_kwargs** - **Only valid when `url_view_name` is set.** Additional named
arguments to pass into `reverse()` to resolve the URL. Additionally,
the template tag will add an extra parameter to this for the
page, as it is assumed that if given a url_name, the page will
be a named variable in the URL regular expression. In this case,
the **url_param_name** continues to be the string used to represent
the name. That is, by default, **url_param_name** is equal to "page"
and thus it is expected that there is a named "page" argument in the
URL referenced by **url_view_name**. This allows us to use pretty
pagination URLs such as "/page/1"

the `url_param_name` continues to be the string used to represent
the name. That is, by default, `url_param_name` is equal to `"page"`
and thus it is expected that there is a named `page` argument in the
URL referenced by `url_view_name`. This allows us to use pretty
pagination URLs such as `/page/1`
- **url_anchor** - The anchor to use in URLs. Defaults to `None`
- **extra_pager_classes** - A space separated list of CSS class names that will be added
to the top level `<ul>` HTML element. This could be used to, as an
example, add a class to prevent the pager from showing up when
printing.

**Usage**

Usage is basically the same as for bootstrap_paginate. The simplest usage is:
218 changes: 0 additions & 218 deletions README.rst

This file was deleted.

Binary file added bootstrap_pagination/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
54 changes: 54 additions & 0 deletions bootstrap_pagination/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-22 04:23-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Anton Samarchyan <desecho@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"

#: templates/bootstrap_pagination/pagination.html:12
msgid "First Page"
msgstr "Первая страница"

#: templates/bootstrap_pagination/pagination.html:19
#: templates/bootstrap_pagination/pagination.html:23
#: templatetags/bootstrap_pagination.py:102
#: templatetags/bootstrap_pagination.py:104
msgid "Previous Page"
msgstr "Предыдущая страница"

#: templates/bootstrap_pagination/pagination.html:30
msgid "Current Page"
msgstr "Текущая страница"

#: templates/bootstrap_pagination/pagination.html:34
msgid "Page"
msgstr "Страница"

#: templates/bootstrap_pagination/pagination.html:41
#: templates/bootstrap_pagination/pagination.html:45
#: templatetags/bootstrap_pagination.py:103
#: templatetags/bootstrap_pagination.py:105
msgid "Next Page"
msgstr "Следующая страница"

#: templates/bootstrap_pagination/pagination.html:52
#: templates/bootstrap_pagination/pagination.html:56
msgid "Last Page"
msgstr "Последняя страница"

msgid "of"
msgstr "из"
21 changes: 15 additions & 6 deletions bootstrap_pagination/templates/bootstrap_pagination/pager.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<ul class="pager">
{% if page.has_previous %}
<ul class="pager {{ extra_pager_classes }}">
{% if page.has_previous %}
<li{% if not centered %} class="previous"{% endif %}>
<a title="{{ previous_title }}" href="{{ previous_page_url|default:"#" }}">{{ previous_label }}</a>
</li>
<a title="{{ previous_title }}" href="{{ previous_page_url|default:"#"|escape }}">{{ previous_label }}</a>
</li>
{% else %}
<li class="{% if not centered %}previous{% endif %} disabled">
<span title="{{ previous_title }}">{{ previous_label }}</span>
</li>
{% endif %}

{% if page.has_next %}
<li{% if not centered %} class="next"{% endif %}>
<a title="{{ next_title }}" href="{{ next_page_url|default:"#" }}">{{ next_label }}</a>
<a title="{{ next_title }}" href="{{ next_page_url|default:"#"|escape }}">{{ next_label }}</a>
</li>
{% else %}
<li title="{{ next_title }}" class="{% if not centered %} next{% endif %} disabled">
<span>{{ next_label }}</span>
</li>
{% endif %}
</ul>
</ul>
63 changes: 44 additions & 19 deletions bootstrap_pagination/templates/bootstrap_pagination/pagination.html
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,34 +1,59 @@
{% load i18n %}
{% load bootstrap_pagination %}
<ul class="pagination{% if size == "small" %} pagination-sm{% endif %}{% if size == "large" %} pagination-lg{% endif %}{% block extra_classes %}{% endblock %}">
<ul class="pagination{% if size == "small" %} pagination-sm{% endif %}{% if size == "large" %} pagination-lg{% endif %} {{ extra_pagination_classes }}">
{% if show_first_last %}
<li {% if not page.has_previous %}class="disabled"{% endif %}>
<a title="First Page" href="{{ first_page_url|default:"#" }}">{{first_label}}</a>
</li>
{% if not page.has_previous %}
<li class="page-item disabled">
<span class="page-link" aria-hidden="true" title="{% trans 'First Page' %}">{{ first_label }}</span>
</li>
{% else %}
<li class="page-item">
<a class="page-link" aria-label="{% trans 'First Page' %}" title="{% trans 'First Page' %}" href="{{ first_page_url|default:"#"|escape }}"><span aria-hidden="true">{{first_label}}</span></a>
</li>
{% endif %}
{% endif %}
{% if show_prev_next %}
<li {% if not page.has_previous %}class="disabled"{% endif %}>
<a title="Previous Page" href="{{ previous_page_url|default:"#" }}">{{ previous_label }}</a>
</li>
{% if not page.has_previous %}
<li class="page-item disabled">
<span class="page-link" aria-hidden="true" title="{% trans 'Previous Page' %}">{{ previous_label }}</span>
</li>
{% else %}
<li class="page-item">
<a class="page-link" aria-label="{% trans 'Previous Page' %}" title="{% trans 'Previous Page' %}" href="{{ previous_page_url|default:"#"|escape }}"><span aria-hidden="true">{{ previous_label }}</span></a>
</li>
{% endif %}
{% endif %}
{% for pagenum, url in page_urls %}
{% for pagenum, index_range, url in page_urls %}
{% if page.number == pagenum %}
<li class="active">
<a title="Current Page" href="#">{{ pagenum }}</a>
<li class="page-item active">
<span class="page-link" aria-label="{% trans 'Current Page' %}" title="{% trans 'Current Page' %}">{% if show_index_range %} {{ index_range }} {% else %} {{ pagenum }} {% endif %}</span>
</li>
{% else %}
<li>
<a title="Page {{ pagenum }} of {{ page.paginator.num_pages }}" href="{{ url }}">{{ pagenum }}</a>
<li class="page-item">
<a class="page-link" aria-label="{% trans 'Page' %} {{ pagenum }} {% trans 'of' %} {{ page.paginator.num_pages }}" title="{% trans 'Page' %} {{ pagenum }} {% trans 'of' %} {{ page.paginator.num_pages }}" href="{{ url|escape }}">{% if show_index_range %} {{ index_range }} {% else %} {{ pagenum }} {% endif %}</a>
</li>
{% endif %}
{% endfor %}
{% if show_prev_next %}
<li {% if not page.has_next %}class="disabled"{% endif %}>
<a title="Next Page" href="{{ next_page_url|default:"#" }}">{{ next_label }}</a>
</li>
{% if not page.has_next %}
<li class="page-item disabled">
<span class="page-link" aria-hidden="true" title="{% trans 'Next Page' %}">{{ next_label }}</span>
</li>
{% else %}
<li class="page-item">
<a class="page-link" aria-label="{% trans 'Next Page' %}" title="{% trans 'Next Page' %}" href="{{ next_page_url|default:"#"|escape }}"><span aria-hidden="true">{{ next_label }}</span></a>
</li>
{% endif %}
{% endif %}
{% if show_first_last %}
<li {% if not page.has_next %}class="disabled"{% endif %}>
<a title="Last Page" href="{{ last_page_url|default:"#" }}">{{last_label}}</a>
</li>
{% if not page.has_next %}
<li class="page-item disabled">
<span class="page-link" aria-hidden="true" title="{% trans 'Last Page' %}" >{{ last_label }}</span>
</li>
{% else %}
<li class="page-item">
<a class="page-link" aria-label="{% trans 'Last Page' %}" title="{% trans 'Last Page' %}" href="{{ last_page_url|default:"#"|escape }}"><span aria-hidden="true">{{last_label}}</span></a>
</li>
{% endif %}
{% endif %}
</ul>
</ul>
180 changes: 132 additions & 48 deletions bootstrap_pagination/templatetags/bootstrap_pagination.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
django>=1.2
29 changes: 29 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python
import os
try:
import unittest2 as unittest
except ImportError:
import unittest #python3


import django


def runtests():
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'

try:
django.setup()
except AttributeError: # Happens before django 1.7
pass

loader = unittest.TestLoader()
tests = loader.discover('tests')
testRunner = unittest.runner.TextTestRunner()
result = testRunner.run(tests)
if result.errors or result.failures:
exit(1)


if __name__ == "__main__":
runtests()
46 changes: 35 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
# -*- coding: utf-8 -*-
import os

from distutils.core import setup
from setuptools import find_packages

readme = open('README.rst', 'r')
readme_text = readme.read()
readme.close()

with open(os.path.join(os.path.dirname(__file__), 'README.md'), 'rb') as readme:
readme_text = readme.read().decode('utf-8')

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

setup(
name='django-bootstrap-pagination',
version='1.5.0',
version='1.7.1',
keywords="django bootstrap pagination templatetag",
author=u'Jason McClellan',
author_email='jason@jasonmccllelan.net',
author=u'Jason McClellan<jason@jasonmcclellan.io>, Koert van der Veer<koert@ondergetekende.nl>',
author_email='jason@jasonmccllelan.io',
packages=find_packages(),
url='https://github.com/jmcclell/django-bootstrap-pagination',
license='MIT licence, see LICENCE',
description='Render Django Page objects as Bootstrap 3.x Pagination compatible HTML',
long_description=readme_text.encode('UTF-8'),
description='Render Django Page objects as Bootstrap 3.x/4.x Pagination compatible HTML',
long_description=readme_text,
long_description_content_type='text/markdown',
zip_safe=False,
include_package_data=True,
classifiers=[
"Development Status :: 3 - Alpha",
"Framework :: Django",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: MIT License",
"Framework :: Django",
"Framework :: Django :: 1.4",
"Framework :: Django :: 1.5",
"Framework :: Django :: 1.6",
"Framework :: Django :: 1.7",
"Framework :: Django :: 1.8",
"Framework :: Django :: 1.9",
"Framework :: Django :: 1.10",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
"Framework :: Django :: 2.1",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
]
)
5 changes: 5 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mock
lxml
cssselect
coverage
unittest2
Empty file added tests/__init__.py
Empty file.
93 changes: 93 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import django.conf
try:
from django.core.urlresolvers import NoReverseMatch
except ImportError: # Django 2+
from django.urls import NoReverseMatch
import django.http

import mock
try:
import unittest2 as unittest
except ImportError:
import unittest

from bootstrap_pagination.templatetags import bootstrap_pagination


class TestHelpers(unittest.TestCase):
def test_strToBool(self):
self.assertTrue(bootstrap_pagination.strToBool('true'))
self.assertFalse(bootstrap_pagination.strToBool('false'))

@mock.patch('bootstrap_pagination.templatetags.bootstrap_pagination.'
'reverse')
def test_get_page_url_view(self, mock_reverse):
mock_reverse.return_value = "/some_nice_url"
url = bootstrap_pagination.get_page_url(
page_num=42,
current_app='the_current_app',
url_view_name='the_view',
url_extra_args=["arg1"],
url_extra_kwargs={"kwarg": "yes"},
url_param_name='page',
url_get_params=[],
url_anchor="derp")

self.assertEqual(url, '/some_nice_url#derp')
mock_reverse.assert_called_once_with('the_view',
args=['arg1'],
current_app='the_current_app',
kwargs={'kwarg': 'yes',
'page': 42})

@mock.patch('bootstrap_pagination.templatetags.bootstrap_pagination.'
'reverse')
def test_get_page_url_view_sub(self, mock_reverse):
mock_reverse.side_effect = [
NoReverseMatch(),
"/some_nice_url"
]
url = bootstrap_pagination.get_page_url(
page_num=42,
current_app='the_current_app',
url_view_name='the_view',
url_extra_args=["arg1"],
url_extra_kwargs={"kwarg": "yes"},
url_param_name='page',
url_get_params=django.http.QueryDict(""),
url_anchor="derp")

self.assertEqual(url, '/some_nice_url#derp')
if django.VERSION < (1, 9, 0):
sep = '.'
else:
sep = ':'

mock_reverse.assert_called_with('tests' + sep + 'the_view',
args=['arg1'],
current_app='the_current_app',
kwargs={'kwarg': 'yes',
'page': 42})

@mock.patch('bootstrap_pagination.templatetags.bootstrap_pagination.'
'reverse')
def test_get_page_url_straight(self, mock_reverse):
mock_reverse.return_value = "/some_nice_url"
url = bootstrap_pagination.get_page_url(
page_num=42,
current_app='the_current_app',
url_view_name=None,
url_extra_args=["arg1"],
url_extra_kwargs={"kwarg": "yes"},
url_param_name='page',
url_get_params=django.http.QueryDict("arg2=val"),
url_anchor="derp")

self.assertIn("arg2=val", url)
self.assertIn("page=42", url)
self.assertTrue(url.endswith("#derp"))


if __name__ == '__main__':
django.conf.settings.configure()
unittest.main()
34 changes: 34 additions & 0 deletions tests/test_pager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
try:
import unittest2 as unittest
except ImportError:
import unittest

import lxml.html

try:
from django.template.loader import get_template_from_string
except ImportError:
from django.template import Engine
get_template_from_string = Engine.get_default().from_string

from django.template import Context
import django.http
from django.core.paginator import Paginator


class PagerTestCase(unittest.TestCase):
def test_example(self):
template = get_template_from_string("""
{% load bootstrap_pagination %}
{% bootstrap_pager page_obj %}
""")

objects = ["obj%02x" % idx
for idx in range(30)]

paginator = Paginator(objects, 10)

c = Context({'page_obj': paginator.page(2),
'request': django.http.HttpRequest()})
html = lxml.html.fragment_fromstring(template.render(c))
self.assertEqual(html.get('class').strip(), 'pager')
37 changes: 37 additions & 0 deletions tests/test_paginate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
try:
import unittest2 as unittest
except ImportError:
import unittest

import lxml.html

try:
from django.template.loader import get_template_from_string
except ImportError:
from django.template import Engine
get_template_from_string = Engine.get_default().from_string

from django.template import Context
import django.http
from django.core.paginator import Paginator


class PaginateTestCase(unittest.TestCase):
def test_example(self):
template = get_template_from_string("""
{% load bootstrap_pagination %}
{% bootstrap_paginate page_obj range=10 %}
""")

objects = ["obj%02x" % idx
for idx in range(30)]

paginator = Paginator(objects, 10)

c = Context({'page_obj': paginator.page(2),
'request': django.http.HttpRequest()})
html = lxml.html.fragment_fromstring(template.render(c))
self.assertEqual(html.get('class').strip(), 'pagination')
self.assertEqual(
html.cssselect('[title=\"Current Page\"]')[0].text.strip(),
'2')
35 changes: 35 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os


BASE_DIR = os.path.dirname(__file__)
SETTINGS_MODULE = "tests.test_settings"

INSTALLED_APPS = (
'bootstrap_pagination',
)

DATABASES = {}
MIDDLEWARE_CLASSES = ()

ROOT_URLCONF = 'tests.test_settings.urls'
SECRET_KEY = 'secretkey'
SITE_ROOT = '.'


TEMPLATE_DEBUG = True
TEMPLATE_DIRS = ()

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': TEMPLATE_DIRS,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
],
'debug': TEMPLATE_DEBUG,
},
},
]

urls = []