line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Controller::Tag; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
18461
|
use strict; |
|
35
|
|
|
|
|
100
|
|
|
35
|
|
|
|
|
1198
|
|
4
|
35
|
|
|
35
|
|
419
|
use parent 'Catalyst::Controller'; |
|
35
|
|
|
|
|
87
|
|
|
35
|
|
|
|
|
231
|
|
5
|
35
|
|
|
35
|
|
16913
|
use HTML::TagCloud; |
|
35
|
|
|
|
|
42405
|
|
|
35
|
|
|
|
|
417
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MojoMojo::Controller::Tag - Tags controller |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Handles the following URLs |
14
|
|
|
|
|
|
|
/.tags/ |
15
|
|
|
|
|
|
|
/.list/<tag> (dispatched from Page) |
16
|
|
|
|
|
|
|
/.recent/<tag> (dispatched from Page) |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This controller generates a tag cloud and retrieves (all or recent) pages |
21
|
|
|
|
|
|
|
tagged with a given tag. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 ACTIONS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 list |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This is a private action, and is dispatched from |
28
|
|
|
|
|
|
|
L<E<47>.list|MojoMojo::Controller::Page/list> when supplied with a tag |
29
|
|
|
|
|
|
|
argument. It will list all pages tagged with the given tag. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub list : Private { |
34
|
0
|
|
|
0
|
|
0
|
my ( $self, $c, $tag ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
0
|
return unless $tag; |
37
|
0
|
|
|
|
|
0
|
$c->stash->{template} = 'page/list.tt'; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
$c->stash->{activetag} = $tag; |
40
|
0
|
|
|
|
|
0
|
$c->stash->{pages} = [ $c->stash->{page}->tagged_descendants($tag) ]; |
41
|
0
|
|
|
|
|
0
|
$c->stash->{related} = [ $c->model("DBIC::Tag")->related_to($tag) ]; |
42
|
35
|
|
|
35
|
|
3422
|
} |
|
35
|
|
|
|
|
87
|
|
|
35
|
|
|
|
|
400
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 recent |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This is a private action, and is dispatched from |
47
|
|
|
|
|
|
|
L<E<47>.recent|MojoMojo::Controller::Page/recent> when supplied with a tag |
48
|
|
|
|
|
|
|
argument. It will list recent pages tagged with the given tag. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub recent : Private { |
53
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $c, $tag ) = @_; |
54
|
0
|
|
|
|
|
0
|
$c->stash->{template} = 'page/recent.tt'; |
55
|
0
|
0
|
|
|
|
0
|
return unless $tag; |
56
|
0
|
|
|
|
|
0
|
$c->stash->{activetag} = $tag; |
57
|
0
|
|
|
|
|
0
|
$c->stash->{pages} = [ $c->stash->{page}->tagged_descendants_by_date($tag) ]; |
58
|
|
|
|
|
|
|
|
59
|
35
|
|
|
35
|
|
431905
|
} |
|
35
|
|
|
|
|
94
|
|
|
35
|
|
|
|
|
177
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 tags (/.tags) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Tag cloud for pages. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub tags : Global { |
68
|
2
|
|
|
2
|
1
|
2055
|
my ( $self, $c, $tag ) = @_; |
69
|
2
|
|
|
|
|
13
|
my $tags = [ $c->model("DBIC::Tag")->by_page( $c->stash->{page}->id ) ]; |
70
|
2
|
|
|
|
|
7652
|
my %tags; |
71
|
|
|
|
|
|
|
map { |
72
|
2
|
|
|
|
|
32
|
$tags{$_->tag}++; |
|
10
|
|
|
|
|
264
|
|
73
|
|
|
|
|
|
|
}@$tags; |
74
|
2
|
|
|
|
|
41
|
my $cloud = HTML::TagCloud->new(); |
75
|
2
|
|
|
|
|
39
|
foreach my $tag (keys %tags) { |
76
|
|
|
|
|
|
|
$cloud->add( |
77
|
|
|
|
|
|
|
$tag, |
78
|
|
|
|
|
|
|
$c->req->base . $c->stash->{path} . '.list/' . $tag, |
79
|
6
|
|
|
|
|
582
|
$tags{$tag} |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
2
|
|
|
|
|
249
|
$c->stash->{cloud} = $cloud; |
83
|
2
|
|
|
|
|
125
|
$c->stash->{template} = 'tag/cloud.tt'; |
84
|
35
|
|
|
35
|
|
35668
|
} |
|
35
|
|
|
|
|
82
|
|
|
35
|
|
|
|
|
166
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Marcus Ramberg <mramberg@cpan.org> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 LICENSE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
93
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |