{"id":15628176,"url":"https://github.com/maprihoda/simple_pagination","last_synced_at":"2025-03-29T17:44:05.429Z","repository":{"id":1682835,"uuid":"2410230","full_name":"maprihoda/simple_pagination","owner":"maprihoda","description":"Simple pagination for Google App Engine (GAE) Python","archived":false,"fork":false,"pushed_at":"2012-03-16T11:43:20.000Z","size":96,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T18:49:37.035Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maprihoda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-09-18T16:32:17.000Z","updated_at":"2014-05-04T11:12:05.000Z","dependencies_parsed_at":"2022-09-12T00:00:52.816Z","dependency_job_id":null,"html_url":"https://github.com/maprihoda/simple_pagination","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maprihoda%2Fsimple_pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maprihoda%2Fsimple_pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maprihoda%2Fsimple_pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maprihoda%2Fsimple_pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maprihoda","download_url":"https://codeload.github.com/maprihoda/simple_pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246223270,"owners_count":20743158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T10:21:18.518Z","updated_at":"2025-03-29T17:44:05.407Z","avatar_url":"https://github.com/maprihoda.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Pagination\n\nA utility class, a pager method and a jinja2 macro for paging query results and generating page links. Can be used with Google App Engine (GAE).\n\nThe utility class is the PageLinks class found in the page_links.py file. The class's initialization method accepts the following parameters:\n\n    page:           The current page\n    total_items:    The total number of items\n    per_page:       The number of items per page\n    url_root:       The start of the URL assigned to each page.\n    page_field:     The name of the URL parameter to use for pages\n    page_range:     The number of pages to show (should be odd)\n\n\n## Example Usage (GAE specific)\n\nSimply copy the page_links.py file into your GAE project root.\nIn your project's base handler (base controller) class, create a pager method:\n\n    form page_links import PageLinks\n\n    class BaseHandler(webapp.RequestHandler):\n\n        # ...other code...\n\n        def pager(self, query, page, total_items, per_page, url_root, page_field='pg', page_range= 9):\n            try:\n                page = int(page)\n            except ValueError:\n                page = 1\n\n            entities = query.fetch(per_page, (page - 1) * per_page)\n\n            pagination_links = PageLinks(\n                page,\n                total_items,\n                per_page,\n                url_root,\n                page_field,\n                page_range\n            )\n\n            pagination_links = pagination_links.get_links()\n            return entities, pagination_links\n\n\nThen, in your handlers, you can use the pager method as follows:\n\n    class Recruiters(BaseHandler):\n        per_page = 20\n\n        def get(self):\n            # ...other code...\n\n            page = self.request.get('pg')\n            query = company.recruiters\n\n            recruiters, pagination_links = self.pager(\n                query,\n                page,\n                query.count(),\n                self.per_page,\n                '/a/recruiters',\n            )\n\n\nYou can also use the following Jinja2 macro in your templates:\n\n    {% macro pagelinks(pagination_links) %}\n    \u003cdiv id=\"pagelinks\"\u003e\n    {% for link in pagination_links %}\n       {{ link }}\n    {% endfor %}\n    \u003c/div\u003e\n    {% endmacro %}\n\n\nYou can see Simple Pagination in action on [Aktuální nabídky práce](http://www.aktualninabidkyprace.cz/). It's a simple job board built on [Google App Engine](http://code.google.com/appengine/).\n\n\n## Credits\n\nThe PageLinks class is an adapted version of a utility class from the he3-appengine-lib project (http://code.google.com/p/he3-appengine-lib/wiki/PageLinks)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaprihoda%2Fsimple_pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaprihoda%2Fsimple_pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaprihoda%2Fsimple_pagination/lists"}