| 1 | package XTaTIK::Controller::Root; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.001002'; # VERSION | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use Mojo::Base 'Mojolicious::Controller'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use XTaTIK::Common qw/n_to_br/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use File::Spec::Functions qw/catfile/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use experimental 'postderef'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | sub index { | ||||||||||||||||||||
| 11 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
index: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | my @products = $self->products->get_by_number( | |||||||||||||||||||
| 14 | split /\n/, $self->xvar('hot_products') | ||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | $self->_find_product_pic( $_->{image} ) for @products; | |||||||||||||||||||
| 18 | 0 | $self->stash( hot_products => \@products, ); | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | sub products_category { | ||||||||||||||||||||
| 22 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
products_category: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | my ( $products, $return_path, $return_name ) | |||||||||||||||||||
| 25 | = $self->products->get_category( $self->stash('category') ); | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | for ( @$products ) { | |||||||||||||||||||
| 28 | 0 | $self->_find_product_pic( $_->{image} ) for $_->{contents}->@*; | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | $self->stash( | ||||||||||||||||||||
| 32 | 0 | products => $products, | |||||||||||||||||||
| 33 | return_path => $return_path, | ||||||||||||||||||||
| 34 | return_name => $return_name, | ||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | sub _find_product_pic { | ||||||||||||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_find_product_pic: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | $_[0] = 'nopic.png' | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table0%0/2
A
A= $_[0]
| |||||||||||||||||||||
| 42 | unless $self->app->static | ||||||||||||||||||||
| 43 | ->file( catfile 'product-pics', $_[0]//'' ); | ||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub product { | ||||||||||||||||||||
| 47 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
product: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 48 | 0 | my ( $product ) = $self->products->get_by_url( $self->stash('url') ); | |||||||||||||||||||
| 49 | 0 | ▶ | $product or $self->reply->not_found; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | $self->_find_product_pic( $product->{image} ); | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | $self->stash( product => $product ); | |||||||||||||||||||
| 54 | }; | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | sub contact_post { | ||||||||||||||||||||
| 57 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
contact_post: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | $self->form_checker( | |||||||||||||||||||
| 60 | rules => { | ||||||||||||||||||||
| 61 | name => { max => 200, }, | ||||||||||||||||||||
| 62 | email => { max => 200, }, | ||||||||||||||||||||
| 63 | province => { | ||||||||||||||||||||
| 64 | valid_values => [ | ||||||||||||||||||||
| 65 | qw/AB BC MB NB NF NT NS NU ON PE QC SK YT/ | ||||||||||||||||||||
| 66 | ], | ||||||||||||||||||||
| 67 | valid_values_error => 'Please choose your province', | ||||||||||||||||||||
| 68 | }, | ||||||||||||||||||||
| 69 | message => { max => 100_000 }, | ||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | ▶ | return $self->render( template => 'root/contact' ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | unless $self->form_checker_ok; | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | # Check CSRF token | ||||||||||||||||||||
| 77 | 0 | ▶ | return $self->render(text => 'Bad CSRF token!', status => 403) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | if $self->validation->csrf_protect->has_error('csrf_token'); | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 0 | $self->stash( visitor_ip => $self->tx->remote_address ); | |||||||||||||||||||
| 81 | 0 | $self->stash( message => n_to_br( $self->param('message')) ); | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | $self->mail( | ||||||||||||||||||||
| 84 | test => $self->config('mail')->{test}, | ||||||||||||||||||||
| 85 | to => $self->config('mail')->{to}{quicknote}, | ||||||||||||||||||||
| 86 | from => $self->config('mail')->{from}{quicknote}, | ||||||||||||||||||||
| 87 | subject => 'Quicknote from ' | ||||||||||||||||||||
| 88 | . $self->config('text')->{website_domain}, | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 0 | type => 'text/html', | |||||||||||||||||||
| 91 | data => $self->render_to_string('email-templates/quicknote'), | ||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | return $self->render( template => 'root/contact' ); | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | sub feedback_post { | ||||||||||||||||||||
| 98 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
feedback_post: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 0 | $self->form_checker( | |||||||||||||||||||
| 101 | rules => { | ||||||||||||||||||||
| 102 | email => { max => 200, optional => 1, }, | ||||||||||||||||||||
| 103 | feedback => { max => 100_000, }, | ||||||||||||||||||||
| 104 | }, | ||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | 0 | ▶ | return $self->render( template => 'root/feedback' ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 108 | unless $self->form_checker_ok; | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 0 | $self->stash( | |||||||||||||||||||
| 111 | visitor_ip => $self->tx->remote_address, | ||||||||||||||||||||
| 112 | feedback => n_to_br( $self->param('feedback') ), | ||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | $self->mail( | ||||||||||||||||||||
| 116 | test => $self->config('mail')->{test}, | ||||||||||||||||||||
| 117 | to => $self->config('mail')->{to}{feedback}, | ||||||||||||||||||||
| 118 | from => $self->config('mail')->{from}{feedback}, | ||||||||||||||||||||
| 119 | subject => 'Site Feedback from ' | ||||||||||||||||||||
| 120 | . $self->config('text')->{website_domain}, | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 0 | type => 'text/html', | |||||||||||||||||||
| 123 | data => $self->render_to_string('email-templates/feedback'), | ||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | return $self->render( template => 'root/feedback' ); | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | sub sitemap { | ||||||||||||||||||||
| 130 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
sitemap: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | $self->stash( | ||||||||||||||||||||
| 133 | urls => [ | ||||||||||||||||||||
| 134 | map +{ | ||||||||||||||||||||
| 135 | freq => 'weekly', | ||||||||||||||||||||
| 136 | priority => '0.9', | ||||||||||||||||||||
| 137 | url => $self->xtext('website_proto') | ||||||||||||||||||||
| 138 | . '://' | ||||||||||||||||||||
| 139 | . $self->xtext('website_domain') | ||||||||||||||||||||
| 140 | . $_, | ||||||||||||||||||||
| 141 | }, qw{ | ||||||||||||||||||||
| 142 | / | ||||||||||||||||||||
| 143 | /blog | ||||||||||||||||||||
| 144 | /history | ||||||||||||||||||||
| 145 | /about | ||||||||||||||||||||
| 146 | /contact | ||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||
| 148 | 0 | ▶ | ( map '/blog/' . $_->{url}, @{$self->blog->brief_list ||[]}), | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 149 | 0 | ▶ | map '/product/' . $_->{url}, @{ $self->products->get_all||[] }, | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 150 | ], | ||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||
| 152 | } | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | 1 | 1; | |||||||||||||||||||
| 155 | |||||||||||||||||||||