File Coverage

blib/lib/Tapper/Reports/Web/Controller/Tapper.pm
Criterion Covered Total %
statement 29 36 80.5
branch 1 6 16.6
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 40 52 76.9


line stmt bran cond sub pod time code
1             package Tapper::Reports::Web::Controller::Tapper;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Reports::Web::Controller::Tapper::VERSION = '5.0.15';
4 11     11   5813 use strict;
  11         33  
  11         364  
5 11     11   58 use warnings;
  11         175  
  11         363  
6 11     11   418 use 5.010;
  11         40  
7 11     11   4655 use Tapper::Reports::Web::Util;
  11         35  
  11         407  
8              
9 11     11   83 use parent 'Tapper::Reports::Web::Controller::Base';
  11         30  
  11         86  
10              
11             sub index :Path :Args(0)
12             {
13 3     3   4344 my ( $self, $c ) = @_;
14              
15             # the easy way, to avoid fiddling with Mason autohandlers on
16             # simple redirects
17              
18 3         9 my $body = <<EOF;
19             <html>
20             <head>
21             <meta http-equiv="refresh" content="0; URL=/tapper/start">
22             <meta name="description" content="Tapper"
23             <title>Tapper</title>
24             </head>
25             EOF
26 3         73 $c->response->body($body);
27 11     11   1354 }
  11         24  
  11         93  
28              
29              
30             sub auto :Private
31             {
32 21     21 1 31067 my ( $self, $c ) = @_;
33 21         215 my $util = Tapper::Reports::Web::Util->new();
34              
35              
36 21         4818 my (undef, $action) = split '/', $c->req->action;
37 21         1324 $c->stash->{top_menu} = $util->prepare_top_menu($action);
38 21 50       1460 if ($c->config->{use_authentication}) {
39 0 0       0 if ($c->user_exists()) {
40 0         0 my $username = $c->user->username;
41 0         0 foreach (@{$c->stash->{top_menu}}) {
  0         0  
42 0 0       0 if ($_->{text} eq 'Login') {
43 0         0 $_->{text} = "Logout $username";
44 0         0 $_->{uri} = '/tapper/user/logout';
45             }
46             }
47             }
48             }
49              
50             # if auto returns false the remaining actions are not called
51 21         2076 1;
52 11     11   137791 }
  11         37  
  11         72  
53              
54              
55             1;
56              
57             __END__
58              
59             =pod
60              
61             =encoding UTF-8
62              
63             =head1 NAME
64              
65             Tapper::Reports::Web::Controller::Tapper
66              
67             =head2 auto
68              
69             This function is called. It creates the datastructure for the associated
70             autohandler template to generate the navigation links. This
71             datastructure is put onto the stash and therefore the function does not
72             return anything. It is called automatically from Catalyst with an object
73             reference ($self) and the catalyst context. Thus you also don't need to
74             worry about parameters.
75              
76             =head1 AUTHORS
77              
78             =over 4
79              
80             =item *
81              
82             AMD OSRC Tapper Team <tapper@amd64.org>
83              
84             =item *
85              
86             Tapper Team <tapper-ops@amazon.com>
87              
88             =back
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is Copyright (c) 2020 by Advanced Micro Devices, Inc..
93              
94             This is free software, licensed under:
95              
96             The (two-clause) FreeBSD License
97              
98             =cut