lib/Rapi/Blog/Template/AccessStore.pm

filter: Statementstmt 31.0% 58 / 187 Branchbran 0.0% 0 / 80 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 23.4% 15 / 64 Podpod 0.0% 0 / 19 totaltotal 18.3% 73 / 398 CC 52 SCAR 26.7
CC
52
Cov
20%
__ANON__
56.0
__ANON__
56.0
__ANON__
42.0
CRAP 14.5
« lib/Rapi/Blog/Module/SectionTree.pm ↑ Summary lib/Rapi/Blog/Scaffold/ViewWrapper.pm »
1 package Rapi::Blog::Template::AccessStore;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 1 ▶use RapidApp::Util qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Rapi::Blog::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 extends 'RapidApp::Template::AccessStore';
11 1 ▶use Types::Standard ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 1 ▶use Rapi::Blog::Scaffold;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rapi::Blog::Template::Dispatcher;
Subroutine BEGIN: called CC=1 SCAR=0.0
15
16 1 ▶use Plack::App::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Plack::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Plack::Middleware::ConditionalGET;
Subroutine BEGIN: called CC=1 SCAR=0.0
19
20 0 ▶sub _cache_slots { (shift)->local_cache->{template_row_slot} //= {} }
Subroutine _cache_slots: not called CC=2 SCAR=17.9
Condition0%0/2
+(shift())->local_cache->{"template_row_slot"} //= {}
l!l
00
MC/DC0%0/1
+(shift())->local_cache->{"template_row_slot"} //= {}
+(shift())->local_cache->{"template_row_slot"}
Truth table0%0/2
A
A= +(shift())->local_cache->{"template_row_slot"}
Aresult
11
00
21
22 1 has 'BlogCfg', is => 'ro', required => 1, isa => HashRef;
23 1 has 'ScaffoldSet', is => 'ro', required => 1, isa => InstanceOf['Rapi::Blog::Scaffold::Set'];
24 1 has 'scaffold_cfg', is => 'ro', required => 1, isa => InstanceOf['Rapi::Blog::Scaffold::Config'];
25
26 0 ▶sub Dispatcher_for {
Subroutine Dispatcher_for: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my ($self,@args) = @_;
28 0 my $path = join('/',@args);
29 0 ▶ $self->_cache_slots->{$path}{Dispatcher} ||= Rapi::Blog::Template::Dispatcher->new(
Condition0%0/3
$self->_cache_slots->{$path}{"Dispatcher"} ||= "Rapi::Blog::Template::Dispatcher"->new("path", $path, "AccessStore", $self, "ctx", "RapidApp"->active_request_context)->resolve
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_cache_slots->{$path}{"Dispatcher"} ||= "Rapi::Blog::Template::Dispatcher"->new("path", $path, "AccessStore", $self, "ctx", "RapidApp"->active_request_context)->resolve
$self->_cache_slots->{$path}{"Dispatcher"} "Rapi::Blog::Template::Dispatcher"->new("path", $path, "AccessStore", $self, "ctx", "RapidApp"->active_request_context)->resolve
Truth table0%0/3
A ||= B
A= $self->_cache_slots->{$path}{"Dispatcher"}B= "Rapi::Blog::Template::Dispatcher"->new("path", $path, "AccessStore", $self, "ctx", "RapidApp"->active_request_context)->resolve
ABresult
1X1
011
000
30 path => $path, AccessStore => $self, ctx => RapidApp->active_request_context
31 )->resolve
32 }
33
34 0 ▶sub PostDispatcher_for {
Subroutine PostDispatcher_for: not called CC=3 SCAR=24.8
Pod undocumented
35 0 my $self = shift;
36 0 ▶ my $Dispatcher = $self->Dispatcher_for(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $Dispatcher = $self->Dispatcher_for(@_) or return undef 0 0 0
37 0 ▶ $Dispatcher->type eq 'Post' ? $Dispatcher : undef
Branch: 1 branch
BranchTrueFalseTotal
$Dispatcher->type eq 'Post' ? : 0 0 0
38 }
39
40 0 ▶sub Post_name_for {
Subroutine Post_name_for: not called CC=2 SCAR=17.9
Pod undocumented
41 0 my $self = shift;
42 0 ▶ my $Dispatcher = $self->PostDispatcher_for(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $Dispatcher = $self->PostDispatcher_for(@_) or return undef 0 0 0
43 0 $Dispatcher->name
44 }
45
46
47 #has 'scaffold_dir', is => 'ro', isa => InstanceOf['Path::Class::Dir'], required => 1;
48 #has 'scaffold_cnf', is => 'ro', isa => HashRef, required => 1;
49 #has 'static_paths', is => 'ro', isa => ArrayRef[Str], default => sub {[]};
50 #has 'private_paths', is => 'ro', isa => ArrayRef[Str], default => sub {[]};
51 #has 'default_ext', is => 'ro', isa => Maybe[Str], default => sub {undef};
52
53 0 ▶around 'template_external_tpl' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
54 0 my ($orig,$self,@args) = @_;
55 0 my $template = join('/',@args);
56
57 0 ▶ $self->Dispatcher_for($template)->claimed ? 1 : $self->$orig(@args)
Branch: 1 branch
BranchTrueFalseTotal
$self->Dispatcher_for($template)->claimed ? : 0 0 0
58 1 };
59
60
61 # Deny post templates access to to privileged attributes such as the catalyst context object).
62 # This could be expanded later on to allow only certain posts to be able to access these attributes.
63 0 ▶around 'template_admin_tpl' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
64 0 my ($orig,$self,@args) = @_;
65 0 my $template = join('/',@args);
66 0 ▶ $self->Dispatcher_for($template)->restrict ? 0 : $self->$orig(@args)
Branch: 1 branch
BranchTrueFalseTotal
$self->Dispatcher_for($template)->restrict ? : 0 0 0
67 1 };
68
69
70
71
72 0 ▶sub templateData {
Subroutine templateData: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my ($self, $template) = @_;
74 0 ▶ die 'template name argument missing!' unless ($template);
Branch: 1 branch
BranchTrueFalseTotal
unless $template 0 0 0
75
76 0 $self->Dispatcher_for($template)->template_vars
77 }
78
79 # -----------------
80 # Access class API:
81
82 0 ▶around '_get_default_template_vars' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
83 0 my ($orig,$self,@args) = @_;
84 0 my $c = RapidApp->active_request_context;
85
86 0 my $template = join('/',@args);
87 0 my $recaptcha_config = $self->BlogCfg->{recaptcha_config};
88
89 my $vars = {
90 0 %{ $self->$orig(@args) },
91 0 ▶ %{ $self->templateData($template) || {} },
Condition0%0/2
$self->templateData($template) || {}
l!l
00
MC/DC0%0/1
$self->templateData($template) || {}
$self->templateData($template)
Truth table0%0/2
A
A= $self->templateData($template)
Aresult
11
00
92
93 BlogCfg => $self->BlogCfg,
94 scaffold => $self->scaffold_cfg,
95 0 ▶ list_posts => sub { $self->Model->resultset('Post') ->list_posts(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
96 0 ▶ get_posts => sub { $self->Model->resultset('Post') ->get_posts(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 ▶ list_tags => sub { $self->Model->resultset('Tag') ->list_tags(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 0 ▶ list_categories => sub { $self->Model->resultset('Category') ->list_categories(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 0 ▶ list_sections => sub { $self->Model->resultset('Section') ->list_sections(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 0 ▶ list_users => sub { $self->Model->resultset('User') ->list_users(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
101
102 # TODO: consider mount_url
103 0 ▶ request_path => sub { $c ? join('','/',$c->req->path) : undef },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$c ? : 0 0 0
104
105 0 ▶ User => sub { Rapi::Blog::Util->get_User },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106
107 # Path to the 'Remote' controller
108 0 ▶ remote_action_path => sub { $c ? join('',$c->mount_url,'/remote') : undef },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$c ? : 0 0 0
109
110 0 ▶ add_post_path => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
111 0 my $ns = $c->module_root_namespace;
112 0 ▶ if(my $mode = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift()) { } 0 0 0
113 0 $mode = lc($mode);
114 # Note: 'direct' is not useful un this context since add relies on opening new tab
115 0 ▶ die "add_post_path(): bad argument '$mode' -- must be undef or 'navable'"
Branch: 1 branch
BranchTrueFalseTotal
unless $mode eq "navable" 0 0 0
116 unless ($mode eq 'navable');
117 0 return join('',$c->mount_url,'/rapidapp/module/',$mode,'/',$ns,'/main/db/db_post/add')
118 }
119 else {
120 0 return join('',$c->mount_url,'/',$ns,'/#!/',$ns,'/main/db/db_post/add')
121 }
122 },
123
124 0 ▶ resolve_section_id => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
125 0 ▶ if(my $id = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $id = shift()) 0 0 0
126 0 my $Section = $self->Model->resultset('Section')
127 ->search_rs({ 'me.id' => $id })
128 ->first;
129 0 ▶ return $Section ? $Section->name : $id
Branch: 1 branch
BranchTrueFalseTotal
$Section ? : 0 0 0
130 }
131 },
132
133 # Expose this here so its available to non-priv templates:
134 0 ▶ mount_url => sub { $c->mount_url },
Subroutine __ANON__: not called CC=1 SCAR=6.9
135
136 0 ▶ accessed_site => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
137 0 ▶ $c && $c->req or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$c and $c->req or return undef 0 0 0
Condition0%0/3
$c and $c->req
!ll&&!rl&&r
000
MC/DC0%0/2
$c and $c->req
$c $c->req
Truth table0%0/3
A and B
A= $cB= $c->req
ABresult
0X0
100
111
138 0 ▶ my $uri = $c->req->uri or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $uri = $c->req->uri or return undef 0 0 0
139 0 ▶ my $host = $c->req->env->{HTTP_HOST} || $uri->host_port;
Condition0%0/3
$c->req->env->{'HTTP_HOST'} || $uri->host_port
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->req->env->{'HTTP_HOST'} || $uri->host_port
$c->req->env->{'HTTP_HOST'} $uri->host_port
Truth table0%0/3
A || B
A= $c->req->env->{'HTTP_HOST'}B= $uri->host_port
ABresult
1X1
011
000
140 0 ▶ my $proto = $c->req->env->{HTTP_X_FORWARDED_PROTO} || $uri->scheme || 'http';
Condition0%0/5
$c->req->env->{'HTTP_X_FORWARDED_PROTO'} || $uri->scheme || 'http'
l!l
00
$c->req->env->{"HTTP_X_FORWARDED_PROTO"} or $uri->scheme
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->req->env->{'HTTP_X_FORWARDED_PROTO'} || $uri->scheme || 'http'
$c->req->env->{"HTTP_X_FORWARDED_PROTO"} $uri->scheme
Truth table0%0/3
A or B
A= $c->req->env->{"HTTP_X_FORWARDED_PROTO"}B= $uri->scheme
ABresult
1X1
011
000
141 0 join('',$proto,'://',$host)
142 },
143
144 0 ▶ local_info => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
145 0 my $new = shift;
146
147 0 ▶ my $uri = $c->req->uri or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $uri = $c->req->uri or return undef 0 0 0
148 0 ▶ my $session = $c->session or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $session = $c->session or return undef 0 0 0
149 0 my $err = $session->{local_info}{$uri->path};
150
151 0 ▶ if(defined $new) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new) 0 0 0
152 0 ▶ if(!$new || lc($new) eq 'clear') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $new or lc $new eq 'clear') { } 0 0 0
Condition0%0/3
not $new or lc $new eq "clear"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $new or lc $new eq "clear"
not $new lc $new eq "clear"
Truth table0%0/3
not(A) or B
A= not $newB= lc $new eq "clear"
ABresult
1X1
011
000
153 0 ▶ exists $session->{local_info}{$uri->path} and delete $session->{local_info}{$uri->path}
Branch: 1 branch
BranchTrueFalseTotal
exists $session->{"local_info"}{$uri->path} and delete $session->{"local_info"}{$uri->path} 0 0 0
154 }
155 else {
156 0 $session->{local_info}{$uri->path} = $new
157 }
158 }
159
160 $err
161 0 },
162
163 0 ▶ recaptcha_script_tag => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
164 0 ▶ $recaptcha_config
Branch: 1 branch
BranchTrueFalseTotal
$recaptcha_config ? : 0 0 0
165 ? '<script src="https://www.google.com/recaptcha/api.js" async defer></script>'
166 : ''
167 },
168
169 0 ▶ recaptcha_form_item => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
170 $recaptcha_config
171 ? join('',
172 '<div class="g-recaptcha" data-sitekey="',
173 $recaptcha_config->{public_key},
174 0 ▶ '"></div>'
Branch: 1 branch
BranchTrueFalseTotal
$recaptcha_config ? : 0 0 0
175 ) : ''
176 },
177
178 ## All of these work the same:
179 # [% ppRender.TextMarkdown(content) %]
180 # [% ppRender('TextMarkdown',content) %]
181 # [% ppRender('Rapi::Blog::Template::Postprocessor::TextMarkdown',content) %]
182 # [% SET pRen = ppRender('TextMarkdown') %]
183 # [% pRen(content) %]
184 0 ▶ ppRender => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
185 0 ▶ if (scalar(@_) == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ == 0) { } 0 0 0
elsif (scalar @_ == 1) { } 0 0 0
186 0 return Rapi::Blog::Util::ppRender->new
187 }
188 elsif(scalar(@_) == 1) {
189 0 my $pRen = Rapi::Blog::Util::ppRender->new( _post_processor => (shift) );
190 0 ▶ return sub { $pRen->_call_process(@_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
191 0 }
192 else {
193 0 return Rapi::Blog::Util::ppRender->new->_call_process(@_)
194 }
195 }
196 0 };
197
198 #if (my $Scaffold = $self->DispatchRule_for($template)->Scaffold) {
199 # $vars->{scaffold} = $Scaffold->config;
200 #}
201
202 0 return $vars
203
204 1 };
205
206 0 ▶around '_get_admin_template_vars' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
207 0 my ($orig,$self,@args) = @_;
208
209 return {
210 0 %{ $self->$orig(@args) },
211
212 0 ▶ ensure_logged_out => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
213 0 ▶ if (Rapi::Blog::Util->get_User) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rapi::Blog::Util"->get_User) 0 0 0
214 0 RapidApp->active_request_context->logout
215 }
216 ''
217 0 }
218
219
220 0 };
221
222 1 };
223
224
225 # -----------------
226 # Store class API:
227
228
229 1 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
230 1 ▶use Date::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
231 1 ▶use Path::Class qw/file dir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
232
233 0 ▶has 'get_Model', is => 'ro', isa => Maybe[CodeRef], default => sub {undef};
Subroutine __ANON__: not called CC=1 SCAR=1.2
234
235 0 ▶has 'Model', is => 'ro', lazy => 1, default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
236 0 my $self = shift;
237 0 ▶ die "Must supply 'Model' or 'get_Model'" unless $self->get_Model;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_Model 0 0 0
238 0 $self->get_Model->()
239 1 }, isa => Object;
240
241
242 0 ▶sub internal_post_path { (shift)->scaffold_cfg->internal_post_path }
Subroutine internal_post_path: not called CC=1 SCAR=6.9
Pod undocumented
243 0 ▶sub view_wrappers { (shift)->scaffold_cfg->view_wrappers }
Subroutine view_wrappers: not called CC=1 SCAR=6.9
Pod undocumented
244 0 ▶sub default_view_path { (shift)->scaffold_cfg->default_view_path }
Subroutine default_view_path: not called CC=1 SCAR=6.9
Pod undocumented
245 0 ▶sub preview_path { (shift)->scaffold_cfg->preview_path }
Subroutine preview_path: not called CC=1 SCAR=6.9
Pod undocumented
246
247
248 #has 'internal_post_path', is => 'ro', isa => Str, required => 1;
249 ##has 'view_wrappers', is => 'ro', isa => ArrayRef[HashRef], default => sub {[]};
250 #has 'default_view_path', is => 'ro', isa => Maybe[Str], default => sub {undef};
251 ##has 'preview_path', is => 'ro', isa => Maybe[Str], default => sub {undef};
252
253
254 0 ▶sub get_uid {
Subroutine get_uid: not called CC=3 SCAR=24.8
Pod undocumented
255 0 my $self = shift;
256
257 0 ▶ if(my $c = RapidApp->active_request_context) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = "RapidApp"->active_request_context) 0 0 0
258 0 ▶ return $c->user->id if ($c->can('user'));
Branch: 1 branch
BranchTrueFalseTotal
if $c->can("user") 0 0 0
259 }
260
261 0 return 0;
262 }
263
264 0 ▶sub cur_ts {
Subroutine cur_ts: not called CC=1 SCAR=6.9
Pod undocumented
265 0 my $self = shift;
266 0 my $dt = DateTime->now( time_zone => 'local' );
267 0 join(' ',$dt->ymd('-'),$dt->hms(':'));
268 }
269
270 0 ▶sub owns_tpl {
Subroutine owns_tpl: not called CC=1 SCAR=6.9
Pod undocumented
271 0 my ($self, $template) = @_;
272 0 $self->Dispatcher_for($template)->claimed
273 }
274
275 0 ▶sub template_exists {
Subroutine template_exists: not called CC=1 SCAR=6.9
Pod undocumented
276 0 my ($self, $template) = @_;
277 0 $self->Dispatcher_for($template)->exists
278 }
279
280
281 0 ▶sub template_mtime {
Subroutine template_mtime: not called CC=2 SCAR=17.9
Pod undocumented
282 0 my ($self, $template) = @_;
283 0 ▶ $self->_cache_slots->{$template}{template_mtime} //= $self->_template_mtime($template)
Condition0%0/3
$self->_cache_slots->{$template}{"template_mtime"} //= $self->_template_mtime($template)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_cache_slots->{$template}{"template_mtime"} //= $self->_template_mtime($template)
$self->_cache_slots->{$template}{"template_mtime"} $self->_template_mtime($template)
Truth table0%0/3
A //= B
A= $self->_cache_slots->{$template}{"template_mtime"}B= $self->_template_mtime($template)
ABresult
1X1
011
000
284 }
285
286 0 ▶sub _template_mtime {
Subroutine _template_mtime: not called CC=1 SCAR=6.9
287 0 my ($self, $template) = @_;
288
289 0 $self->Dispatcher_for($template)->mtime
290 }
291
292 0 ▶sub template_content {
Subroutine template_content: not called CC=2 SCAR=17.9
Pod undocumented
293 0 my ($self, $template) = @_;
294 0 ▶ $self->_cache_slots->{$template}{template_content} //= $self->_template_content($template)
Condition0%0/3
$self->_cache_slots->{$template}{"template_content"} //= $self->_template_content($template)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_cache_slots->{$template}{"template_content"} //= $self->_template_content($template)
$self->_cache_slots->{$template}{"template_content"} $self->_template_content($template)
Truth table0%0/3
A //= B
A= $self->_cache_slots->{$template}{"template_content"}B= $self->_template_content($template)
ABresult
1X1
011
000
295 }
296
297 0 ▶sub _template_content {
Subroutine _template_content: not called CC=1 SCAR=6.9
298 0 my ($self, $template) = @_;
299
300 0 $self->Dispatcher_for($template)->content
301 }
302
303
304 0 ▶sub create_template {
Subroutine create_template: not called CC=3 SCAR=24.8
Pod undocumented
305 0 my ($self, $template, $content) = @_;
306
307 0 ▶ my $name = $self->Post_name_for($template) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $name = $self->Post_name_for($template) or return undef 0 0 0
308
309 0 my $create = {
310 name => $name,
311 body => $content,
312 published => 1
313 };
314
315 0 ▶ $self->Model->resultset('Post')->create($create) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->Model->resultset('Post')->create($create) ? : 0 0 0
316 }
317
318
319 0 ▶sub update_template {
Subroutine update_template: not called CC=4 SCAR=30.0
Pod undocumented
320 0 my ($self, $template, $content) = @_;
321 0 ▶ my $name = $self->Post_name_for($template) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $name = $self->Post_name_for($template) or return undef 0 0 0
322
323 0 ▶ my $Row = $self->Model->resultset('Post')
Branch: 1 branch
BranchTrueFalseTotal
my $Row = $self->Model->resultset("Post")->search_rs({"me.name", $name})->first or die "Not found!" 0 0 0
324 ->search_rs({ 'me.name' => $name })
325 ->first or die 'Not found!';
326
327 0 ▶ $Row->update({ body => $content }) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Row->update({'body', $content}) ? : 0 0 0
328 }
329
330
331 0 ▶sub delete_template {
Subroutine delete_template: not called CC=4 SCAR=30.0
Pod undocumented
332 0 my ($self, $template) = @_;
333 0 ▶ my $name = $self->Post_name_for($template) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $name = $self->Post_name_for($template) or return undef 0 0 0
334
335 0 ▶ my $Row = $self->Model->resultset('Post')
Branch: 1 branch
BranchTrueFalseTotal
my $Row = $self->Model->resultset("Post")->search_rs({"me.name", $name})->first or die "Not found!" 0 0 0
336 ->search_rs({ 'me.name' => $name })
337 ->first or die 'Not found!';
338
339 0 ▶ $Row->delete ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Row->delete ? : 0 0 0
340 }
341
342 0 ▶around 'get_template_format' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
343 0 my ($orig, $self, @args) = @_;
344 0 my $template = join('/',@args);
345
346 # By rule all local tempaltes (Post rows) are markdown
347 0 ▶ return $self->Post_name_for($template)
Branch: 1 branch
BranchTrueFalseTotal
$self->Post_name_for($template) ? : 0 0 0
348 ? 'markdown'
349 : $self->$orig(@args)
350 1 };
351
352 0 ▶sub list_templates {
Subroutine list_templates: not called CC=1 SCAR=6.9
Pod undocumented
353 0 my $self = shift;
354 0 [ map { join('',$self->internal_post_path,$_) } $self->Model->resultset('Post')->get_column('name')->all ]
355 }
356
357 0 ▶around 'template_post_processor_class' => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
358 0 my ($orig,$self,@args) = @_;
359 0 my $template = join('/',@args);
360
361 # By rule, never use a post processor with a wrapper view:
362 0 ▶ return undef if $self->Dispatcher_for($template)->find_parent_type('ViewWrapper');
Branch: 1 branch
BranchTrueFalseTotal
if $self->Dispatcher_for($template)->find_parent_type("ViewWrapper") 0 0 0
363
364 # Render markdown with our MarkdownElement post-processor if the next template
365 # (i.e. which is including us) is one of our wrapper/views. This will defer
366 # rendering of markdown to the client-side with the marked.js library
367 0 ▶ if($self->process_Context && $self->get_template_format($template) eq 'markdown') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->process_Context and $self->get_template_format($template) eq "markdown") 0 0 0
Condition0%0/3
$self->process_Context and $self->get_template_format($template) eq "markdown"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->process_Context and $self->get_template_format($template) eq "markdown"
$self->process_Context $self->get_template_format($template) eq "markdown"
Truth table0%0/3
A and B
A= $self->process_ContextB= $self->get_template_format($template) eq "markdown"
ABresult
0X0
100
111
368 0 ▶ if(my $next_template = $self->process_Context->next_template) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $next_template = $self->process_Context->next_template) 0 0 0
369 0 ▶ if($self->Dispatcher_for($next_template)->is_type('ViewWrapper')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->Dispatcher_for($next_template)->is_type("ViewWrapper")) 0 0 0
370 0 return 'Rapi::Blog::Template::Postprocessor::MarkdownElement'
371 }
372 }
373 }
374
375 0 return $self->$orig(@args)
376 1 };
377
378
379 0 ▶sub template_psgi_response {
Subroutine template_psgi_response: not called CC=1 SCAR=6.9
Pod undocumented
380 0 my ($self, $template, $c) = @_;
381 0 $self->Dispatcher_for($template)->maybe_psgi_response
382 }
383
384
385 1 1;
« lib/Rapi/Blog/Module/SectionTree.pm ↑ Summary lib/Rapi/Blog/Scaffold/ViewWrapper.pm »