29
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
1 |
# Based on Mojolicious-Plugin-TagHelpers-Pagination and slightly modified for bootstrap
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
2 |
# Under Artistic License 2.0
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
3 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
4 |
package Mojolicious::Plugin::TagHelpers::BootstrapPagination;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
5 |
use Mojo::Base 'Mojolicious::Plugin';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
6 |
use Mojo::ByteStream 'b';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
7 |
use Scalar::Util 'blessed';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
8 |
use POSIX 'ceil';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
9 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
10 |
our $VERSION = 0.01;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
11 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
12 |
our @value_list =
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
13 |
qw/prev
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
14 |
next
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
15 |
current_start
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
16 |
current_end
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
17 |
page_start
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
18 |
page_end
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
19 |
separator
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
20 |
ellipsis
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
21 |
placeholder/;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
22 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
23 |
# Register plugin
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
24 |
sub register {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
25 |
my ($plugin, $mojo, $param) = @_;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
26 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
27 |
$param ||= {};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
28 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
29 |
# Load parameter from Config file
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
30 |
if (my $config_param = $mojo->config('TagHelpers-Pagination')) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
31 |
$param = { %$config_param, %$param };
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
32 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
33 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
34 |
foreach (@value_list) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
35 |
$plugin->{$_} = $param->{$_} if defined $param->{$_};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
36 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
37 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
38 |
# Set 'current_start' and 'current_end' symbols,
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
39 |
# if 'current' template is available.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
40 |
# Same for 'page'.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
41 |
foreach (qw/page current/) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
42 |
if (defined $param->{$_}) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
43 |
@{$plugin}{$_ . '_start', $_ . '_end'} = split("{$_}", $param->{$_});
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
44 |
$plugin->{$_ . '_end'} ||= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
45 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
46 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
47 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
48 |
# Default current start and current end symbols
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
49 |
for ($plugin) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
50 |
$_->{current_start} //= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
51 |
$_->{current_end} //= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
52 |
$_->{page_start} //= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
53 |
$_->{page_end} //= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
54 |
$_->{prev} //= '<';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
55 |
$_->{next} //= '>';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
56 |
$_->{separator} //= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
57 |
$_->{ellipsis} //= '<li><span>...</span></li>';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
58 |
$_->{placeholder} //= 'page';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
59 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
60 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
61 |
# Establish pagination helper
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
62 |
$mojo->helper(
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
63 |
pagination => sub {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
64 |
shift; # Controller
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
65 |
return b( $plugin->pagination( @_ ) );
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
66 |
});
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
67 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
68 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
69 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
70 |
# Pagination helper
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
71 |
sub pagination {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
72 |
my $self = shift;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
73 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
74 |
# $_[0] = current page
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
75 |
# $_[1] = page count
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
76 |
# $_[2] = template or Mojo::URL
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
77 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
78 |
return '' unless $_[0] || $_[1];
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
79 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
80 |
# No valid count given
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
81 |
local $_[1] = !$_[1] ? 1 : ceil($_[1]);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
82 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
83 |
# New parameter hash
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
84 |
my %values =
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
85 |
map { $_ => $self->{$_} } @value_list;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
86 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
87 |
# Overwrite plugin defaults
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
88 |
if ($_[3] && ref $_[3] eq 'HASH') {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
89 |
my $overwrite = $_[3];
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
90 |
foreach (@value_list) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
91 |
$values{$_} = $overwrite->{$_} if defined $overwrite->{$_};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
92 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
93 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
94 |
foreach (qw/page current/) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
95 |
if (defined $overwrite->{$_}) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
96 |
@values{$_ . '_start', $_ . '_end'} = split("{$_}", $overwrite->{$_});
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
97 |
$values{$_ . '_end'} ||= '';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
98 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
99 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
100 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
101 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
102 |
# Establish string variables
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
103 |
my ($p, $n, $cs, $ce, $ps, $pe, $s, $el, $ph) = @values{@value_list};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
104 |
# prev next current_start current_end
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
105 |
# page_start page_end separator ellipsis placeholder
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
106 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
107 |
# Template
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
108 |
my $t = $_[2];
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
109 |
if (blessed $t && blessed $t eq 'Mojo::URL') {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
110 |
$t = $t->to_string;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
111 |
$t =~ s/\%7[bB]$ph\%7[dD]/{$ph}/g;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
112 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
113 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
114 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
115 |
my $sub = sublink_gen($t,$ps,$pe,$ph);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
116 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
117 |
# Pagination string
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
118 |
my $e;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
119 |
my $counter = 1;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
120 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
121 |
if ($_[1] >= 7){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
122 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
123 |
# < [1] #2 #3
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
124 |
if ($_[0] == 1){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
125 |
$e .= $sub->(undef, [$p, 'prev']) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
126 |
$sub->(undef, [$cs . 1 . $ce, 'self']) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
127 |
$sub->('2') . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
128 |
$sub->('3') . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
129 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
130 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
131 |
# < #1 #2 #3
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
132 |
elsif (!$_[0]) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
133 |
$e .= $sub->(undef, [$p, 'prev']) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
134 |
$e .= $sub->($_) . $s foreach (1 .. 3);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
135 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
136 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
137 |
# #< #1
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
138 |
else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
139 |
$e .= $sub->(($_[0] - 1), [$p, 'prev']) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
140 |
$sub->('1') . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
141 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
142 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
143 |
# [2] #3
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
144 |
if ($_[0] == 2){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
145 |
$e .= $sub->(undef, [$cs . 2 . $ce, 'self']) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
146 |
$sub->('3') . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
147 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
148 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
149 |
# ...
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
150 |
elsif ($_[0] > 3){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
151 |
$e .= $el . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
152 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
153 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
154 |
# #x-1 [x] #x+1
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
155 |
if (($_[0] >= 3) && ($_[0] <= ($_[1] - 2))){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
156 |
$e .= $sub->($_[0] - 1) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
157 |
$sub->(undef, [$cs .$_[0] . $ce, 'self']) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
158 |
$sub->($_[0] + 1) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
159 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
160 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
161 |
# ...
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
162 |
if ($_[0] < ($_[1] - 2)){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
163 |
$e .= $el . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
164 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
165 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
166 |
# number is prefinal
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
167 |
if ($_[0] == ($_[1] - 1)){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
168 |
$e .= $sub->($_[1] - 2) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
169 |
$sub->(undef, [$cs . $_[0] . $ce, 'self']) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
170 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
171 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
172 |
# Number is final
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
173 |
if ($_[0] == $_[1]){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
174 |
$e .= $sub->($_[1] - 1) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
175 |
$sub->(undef, [$cs . $_[1] . $ce, 'self']) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
176 |
$sub->(undef, [$n, 'next']);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
177 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
178 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
179 |
# Number is anywhere in between
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
180 |
else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
181 |
$e .= $sub->($_[1]) . $s .
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
182 |
$sub->(($_[0] + 1), [$n,'next']);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
183 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
184 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
185 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
186 |
# Counter < 7
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
187 |
else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
188 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
189 |
# Previous
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
190 |
if ($_[0] > 1){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
191 |
$e .= $sub->(($_[0] - 1), [$p, 'prev']) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
192 |
} else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
193 |
$e .= $sub->(undef, [$p, 'prev']) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
194 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
195 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
196 |
# All numbers in between
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
197 |
while ($counter <= $_[1]){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
198 |
if ($_[0] != $counter) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
199 |
$e .= $sub->($counter) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
200 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
201 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
202 |
# Current
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
203 |
else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
204 |
$e .= $sub->(undef, [$cs . $counter . $ce, 'self']) . $s;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
205 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
206 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
207 |
$counter++;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
208 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
209 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
210 |
# Next
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
211 |
if ($_[0] != $_[1]){
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
212 |
$e .= $sub->(($_[0] + 1), [$n, 'next']);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
213 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
214 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
215 |
else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
216 |
$e .= $sub->(undef, [$n, 'next']);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
217 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
218 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
219 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
220 |
# Pagination string
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
221 |
$e;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
222 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
223 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
224 |
# Sublink function generator
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
225 |
sub sublink_gen {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
226 |
my ($url, $ps, $pe, $ph) = @_;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
227 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
228 |
my $s = 'sub {';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
229 |
# $_[0] = number
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
230 |
# $_[1] = number_shown
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
231 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
232 |
# Url is template
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
233 |
if ($url) {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
234 |
$s .= 'my $url=' . b($url)->quote . ';';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
235 |
$s .= 'if($_[0]){$url=~s/\{' . $ph . '\}/$_[0]/g}else{$url=undef};';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
236 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
237 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
238 |
# No template given
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
239 |
else {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
240 |
$s .= 'my $url = $_[0];';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
241 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
242 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
243 |
$s .= 'my$n=$_[1]||' . b($ps)->quote . '.$_[0].' . b($pe)->quote . ';';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
244 |
$s .= q{my $liclass='';};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
245 |
$s .= q{if(ref $n && $n->[1] eq "self"){$liclass = "active"};};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
246 |
$s .= q{my $rel='';};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
247 |
$s .= q{if(ref $n){$rel=' rel="'.$n->[1].'"';$n=$n->[0]};};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
248 |
$s .= q!if($url){$url=~s/&/&/g;!;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
249 |
$s .= q{$url=~s/</</g;};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
250 |
$s .= q{$url=~s/>/>/g;};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
251 |
$s .= q{$url=~s/"/"/g;};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
252 |
$s .= q!$url=~s/'/'/g;};!;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
253 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
254 |
# Create sublink
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
255 |
$s .= q{return '<li'.($liclass?' class="'.$liclass.'"':'').'><a'.($url?' href="'.$url.'"':'').$rel.'>' . $n . '</a></li>';};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
256 |
$s .= '}';
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
257 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
258 |
my $x = eval($s);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
259 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
260 |
warn $@ if $@;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
261 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
262 |
$x;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
263 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
264 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
265 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
266 |
1;
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
267 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
268 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
269 |
__END__
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
270 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
271 |
=pod
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
272 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
273 |
=head1 NAME
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
274 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
275 |
Mojolicious::Plugin::TagHelpers::Pagination - Pagination Helper for Mojolicious
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
276 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
277 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
278 |
=head1 SYNOPSIS
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
279 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
280 |
# Mojolicious
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
281 |
$app->plugin('TagHelpers::Pagination' => {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
282 |
separator => ' ',
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
283 |
current => '<strong>{current}</strong>'
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
284 |
});
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
285 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
286 |
# Mojolicious::Lite
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
287 |
plugin 'TagHelpers::Pagination' => {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
288 |
separator => ' ',
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
289 |
current => '<strong>{current}</strong>'
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
290 |
};
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
291 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
292 |
# In Templates
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
293 |
%= pagination(2, 4, '?page={page}' => { separator => "\n" })
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
294 |
# <a href="?page=1" rel="prev"><</a>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
295 |
# <a href="?page=1">1</a>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
296 |
# <a rel="self"><strong>2</strong></a>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
297 |
# <a href="?page=3">3</a>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
298 |
# <a href="?page=4">4</a>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
299 |
# <a href="?page=3" rel="next">></a>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
300 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
301 |
=head1 DESCRIPTION
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
302 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
303 |
L<Mojolicious::Plugin::TagHelpers::Pagination> helps you to create
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
304 |
pagination elements in your templates, like this:
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
305 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
306 |
L<E<lt>|/#> L<1|/#> ... L<5|/#> B<[6]> L<7|/#> ... L<18|/#> L<E<gt>|/#>
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
307 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
308 |
=head1 METHODS
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
309 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
310 |
L<Mojolicious::Plugin::TagHelpers::Pagination> inherits all methods from
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
311 |
L<Mojolicious::Plugin> and implements the following new one.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
312 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
313 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
314 |
=head2 register
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
315 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
316 |
# Mojolicious
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
317 |
$app->plugin('TagHelpers::Pagination' => {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
318 |
separator => ' ',
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
319 |
current => '<strong>{current}</strong>'
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
320 |
});
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
321 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
322 |
# Or in your config file
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
323 |
{
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
324 |
'TagHelpers-Pagination' => {
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
325 |
separator => ' ',
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
326 |
current => '<strong>{current}</strong>'
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
327 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
328 |
}
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
329 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
330 |
Called when registering the plugin.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
331 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
332 |
All L<parameters|/PARAMETERS> can be set either on registration or
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
333 |
as part of the configuration file with the key C<TagHelpers-Pagination>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
334 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
335 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
336 |
=head1 HELPERS
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
337 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
338 |
=head2 pagination
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
339 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
340 |
# In Templates:
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
341 |
%= pagination(4, 6 => '/page-{page}.html');
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
342 |
% my $url = Mojo::URL->new->query({ page => '{page}'});
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
343 |
%= pagination(4, 6 => $url);
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
344 |
%= pagination(4, 6 => '/page/{page}.html', { current => '<b>{current}</b>' });
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
345 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
346 |
Generates a pagination string.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
347 |
Expects at least two numeric values: the current page number and
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
348 |
the total count of pages.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
349 |
Additionally it accepts a link pattern and a hash reference
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
350 |
with parameters overwriting the default plugin parameters for
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
351 |
pagination.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
352 |
The link pattern can be a string using a placeholder in curly brackets
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
353 |
(defaults to C<page>) for the page number it should link to.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
354 |
It's also possible to give a
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
355 |
L<Mojo::URL> object containing the placeholder.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
356 |
The placeholder can be used multiple times.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
357 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
358 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
359 |
=head1 PARAMETERS
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
360 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
361 |
For the layout of the pagination string, the plugin accepts the
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
362 |
following parameters, that are able to overwrite the default
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
363 |
layout elements. These parameters can again be overwritten in
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
364 |
the pagination helper.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
365 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
366 |
=over 2
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
367 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
368 |
=item current
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
369 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
370 |
Pattern for current page number. The C<{current}> is a
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
371 |
placeholder for the current number.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
372 |
Defaults to C<[{current}]>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
373 |
Instead of a pattern, both sides of the current number
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
374 |
can be defined with C<current_start> and C<current_end>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
375 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
376 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
377 |
=item ellipsis
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
378 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
379 |
Placeholder symbol for hidden pages. Defaults to C<...>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
380 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
381 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
382 |
=item next
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
383 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
384 |
Symbol for next pages. Defaults to C<>>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
385 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
386 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
387 |
=item page
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
388 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
389 |
Pattern for page number. The C<{page}> is a
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
390 |
placeholder for the page number.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
391 |
Defaults to C<{page}>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
392 |
Instead of a pattern, both sides of the page number
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
393 |
can be defined with C<page_start> and C<page_end>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
394 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
395 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
396 |
=item placeholder
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
397 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
398 |
String representing the placeholder for the page number in the URL
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
399 |
pattern. Defaults to C<page>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
400 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
401 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
402 |
=item prev
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
403 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
404 |
Symbol for previous pages. Defaults to C<<>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
405 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
406 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
407 |
=item separator
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
408 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
409 |
Symbol for the separation of pagination elements.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
410 |
Defaults to C< >.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
411 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
412 |
=back
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
413 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
414 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
415 |
=head1 DEPENDENCIES
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
416 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
417 |
L<Mojolicious>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
418 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
419 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
420 |
=head1 AVAILABILITY
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
421 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
422 |
https://github.com/Akron/Mojolicious-Plugin-TagHelpers-Pagination
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
423 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
424 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
425 |
=head1 COPYRIGHT AND LICENSE
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
426 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
427 |
Copyright (C) 2012-2014, L<Nils Diewald|http://nils-diewald.de/>.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
428 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
429 |
This program is free software, you can redistribute it
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
430 |
and/or modify it under the terms of the Artistic License version 2.0.
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
431 |
|
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
432 |
=cut
|