Skip to content

Commit

Permalink
add skip attribute, read version from source file
Browse files Browse the repository at this point in the history
  • Loading branch information
lixxu committed Feb 3, 2019
1 parent 1a8c2e8 commit ffb11e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
8 changes: 7 additions & 1 deletion docs/index.rst
Expand Up @@ -5,7 +5,7 @@ flask-paginate |release| documentation

Overview
---------
Latest version: **0.5.1**
Latest version: **0.5.2**

**flask-paginate** is a simple paginate extension for
`flask`_ which is reference to `will_paginate`_,
Expand Down Expand Up @@ -247,6 +247,12 @@ Contributors

Changelog
---------
Version 0.5.2
-------------

- add `skip` attribute to fix error in docs
- read version from source file instead of hard code in setup file

Version 0.5.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion example/templates/index.html
Expand Up @@ -12,7 +12,7 @@
<tbody>
{% for user in users %}
<tr>
<td>{{ loop.index + (page - 1) * per_page }}</td>
<td>{{ loop.index + pagination.skip }}</td>
<td>{{ user.name }}</td>
</tr>
{% endfor %}
Expand Down
7 changes: 4 additions & 3 deletions flask_paginate/__init__.py
Expand Up @@ -15,7 +15,7 @@
import sys
from flask import request, url_for, Markup, current_app

__version__ = '0.5.1'
__version__ = '0.5.2'

PY2 = sys.version_info[0] == 2

Expand Down Expand Up @@ -174,8 +174,8 @@ def __init__(self, found=0, **kwargs):
**per_page**: how many records displayed on one page
**page_parameter**: a name(string) of a GET parameter that holds \
a page index, Use it if you want to iterate over multiple Pagination \
objects simultaniously.
a page index, Use it if you want to iterate over multiple \
Pagination objects simultaniously.
default is 'page'.
**per_page_parameter**: a name for per_page likes page_parameter.
Expand Down Expand Up @@ -235,6 +235,7 @@ def __init__(self, found=0, **kwargs):

self.per_page_parameter = per_page_param
self.per_page = kwargs.get(per_page_param, 10)
self.skip = (self.page - 1) * self.per_page
self.inner_window = kwargs.get('inner_window', 2)
self.outer_window = kwargs.get('outer_window', 1)
self.prev_label = kwargs.get('prev_label') or PREV_LABEL
Expand Down
13 changes: 12 additions & 1 deletion setup.py
Expand Up @@ -5,11 +5,22 @@
Simple paginate for flask (study from will_paginate).
Use bootstrap css framework, supports bootstrap2&3 and foundation
"""
import io
import os.path
from setuptools import setup

work_dir = os.path.dirname(os.path.abspath(__file__))
fp = os.path.join(work_dir, "flask_paginate/__init__.py")

with io.open(fp, encoding="utf-8") as f:
for line in f:
if line.startswith("__version__ = "):
version = line.split("=")[-1].strip().replace("'", "")
break

setup(
name='flask-paginate',
version='0.5.1',
version=version.replace('"', ""),
url='https://github.com/lixxu/flask-paginate',
license='BSD',
author='Lix Xu',
Expand Down

0 comments on commit ffb11e9

Please sign in to comment.