{"id":15646523,"url":"https://github.com/unknwon/paginater","last_synced_at":"2025-04-09T11:10:36.329Z","repository":{"id":35460666,"uuid":"39728371","full_name":"unknwon/paginater","owner":"unknwon","description":"Package paginater is a helper module for custom pagination calculation.","archived":false,"fork":false,"pushed_at":"2020-03-31T09:32:01.000Z","size":16,"stargazers_count":48,"open_issues_count":0,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T03:56:54.038Z","etag":null,"topics":["go","lsif-enabled","pagination"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unknwon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-26T14:30:22.000Z","updated_at":"2024-03-11T03:14:10.000Z","dependencies_parsed_at":"2022-09-17T04:52:05.283Z","dependency_job_id":null,"html_url":"https://github.com/unknwon/paginater","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/unknwon%2Fpaginater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unknwon%2Fpaginater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unknwon%2Fpaginater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unknwon%2Fpaginater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unknwon","download_url":"https://codeload.github.com/unknwon/paginater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027407,"owners_count":21035594,"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":["go","lsif-enabled","pagination"],"created_at":"2024-10-03T12:13:10.909Z","updated_at":"2025-04-09T11:10:36.312Z","avatar_url":"https://github.com/unknwon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Paginater\n\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/unknwon/paginater/Go?logo=github\u0026style=for-the-badge)](https://github.com/unknwon/paginater/actions?query=workflow%3AGo)\n[![codecov](https://img.shields.io/codecov/c/github/unknwon/paginater/master?logo=codecov\u0026style=for-the-badge)](https://codecov.io/gh/unknwon/paginater)\n[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge\u0026logo=go)](https://pkg.go.dev/github.com/unknwon/paginater?tab=doc)\n[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge\u0026logo=sourcegraph)](https://sourcegraph.com/github.com/unknwon/paginater)\n\nPackage paginater is a helper module for custom pagination calculation.\n\n## Installation\n\n\tgo get github.com/Unknwon/paginater\n\n## Getting Started\n\nThe following code shows an example of how to use paginater:\n\n```go\npackage main\n\nimport \"github.com/Unknwon/paginater\"\n\nfunc main() {\n\t// Arguments:\n\t// - Total number of rows\n\t// - Number of rows in one page\n\t// - Current page number \n\t// - Number of page links to be displayed\n\tp := paginater.New(45, 10, 3, 3)\n\t\n\t// Then use p as a template object named \"Page\" in \"demo.html\"\n\t// ...\n}\n```\n\n`demo.html`\n\n```html\n{{if not .Page.IsFirst}}[First](1){{end}}\n{{if .Page.HasPrevious}}[Previous]({{.Page.Previous}}){{end}}\n\n{{range .Page.Pages}}\n\t{{if eq .Num -1}}\n\t...\n\t{{else}}\n\t{{.Num}}{{if .IsCurrent}}(current){{end}}\n\t{{end}}\n{{end}}\n\n{{if .Page.HasNext}}[Next]({{.Page.Next}}){{end}}\n{{if not .Page.IsLast}}[Last]({{.Page.TotalPages}}){{end}}\n```\n\nPossible output:\n\n```\n[First](1) [Previous](2) ... 2 3(current) 4 ... [Next](4) [Last](5)\n```\n\nAs you may guess, if the `Page` value is `-1`, you should print `...` in the HTML as common practice.\n\n## Getting Help\n\n- [API Documentation](https://gowalker.org/github.com/Unknwon/paginater)\n- [File An Issue](https://github.com/Unknwon/paginater/issues/new)\n\n## License\n\nThis project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funknwon%2Fpaginater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funknwon%2Fpaginater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funknwon%2Fpaginater/lists"}