This commit is contained in:
Tobe O 2017-05-26 16:01:33 -04:00
parent 3f84e6d814
commit 83cdcf5083
6 changed files with 47 additions and 5 deletions

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/paginate.iml" filepath="$PROJECT_DIR$/.idea/paginate.iml" />
</modules>
</component>
</project>

18
.idea/paginate.iml Normal file
View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -1,7 +1,7 @@
# paginate
[![version 1.0.0](https://img.shields.io/badge/pub-v1.0.0-brightgreen.svg)](https://pub.dartlang.org/packages/angel_paginate)
[![version 1.0.0+1](https://img.shields.io/badge/pub-v1.0.0+1-brightgreen.svg)](https://pub.dartlang.org/packages/angel_paginate)
[![build status](https://travis-ci.org/angel-dart/paginate.svg)](https://travis-ci.org/angel-dart/paginate)
![coverage: 97%](https://img.shields.io/badge/coverage-97%25-green.svg)
![coverage: 100%](https://img.shields.io/badge/coverage-100%25-green.svg)
Platform-agnostic pagination library, with custom support for the
[Angel framework](https://github.com/angel-dart/angel).
@ -76,4 +76,17 @@ configureServer(Angel app) {
}
```
See `test/server_test.dart` for examples of usage with Angel.
See `test/server_test.dart` for examples of usage with Angel.
The pagination hook also allows you to provide a `page` and/or `$limit` in the query.
If the user provides a `page` in the query, it will return a pagination of the given page.
Ex. `http://mysite.com/api/todos?page=4`
A `$limit` can be used to override the `itemsPerPage` set in the `paginate` hook. If you
would like to set a maximum on the number of items per page, you can set `maxItemsPerPage`
in the `paginate` call.
Ex. `http://mysite.com/api/todos?$limit=25`
You can use these pagination functions to provide powerful search experiences on your websites.

View file

@ -15,7 +15,7 @@ HookedServiceEventListener paginate<T>(
'`package:angel_paginate` can only be run as an after hook.');
if (e.result is! Iterable) return;
int page = 0,
int page = 1,
nItems = itemsPerPage;
if (e.params.containsKey('query') && e.params['query'] is Map) {

View file

@ -1,5 +1,5 @@
name: angel_paginate
version: 1.0.0
version: 1.0.0+1
description: Platform-agnostic pagination library, with custom support for the Angel framework.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/paginate

View file

@ -81,6 +81,9 @@ main() {
expect(r.startIndex, 10);
expect(r.endIndex, 14);
expect(r.data, DATA.skip(r.startIndex).take(r.itemsPerPage).toList());
paginator.back();
expect(paginator.pageNumber, 2);
});
test('last page', () {