| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package Jifty::View::Mason::Handler; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | Jifty::View::Mason::Handler - Handler for Mason requests inside of Jifty | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 SUMMARY | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | Jifty controls all of the input and output from the Mason templating | ||||||||||||||||||||||||||||||||||||||||||
| 13 | engine; this means that we cannot use the Mason's standard | ||||||||||||||||||||||||||||||||||||||||||
| 14 | L<HTML::Mason::CGIHandler> interface to interact with it. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use HTML::Mason; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use HTML::Mason::Utils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use HTML::Mason::Exceptions; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use HTML::Mason::FakeApache; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Encode qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Jifty::View::Mason::Request; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Class::Container; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use base qw(Jifty::View Class::Container); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | use HTML::Mason::MethodMaker | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | ( read_write => [ qw( interp ) ] ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | __PACKAGE__->valid_params | |||||||||||||||||||||||||||||||||||||||||
| 35 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 36 | interp => { isa => 'HTML::Mason::Interp' }, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | __PACKAGE__->contained_objects | |||||||||||||||||||||||||||||||||||||||||
| 40 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 41 | interp => 'HTML::Mason::Interp', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head2 new PARAMHASH | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | Takes a number of key-value parameters; see L<HTML::Mason::Params>. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | Defaults the C<out_method> to appending to L<Jifty::Handler/buffer> | ||||||||||||||||||||||||||||||||||||||||||
| 49 | and the C<request_class> to L<Jifty::View::Mason::Request> (below). | ||||||||||||||||||||||||||||||||||||||||||
| 50 | Finally, adds C<h> and C<u> escapes, which map to L</escape_uri> and | ||||||||||||||||||||||||||||||||||||||||||
| 51 | L<escape_utf8> respectively. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $package->create_cache_directories; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my %p = @_ || $package->config; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ || $package->config
MC/DC0%0/2
@_ || $package->config
@_
$package->config
Truth table0%0/3
A || B
A= @_B= $package->config
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | my $self = $package->SUPER::new( request_class => 'Jifty::View::Mason::Request', | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | out_method => sub {Carp::cluck("Mason output skipped Jifty's output stack!") if grep {defined and length} @_}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | %p ); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->interp->set_escape( h => \&escape_utf8 ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->interp->set_escape( u => \&escape_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | =head2 config | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | Returns our Mason config. We use the component root specified in the | ||||||||||||||||||||||||||||||||||||||||||
| 74 | C<Web/TemplateRoot> framework configuration variable (or C<html> by | ||||||||||||||||||||||||||||||||||||||||||
| 75 | default). Additionally, we set up a C<jifty> component root, as | ||||||||||||||||||||||||||||||||||||||||||
| 76 | specified by the C<Web/DefaultTemplateRoot> configuration. All | ||||||||||||||||||||||||||||||||||||||||||
| 77 | interpolations are HTML-escaped by default, and we use the fatal error | ||||||||||||||||||||||||||||||||||||||||||
| 78 | mode. | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | my %config = ( | ||||||||||||||||||||||||||||||||||||||||||
| 86 | static_source => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | use_object_files => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | preprocess => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | # Force UTF-8 semantics on all our components by | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # prepending this block to all components as Mason | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # components defaults to parse the text as Latin-1 | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ${$_[0]} =~ s!^!<\%INIT>use utf8;</\%INIT>\n!; | |||||||||||||||||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | data_dir => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'DataDir'} ), | ||||||||||||||||||||||||||||||||||||||||||
| 95 | allow_globals => [ | ||||||||||||||||||||||||||||||||||||||||||
| 96 | qw[ $JiftyWeb ], | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | @{Jifty->config->framework('Web')->{'Globals'} || []}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'Jifty'->config->framework('Web')->{'Globals'} || []
MC/DC0%0/1
'Jifty'->config->framework('Web')->{'Globals'} || []
'Jifty'->config->framework('Web')->{'Globals'}
Truth table0%0/2
A
A= 'Jifty'->config->framework('Web')->{'Globals'}
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 99 | comp_root => [ | ||||||||||||||||||||||||||||||||||||||||||
| 100 | [application => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'TemplateRoot'} )], | ||||||||||||||||||||||||||||||||||||||||||
| 101 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | %{ Jifty->config->framework('Web')->{'MasonConfig'} }, | |||||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $root_serial = 0; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my %seen; $seen{$_} = 1 for map Jifty->config->framework('Web')->{$_}, qw/TemplateRoot DefaultTemplateRoot/; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | for my $plugin (Jifty->plugins) { | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $comp_root = $plugin->template_root; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | next unless ( defined $comp_root and -d $comp_root and not $seen{$comp_root}++); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $comp_root and -d $comp_root and not $seen{$comp_root}++
defined $comp_root and -d $comp_root
MC/DC0%0/3
defined $comp_root and -d $comp_root and not $seen{$comp_root}++
defined $comp_root
-d $comp_root
not $seen{$comp_root}++
Truth table0%0/4
A and B and not(C)
A= defined $comp_rootB= -d $comp_rootC= not $seen{$comp_root}++
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $plugin->log->debug( "Plugin @{[ref($plugin)]} mason component root added: (@{[$comp_root ||'']})"); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$comp_root || ''
MC/DC0%0/1
$comp_root || ''
$comp_root
Truth table0%0/2
A
A= $comp_root
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | push @{ $config{comp_root} }, [ ref($plugin)."-". $root_serial++ => $comp_root ]; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | push @{$config{comp_root}}, [jifty => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'DefaultTemplateRoot'})]; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | # In developer mode, we want refreshing and all that other good stuff. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (Jifty->config->framework('DevelMode') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $config{static_source} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $config{use_object_files} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | # We require autoflush now. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $config{autoflush} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return %config; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | =head2 escape_utf8 SCALARREF | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | Does a css-busting but minimalist escaping of whatever html you're passing in. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub escape_utf8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_utf8: not called CC=1 SCAR=3.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $$ref =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $$ref =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $$ref =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $$ref =~ s/\(/(/g; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $$ref =~ s/\)/)/g; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $$ref =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $$ref =~ s/'/'/g; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | =head2 escape_uri SCALARREF | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | Escapes in-place URI component according to RFC2396. Takes a reference to | ||||||||||||||||||||||||||||||||||||||||||
| 148 | perl string. | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | *Note* that octets would be treated as latin1 encoded sequence and converted | ||||||||||||||||||||||||||||||||||||||||||
| 151 | to UTF-8 encoding and then escaped. So this sub always provide UTF-8 escaped | ||||||||||||||||||||||||||||||||||||||||||
| 152 | string. See also L<Encode> for more info about converting. | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub escape_uri { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $$ref = Encode::encode_utf8($$ref); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $$ref =~ s/([^a-zA-Z0-9_.!~*'()-])/uc sprintf("%%%02X", ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | =head2 template_exists COMPONENT | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | Checks if the C<COMPONENT> exists, or if C<COMPONENT/index.html> | ||||||||||||||||||||||||||||||||||||||||||
| 166 | exists, and returns which one did. If neither did, it searches for | ||||||||||||||||||||||||||||||||||||||||||
| 167 | C<dhandler> components which could match, returning C<COMPONENT> if it | ||||||||||||||||||||||||||||||||||||||||||
| 168 | finds one. Finally, if it finds no possible component matches, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | returns undef. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | Note that this algorithm does not actually decisively return if Mason | ||||||||||||||||||||||||||||||||||||||||||
| 172 | I<will> handle a given component; the I<dhandler>s could defer | ||||||||||||||||||||||||||||||||||||||||||
| 173 | handling, for instance. | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub template_exists { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
template_exists: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my ($component) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $component =~ s{^/*}{/}; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return $component if $self->interp->comp_exists($component); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | return "$component/index.html" if $self->interp->comp_exists("$component/index.html"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $dhandler = $self->interp->dhandler_name; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $dhandler = "dhandler" unless defined $dhandler; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | return if defined $dhandler and not length $dhandler; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $dhandler and not length $dhandler
MC/DC0%0/2
defined $dhandler and not length $dhandler
defined $dhandler
not length $dhandler
Truth table0%0/3
A and not(B)
A= defined $dhandlerB= not length $dhandler
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | return $component if $self->interp->find_comp_upwards($component, $dhandler); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =head2 show COMPONENT | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | Takes a component path to render. Deals with setting up a global | ||||||||||||||||||||||||||||||||||||||||||
| 195 | L<HTML::Mason::FakeApache> and Request object, and calling the | ||||||||||||||||||||||||||||||||||||||||||
| 196 | component. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =head2 handle_comp | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | A synonym for show | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub show { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | shift->handle_comp(@_); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub _comp_setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_comp_setup: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my ($self, $comp, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # XXX FIXME This is a kludge to get use_mason_wrapper to work | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->interp->set_global('$jifty_internal_request', 0); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | $self->interp->set_global('$jifty_internal_request', 1) if defined $args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return $args ? %$args : $self->request_args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub handle_comp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_comp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my ($comp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my %args = $self->_comp_setup(@_); | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $self->interp->exec($comp, %args); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | =head2 request_args | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | The official source for request arguments is from the current | ||||||||||||||||||||||||||||||||||||||||||
| 229 | L<Jifty::Request> object. | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub request_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_args: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return %{Jifty->web->request->arguments}, %{Jifty->web->request->template_arguments || {}}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'Jifty'->web->request->template_arguments || {}
MC/DC0%0/1
'Jifty'->web->request->template_arguments || {}
'Jifty'->web->request->template_arguments
Truth table0%0/2
A
A= 'Jifty'->web->request->template_arguments
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | =head2 create_cache_directories | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | Attempts to create our application's mason cache directory. | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub create_cache_directories { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_cache_directories: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | for ( Jifty->config->framework('Web')->{'DataDir'} ) { | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | Jifty::Util->make_path( Jifty::Util->absolute_path($_) ); | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||