From 83cdcf508371b4d5891d146352b03e454abee293 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 26 May 2017 16:01:33 -0400 Subject: [PATCH] Docs --- .idea/modules.xml | 8 ++++++++ .idea/paginate.iml | 18 ++++++++++++++++++ README.md | 19 ++++++++++++++++--- lib/server.dart | 2 +- pubspec.yaml | 2 +- test/paginate_test.dart | 3 +++ 6 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .idea/modules.xml create mode 100644 .idea/paginate.iml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..95e1559d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/paginate.iml b/.idea/paginate.iml new file mode 100644 index 00000000..02bd9dfb --- /dev/null +++ b/.idea/paginate.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 89422ded..fbe15f85 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/lib/server.dart b/lib/server.dart index 8ca94321..a4311b2f 100644 --- a/lib/server.dart +++ b/lib/server.dart @@ -15,7 +15,7 @@ HookedServiceEventListener paginate( '`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) { diff --git a/pubspec.yaml b/pubspec.yaml index 3338f1c6..9c9ab8f0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/angel-dart/paginate diff --git a/test/paginate_test.dart b/test/paginate_test.dart index fc85b3d2..764ddf9f 100644 --- a/test/paginate_test.dart +++ b/test/paginate_test.dart @@ -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', () {