File Coverage

blib/lib/Dancer2/Plugin/Paginator.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition 2 4 50.0
subroutine 5 5 100.0
pod n/a
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Dancer2::Plugin::Paginator;
2              
3             $Dancer2::Plugin::Paginator::VERSION = '2.11';
4             $Dancer2::Plugin::Paginator::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             Dancer2::Plugin::Paginator - Dancer2 plugin for Paginator::Lite.
9              
10             =head1 VERSION
11              
12             Version 2.11
13              
14             =cut
15              
16 2     2   722559 use strict; use warnings;
  2     2   10  
  2         48  
  2         8  
  2         3  
  2         45  
17              
18 2     2   959 use Dancer2::Plugin;
  2         196943  
  2         16  
19 2     2   38900 use Paginator::Lite;
  2         12994  
  2         285  
20              
21             register paginator => sub {
22 2     2   186683 my ($dsl, %params) = @_;
23              
24 2         11 my $conf = plugin_setting;
25 2   50     202 $conf->{frame_size} ||= 5;
26 2   50     11 $conf->{page_size} ||= 10;
27              
28 2         4 return Paginator::Lite->new(%{$conf}, %params);
  2         31  
29             };
30              
31             register_plugin;
32              
33             =head1 SYNOPSIS
34              
35             use Dancer2;
36             use Dancer2::Plugin::Paginator;
37              
38             get '/list' => sub {
39             my $paginator = paginator(
40             'curr' => $page,
41             'items' => rset('Post')->count,
42             'base_url' => '/posts/page/',
43             );
44              
45             template 'list', { paginator => $paginator };
46             };
47              
48             true;
49              
50             For complete working code, please take a look L<Dancer2 Cookbook|https://github.com/manwar/Dancer2-Cookbook>.
51              
52             =head1 CONFIGURATION
53              
54             Configuration can be done in your L<Dancer2> app config file as described below:
55              
56             plugins:
57             Paginator:
58             frame_size: 3
59             page_size: 7
60              
61             =head1 METHODS
62              
63             =head2 method paginator(%params)
64              
65             Returns a L<Paginator::Lite> object. Receives same parameters that as the L<Paginator::Lite>
66             constructor.
67              
68             =head1 AUTHOR
69              
70             Original author Blabos de Blebe, C<< <blabos@cpan.org> >>
71              
72             Recently brought to live from BackPAN by Mohammad S Anwar, C<< <mohammad.anwar@yahoo.com> >>
73              
74             =head1 REPOSITORY
75              
76             L<https://github.com/manwar/Dancer2-Plugin-Paginator>
77              
78             =head1 ACKNOWLEDGEMENTS
79              
80             Blabos de Blebe has kindly transferred the ownership of this distribution to me
81             and even handed over the GitHub repository as well.
82              
83             =head1 SEE ALSO
84              
85             L<Paginator::Lite>
86              
87             =head1 BUGS
88              
89             Please report any bugs or feature requests to C<bug-dancer2-plugin-captcha at rt.cpan.org>,
90             or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer2-Plugin-Captcha>.
91             I will be notified and then you'll automatically be notified of progress on your
92             bug as I make changes.
93              
94             =head1 SUPPORT
95              
96             You can find documentation for this module with the perldoc command.
97              
98             perldoc Dancer2::Plugin::Paginator
99              
100             You can also look for information at:
101              
102             =over 4
103              
104             =item * RT: CPAN's request tracker (report bugs here)
105              
106             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer2-Plugin-Paginator>
107              
108             =item * AnnoCPAN: Annotated CPAN documentation
109              
110             L<http://annocpan.org/dist/Dancer2-Plugin-Paginator>
111              
112             =item * CPAN Ratings
113              
114             L<http://cpanratings.perl.org/d/Dancer2-Plugin-Paginator>
115              
116             =item * Search CPAN
117              
118             L<http://search.cpan.org/dist/Dancer2-Plugin-Paginator/>
119              
120             =back
121              
122             =head1 LICENSE AND COPYRIGHT
123              
124             Copyright (C) 2013 Blabos de Blebe.
125             Copyright (C) 2017 - 2019 Mohammad S Anwar.
126              
127             This program is free software; you can redistribute it and / or modify it under
128             the terms same as Perl 5.
129              
130             =cut
131              
132             1; # End of Dancer2::Plugin::Paginator