/[Frey]/trunk/lib/Frey/ORM/Links.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Frey/ORM/Links.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 207 - (hide annotations)
Fri Oct 31 15:33:15 2008 UTC (15 years, 6 months ago) by dpavlin
Original Path: trunk/lib/Frey/Web/Links.pm
File size: 912 byte(s)
implement slinding pager which show context of 10 pages
or 20 pages total if there is enough pages to display
1 dpavlin 110 package Frey::Web::Links;
2     use Moose;
3    
4 dpavlin 111 =head1 NAME
5    
6     Frey::Web::Links - simple links to current page with one param
7    
8     =cut
9    
10 dpavlin 110 has 'name' => (
11     'is' => 'rw',
12     isa => 'Str',
13     required => 1,
14     );
15    
16     has 'current' => (
17     is => 'rw',
18     isa => 'Str',
19     required => 1,
20     );
21    
22     has 'values' => (
23     is => 'rw',
24     isa => 'ArrayRef[Str]',
25     required => 1,
26     );
27    
28     has 'current_tag' => (
29     is => 'rw',
30     isa => 'Str',
31     default => 'em',
32     );
33    
34     has 'delimiter' => (
35     is => 'rw',
36     isa => 'Str',
37     default => ' ',
38     );
39    
40 dpavlin 207 has 'empty' => (
41     is => 'rw',
42     isa => 'Str',
43     default => '[empty]',
44     );
45    
46 dpavlin 110 sub links {
47     my $self = shift;
48     my @out =
49     map {
50 dpavlin 207 if ( $_ eq '' ) {
51     $self->empty
52     } elsif ( $self->current eq $_ ) {
53 dpavlin 110 '<' . $self->current_tag . '>' . $_ . '</' . $self->current_tag . '>'
54     } else {
55     qq|<a href="?| . $self->name . qq|=$_">$_</a>|
56     }
57     } ( @{ $self->values } );
58     return @out if wantarray;
59     return join($self->delimiter, @out);
60     }
61    
62     1;

  ViewVC Help
Powered by ViewVC 1.1.26