line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Extensions::Counter; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
31439685
|
use strict; |
|
35
|
|
|
|
|
97
|
|
|
35
|
|
|
|
|
1079
|
|
4
|
35
|
|
|
35
|
|
190
|
use warnings; |
|
35
|
|
|
|
|
79
|
|
|
35
|
|
|
|
|
1307
|
|
5
|
|
|
|
|
|
|
|
6
|
35
|
|
|
35
|
|
193
|
use base qw(MojoMojo::Extension); # ISA Catalyst::Controller |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
11543
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 Name |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
MojoMojo::Extensions::Counter - a page counter |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head2 Methods |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 index |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
View page. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub index :Path('counter') :Args(0) { |
21
|
7
|
|
|
7
|
|
8489
|
my ( $self, $c ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
7
|
|
|
|
|
51
|
$c->detach('view'); |
24
|
35
|
|
|
35
|
|
236
|
} |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
632
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 view |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Add count into the view. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub view :Path('counter.view') :Args(0) { |
33
|
8
|
|
|
8
|
1
|
4841
|
my ( $self, $c ) = @_; |
34
|
8
|
|
100
|
|
|
48
|
@{$c->stash}{qw(current_view template count)} = ('TT', 'extensions/counter.tt', $c->session->{count} || 0); |
|
8
|
|
|
|
|
6396
|
|
35
|
35
|
|
|
35
|
|
670988
|
} |
|
35
|
|
|
|
|
99
|
|
|
35
|
|
|
|
|
177
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 add |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Increment count by 1. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub add :Path('counter.add') :Args(0) { |
44
|
2
|
|
|
2
|
1
|
1997
|
my ( $self, $c ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
10
|
my $session = $c->session; |
47
|
2
|
|
100
|
|
|
246
|
my $count = $session->{count} || 0; |
48
|
2
|
|
|
|
|
8
|
$session->{count} = $count + 1; |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
11
|
$c->res->redirect($c->uri_for('/special/counter')); |
51
|
35
|
|
|
35
|
|
35099
|
} |
|
35
|
|
|
|
|
90
|
|
|
35
|
|
|
|
|
162
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 subtract |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Reduce count by 1. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub subtract :Path('counter.subtract') :Args(0) { |
60
|
2
|
|
|
2
|
1
|
1894
|
my ( $self, $c ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
10
|
my $session = $c->session; |
63
|
2
|
|
50
|
|
|
241
|
my $count = $session->{count} || 0; |
64
|
2
|
|
|
|
|
6
|
$session->{count} = $count - 1; |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
10
|
$c->res->redirect($c->uri_for('/special/counter')); |
67
|
35
|
|
|
35
|
|
32743
|
} |
|
35
|
|
|
|
|
89
|
|
|
35
|
|
|
|
|
204
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |