lib/MojoMojo/Controller/Tag.pm

filter: Statementstmt 72.5% 29 / 40 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 2 / 2 totaltotal 69.0% 38 / 55 CC 4 SCAR 10.4
CC
4
Cov
66%
list
6.0
recent
6.0
tags
2.0
CRAP 2.8
« lib/MojoMojo/Formatter/Emote.pm ↑ Summary lib/MojoMojo/Formatter/IDLink.pm »
1 package MojoMojo::Controller::Tag;
2  
3 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use parent 'Catalyst::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use HTML::TagCloud;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶sub list : Private {
Subroutine list: not called CC=2 SCAR=17.9
34 0 my ( $self, $c, $tag ) = @_;
35  
36 0 ▶ return unless $tag;
Branch: 1 branch
BranchTrueFalseTotal
unless $tag 0 0 0
37 0 $c->stash->{template} = 'page/list.tt';
38  
39 0 $c->stash->{activetag} = $tag;
40 0 $c->stash->{pages} = [ $c->stash->{page}->tagged_descendants($tag) ];
41 0 $c->stash->{related} = [ $c->model("DBIC::Tag")->related_to($tag) ];
42 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶sub recent : Private {
Subroutine recent: not called CC=2 SCAR=17.9
Pod documented
53 0 my ( $self, $c, $tag ) = @_;
54 0 $c->stash->{template} = 'page/recent.tt';
55 0 ▶ return unless $tag;
Branch: 1 branch
BranchTrueFalseTotal
unless $tag 0 0 0
56 0 $c->stash->{activetag} = $tag;
57 0 $c->stash->{pages} = [ $c->stash->{page}->tagged_descendants_by_date($tag) ];
58  
59 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 =head2 tags (/.tags)
62  
63 Tag cloud for pages.
64  
65 =cut
66  
67 2 ▶sub tags : Global {
Subroutine tags: called CC=2 SCAR=6.9
Pod documented
68 2 my ( $self, $c, $tag ) = @_;
69 2 my $tags = [ $c->model("DBIC::Tag")->by_page( $c->stash->{page}->id ) ];
70 2 my %tags;
71 map {
72 2 $tags{$_->tag}++;
73 }@$tags;
74 2 my $cloud = HTML::TagCloud->new();
75 2 foreach my $tag (keys %tags) {
76 $cloud->add(
77 $tag,
78 $c->req->base . $c->stash->{path} . '.list/' . $tag,
79 6 $tags{$tag}
80 );
81 }
82 2 $c->stash->{cloud} = $cloud;
83 2 $c->stash->{template} = 'tag/cloud.tt';
84 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
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 35 1;
« lib/MojoMojo/Formatter/Emote.pm ↑ Summary lib/MojoMojo/Formatter/IDLink.pm »