Mojito.pm

filter: Statementstmt 12.8% 27 / 210 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 28.5% 8 / 28 Podpod 100% 19 / 19 totaltotal 17.8% 54 / 303 CC 21 SCAR 26.9
CC
21
Cov
11%
preview_page
42.0
epub_collection
42.0
search
20.0
CRAP 14.7
« Mojito/Model/Doc/Elasticsearch.pm ↑ Summary Mojito/Model/Doc/Deep.pm »
1 1 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Mojito;
3 1 $Mojito::VERSION = '0.25';
4 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Dumper::Concise;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 extends 'Mojito::Page';
11  
12 =head1 NAME
13  
14 Mojito - A Web Document System
15  
16 =head1 SYNOPSIS
17  
18 use Mojito::Model::Config;
19 my $mojito = Mojito->new(config => Mojito::Model::Config->new->config);
20 my $page_id = '123456781234567812345678';
21 my $rendered_page = $mojito->view_page({id => $page_id});
22  
23 # You might want to checkout one of the applications in app/
24 # For example: 'plackup -Ilib' starts up a Web::Simple instance of Mojito
25  
26 =head1 DESCRIPTION
27  
28 Mojito is a web document system that enables individuals to easily author
29 HTML5 compliant documents. It provides a source editor for various
30 markup languages along with a near realtime view pane. It allows for the
31 intermixing of different source formats.
32  
33 =head1 Attributes
34  
35 =head2 base_url
36  
37 Base of the application used for creating internal links.
38  
39 =cut
40  
41 1 has base_url => ( is => 'rw', );
42  
43 =head2 username
44  
45 Authenticated (Digest Auth) user name (aka REMOTE_USER)
46  
47 =cut
48  
49 1 has username => (
50 is => 'rw',
51 );
52  
53 1 has bench_fixture => ( is => 'ro', lazy => 1, builder => '_build_bench_fixture');
54  
55 =head1 Methods
56  
57 =head2 create_page
58  
59 Create a new page and return the url to redirect to, namely the page in edit mode.
60 We might change this to view mode if demand persuades.
61  
62 =cut
63  
64 0 ▶sub create_page {
Subroutine create_page: not called CC=2 SCAR=17.9
Pod documented
65 0 my ( $self, $params ) = @_;
66  
67 # We need to get some content into the delegatee
68 0 $self->parser->page($params->{content});
69  
70 0 my $page_struct = $self->page_structure;
71 # Load some parts to the page_struct
72 0 $page_struct->{default_format} = $params->{wiki_language};
73 0 $page_struct->{page_html} = $self->render_page($page_struct);
74 0 $page_struct->{body_html} = $self->render_body($page_struct);
75 0 $page_struct->{title} = $self->intro_text( $page_struct->{body_html} );
76 0 ▶ if ($params->{public}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"public"}) 0 0 0
77 0 $page_struct->{public} = 1;
78 }
79 0 my $id = $self->create($page_struct);
80 0 $params->{id} = $id;
81 # Put into repo
82 0 $params->{username} = $self->username;
83 0 $self->commit_page($page_struct, $params);
84  
85 0 return $self->base_url . 'page/' . $id . '/edit';
86 }
87  
88 =head2 preview_page
89  
90 AJAX preview of a page (parse and render, save when button pressed)
91  
92 =cut
93  
94 0 ▶sub preview_page {
Subroutine preview_page: not called CC=6 SCAR=37.4
Pod documented
95 0 my ( $self, $params ) = @_;
96  
97 0 $self->parser->page($params->{content});
98 0 $self->parser->default_format($params->{wiki_language});
99 0 my $page_struct = $self->page_structure;
100 0 ▶ if ( $params->{extra_action}
Branch: 2 branches
BranchTrueFalseTotal
if ($params->{'extra_action'} and $params->{'extra_action'} eq 'save' and $params->{'mongo_id'}) { } 0 0 0
elsif ($params->{'mongo_id'}) { } 0 0 0
Condition0%0/6
$params->{"extra_action"} and $params->{"extra_action"} eq "save" and $params->{"mongo_id"}
!ll&&!rl&&r
000
$params->{"extra_action"} and $params->{"extra_action"} eq "save"
!ll&&!rl&&r
000
MC/DC0%0/3
$params->{"extra_action"} and $params->{"extra_action"} eq "save" and $params->{"mongo_id"}
$params->{"extra_action"} $params->{"extra_action"} eq "save" $params->{"mongo_id"}
Truth table0%0/4
A and B and C
A= $params->{"extra_action"}B= $params->{"extra_action"} eq "save"C= $params->{"mongo_id"}
ABCresult
0XX0
10X0
1100
1111
101 && ( $params->{extra_action} eq 'save' )
102 && ( $params->{'mongo_id'} ) )
103 {
104 0 $page_struct->{page_html} = $self->render_page($page_struct);
105 0 $page_struct->{body_html} = $self->render_body($page_struct);
106 0 $page_struct->{title} = $self->intro_text( $page_struct->{body_html} );
107 0 $self->update( $params->{'mongo_id'}, $page_struct );
108 }
109 elsif ( $params->{'mongo_id'} ) {
110  
111 # Auto update this stuff so the user doesn't have to even think about clicking save button
112 # TODO: add title, page and body html to page_struct like above.
113 # Do we even need these two branches given that we're autosaving now.
114 # TODO: on new page, insert to get an id then update to that from the start
115 0 ▶ $page_struct->{title} = $params->{page_title}||'no title';
Condition0%0/2
$params->{'page_title'} || 'no title'
l!l
00
MC/DC0%0/1
$params->{'page_title'} || 'no title'
$params->{'page_title'}
Truth table0%0/2
A
A= $params->{'page_title'}
Aresult
11
00
116 0 $self->update( $params->{'mongo_id'}, $page_struct );
117 }
118  
119 0 my $rendered_content = $self->render_body($page_struct);
120 0 my $response_href = { rendered_content => $rendered_content, message => $page_struct->{message} };
121  
122 0 return $response_href;
123 }
124  
125 =head2 update_page
126  
127 Update a page given: content, id and base_url
128  
129 =cut
130  
131 0 ▶sub update_page {
Subroutine update_page: not called CC=3 SCAR=24.8
Pod documented
132 0 my ( $self, $params ) = @_;
133  
134 0 $self->parser->page($params->{content});
135 0 $self->parser->default_format($params->{wiki_language});
136 0 my $page = $self->page_structure;
137  
138 # Store rendered parts as well. May as well until proven wrong.
139 0 $page->{page_html} = $self->render_page($page);
140 0 $page->{body_html} = $self->render_body($page);
141 0 $page->{title} = $self->intro_text( $page->{body_html} );
142  
143 # Add a feed if there is such a param
144 0 ▶ if (my $feeds = $params->{feeds}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $feeds = $params->{"feeds"}) 0 0 0
145 # Allow : to separate multiple feeds. e.g. ?feeds=ironman:chatterbox
146 0 my @feeds = split ':', $feeds;
147 0 $page->{feeds} = [@feeds];
148 # A document that is part of a feed is considered public by default
149 0 $page->{public} = 1;
150 }
151 0 ▶ if ($params->{public}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"public"}) 0 0 0
152 0 $page->{public} = 1;
153 }
154  
155 # Update the list of collections to which this doc belongs
156 0 $self->collector->editer->update_collection_membership($params);
157  
158 # Save page to db
159 0 $self->update( $params->{id}, $page );
160 # Commit revison to git repo
161 # add username to params so it can used in the commit
162 0 $params->{username} = $self->username;
163 0 $self->commit_page($page, $params);
164 0 return $self->base_url . 'page/' . $params->{id};
165 }
166  
167 =head2 edit_page_form
168  
169 Present the form with a page ready to be edited.
170  
171 =cut
172  
173 0 ▶sub edit_page_form {
Subroutine edit_page_form: not called CC=1 SCAR=6.9
Pod documented
174 0 my ( $self, $params ) = @_;
175  
176 0 my $page = $self->read( $params->{id} );
177 0 my $rendered_content = $self->render_body($page);
178  
179 0 return $self->fillin_edit_page( $page, $rendered_content, $params->{id} );
180 }
181  
182 =head2 view_page
183  
184 Given a page id, we retrieve its page from the db and return
185 the HTML form of the page to the browser.
186  
187 =cut
188  
189 0 ▶sub view_page {
Subroutine view_page: not called CC=1 SCAR=6.9
Pod documented
190 0 my ( $self, $params ) = @_;
191  
192 0 my $page = $self->read( $params->{id} );
193 0 my $rendered_page = $self->render_page($page);
194 0 my $links = $self->get_recent_links;
195 0 my $collections = $self->view_collections_index;
196  
197 # Change class on view_area when we're in view mode.
198 0 $rendered_page =~ s/(<section\s+id="view_area").*?>/$1 class="view_area_view_mode">/si;
199 # Fill-in recent area
200 0 $rendered_page =~ s/(<section\s+id="recent_area".*?>)<\/section>/$1${links}<\/section>/si;
201 # Fill-in collections area
202 0 $rendered_page =~ s/(<section\s+id="collections_area".*?>)<\/section>/$1${collections}<\/section>/si;
203  
204 0 return $rendered_page;
205 }
206  
207 =head2 view_page_public
208  
209 Given a page id, we retrieve its page from the db and return
210 the HTML form of the page to the browser. This method is much
211 like the view_page() method is setup for public pages
212 (ones that do not require authentication).
213  
214 =cut
215  
216 0 ▶sub view_page_public {
Subroutine view_page_public: not called CC=2 SCAR=17.9
Pod documented
217 0 my ( $self, $params ) = @_;
218 0 my $page = $self->read( $params->{id} );
219 0 ▶ return "Page is not public" if not $page->{public};
Branch: 1 branch
BranchTrueFalseTotal
unless $page->{"public"} 0 0 0
220 # TODO: Use body_html unless otherwise specified
221 # return $self->wrap_page($page->{body_html}, $page->{title});
222 0 return $self->wrap_page($self->render_body($page), $page->{title});
223 }
224  
225 =head2 view_page_collected
226  
227 Given a page id and a collection id we retrieve the collected page source
228 from the db and return it as an HTML rendered page to the browser. This method
229 is much like the view_page() method, but is setup for viewing pages in a collection
230 with a collection navigation: next, previous, index (toc)
231  
232 =cut
233  
234 0 ▶sub view_page_collected {
Subroutine view_page_collected: not called CC=2 SCAR=17.9
Pod documented
235 0 my ( $self, $params ) = @_;
236  
237 0 my $page = $self->read( $params->{page_id} );
238 0 my $rendered_page = $self->render_page($page);
239  
240 # Change class on view_area when we're in view mode.
241 0 $rendered_page =~
242 s/(<section\s+id="view_area").*?>/$1 class="view_area_view_mode">/si;
243  
244 # Strip out Edit and New links (even though they are Auth::Digest Protected)
245 # Remove edit, new links and the recent area
246 0 ▶ if(not $self->config->{username}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->config->{"username"}) 0 0 0
247 0 $rendered_page =~ s/<nav id="edit_link".*?><\/nav>//sig;
248 }
249 0 $rendered_page =~ s/<nav id="new_link".*?>.*?<\/nav>//sig;
250 0 $rendered_page =~ s/<section id="recent_area".*?><\/section>//si;
251 0 $rendered_page =~ s/<section id="publish_area">.*?<\/section>//si;
252 0 $rendered_page =~ s/<section id="collections_area"><\/section>//si;
253 0 $rendered_page =~ s/<section id="search_area">.*?<\/section>//si;
254 0 $rendered_page =~ s/<section id="calendar_area">.*?<\/section>//si;
255 # Fill-in collection navigation area
256 0 my $collection_nav = $self->view_collection_nav( $params );
257 0 $rendered_page =~ s/(<section\s+id="collection_nav_area".*?>)<\/section>/$1${collection_nav}<\/section>/si;
258  
259 0 return $rendered_page;
260 }
261  
262 =head2 view_home_page
263  
264 Create the view for the base of the application.
265  
266 =cut
267  
268 0 ▶sub view_home_page {
Subroutine view_home_page: not called CC=1 SCAR=6.9
Pod documented
269 0 my $self = shift;
270  
271 0 my $output = $self->home_page;
272 0 my $links = $self->get_recent_links;
273 0 $output =~ s/(<section\s+id="recent_area".*?>)<\/section>/$1${links}<\/section>/si;
274  
275 0 return $output;
276 }
277  
278 =head2 view_page_diff
279  
280 View the diff of a page.
281  
282 =cut
283  
284 0 ▶sub view_page_diff {
Subroutine view_page_diff: not called CC=1 SCAR=6.9
Pod documented
285 0 my ( $self, $params ) = @_;
286  
287 0 my $head = '
288 <!doctype html>
289 <html>
290 <head>
291 <meta charset=utf-8>
292 <meta http-equiv="powered by" content="Mojito development version" />
293 <title>Mojito Syntax Highlighting - via JavaScript</title>
294 <script src=http://missoula.org/mojito/jquery/jquery_min.js></script>
295 <script src=http://missoula.org/mojito/javascript/render_page.js></script>
296 <script src=http://missoula.org/mojito/javascript/style.js></script>
297 <script src=http://missoula.org/mojito/syntax_highlight/prettify.js></script>
298 <script src=http://missoula.org/mojito/jquery/autoresize_min.js></script>
299 <script src=http://missoula.org/mojito/jquery/jquery-ui-1.8.11.custom.min.js></script>
300 <script src=http://missoula.org/mojito/SHJS/sh_main.min.js></script>
301 <script src=http://missoula.org/mojito/SHJS/sh_diff.min.js></script>
302 <link href=http://missoula.org/mojito/css/ui-lightness/jquery-ui-1.8.11.custom.css type=text/css rel=stylesheet />
303 <link href=http://missoula.org/mojito/syntax_highlight/prettify.css type=text/css rel=stylesheet />
304 <link href=http://missoula.org/mojito/SHJS/sh_rand01.min.css type=text/css rel=stylesheet />
305 <link href=http://missoula.org/mojito/css/mojito.css type=text/css rel=stylesheet />
306  
307 </head>
308 <body class="html_body">
309 ';
310 0 my $diff = '<pre class="sh_diff">' . "\n" . $self->diff_page($params->{id}, $params->{m}, $params->{n}) . "\n</pre>";
311 0 my $foot = "\n</body></html>";
312 0 return $head . $diff . $foot;
313 }
314  
315 =head2 search
316  
317 Search the documents for a single word.
318  
319 =cut
320  
321 0 ▶sub search {
Subroutine search: not called CC=4 SCAR=30.0
Pod documented
322 0 my ( $self, $params ) = @_;
323  
324 0 my $base_url = $self->base_url;
325 0 my $hit_hashref= $self->search_word($params->{word});
326 0 ▶ if (not scalar keys %{$hit_hashref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %{$hit_hashref;}) 0 0 0
327 0 my $output = "No matches for: <b>" . $params->{word} . "</b><br />&nbsp;\n";
328 0 $output .= "<nav style='font-size:0.8em;'>Want a <a href='${base_url}page'>new page?</a></nav>";
329 0 return $output;
330 }
331 # Get the full page and extract the title for display.
332 # Rework hit_has from HashRef to HashRef[HashRef] so we can store both hit counts and a title.
333 0 my $link_data = {};
334 0 foreach my $page_id (keys %{$hit_hashref}) {
335 0 my $page = $self->read($page_id);
336 0 ▶ $link_data->{$page_id}->{title} = $page->{title}||'no title';
Condition0%0/2
$page->{'title'} || 'no title'
l!l
00
MC/DC0%0/1
$page->{'title'} || 'no title'
$page->{'title'}
Truth table0%0/2
A
A= $page->{'title'}
Aresult
11
00
337 0 $link_data->{$page_id}->{times_found} = $hit_hashref->{$page_id};
338 }
339 0 my @search_hits = map { "<a href='${base_url}page/$_'>$link_data->{$_}->{title} <span style='font-size: 0.82em;'>($link_data->{$_}->{times_found})</span></a>" }
340 0 sort {$link_data->{$b}->{times_found} <=> $link_data->{$a}->{times_found}} keys %{$link_data};
341 0 return join "<br />\n", @search_hits;
342 }
343  
344 =head2 collect
345  
346 Collect documents. The id for each document submitted will be put into
347 a list of document ids stored in the 'collection' collection. Yeah, that
348 may seem strange at first, but the idea is we want to allow for arbitrary
349 sets of documents from the notes collection. We construct these sets by creating
350 a list (array) of the corresponding document ids and inserting this "document"
351 into the "collection" collection.
352  
353 For example, the Beer collection document could look like:
354  
355 {
356 collection_name => 'Beer',
357 documents => [$some_doc_id, $another_doc_id, .. $last_doc_id]
358 permissions => { owner => 'rwx', group=> 'r', world => 'r' }
359 }
360  
361 where the doc ids are the usual mongodb auto-generated id.
362  
363 Return the /collections URL to which we'll redirect.
364  
365 =cut
366  
367 0 ▶sub collect {
Subroutine collect: not called CC=1 SCAR=6.9
Pod documented
368 0 my ( $self, $params ) = @_;
369
370 # Create page in DB
371 0 $params->{id}= $self->collector->create($params);
372
373 # Put into repo
374 0 $params->{username} = $self->username;
375 0 my $page_source = join "\n", @{$params->{collected_page_ids}};
376 0 $page_source .= "\n";
377 0 my $page_struct = { page_source => $page_source };
378 0 $self->commit_page($page_struct, $params);
379  
380 0 return $self->base_url . 'collections';
381 }
382  
383 =head2 sort_collection
384  
385 Store a sorted list of pages.
386 Return the /collections URL to which we'll redirect.
387  
388 =cut
389  
390 0 ▶sub sort_collection {
Subroutine sort_collection: not called CC=1 SCAR=6.9
Pod documented
391 0 my ( $self, $params ) = @_;
392 0 $self->collector->create($params);
393 0 return $self->base_url . 'collections';
394 }
395  
396 =head2 merge_collection
397  
398 Given a collection id, we concatentate all its page into one.
399  
400 =cut
401  
402 0 ▶sub merge_collection {
Subroutine merge_collection: not called CC=2 SCAR=14.4
Pod documented
403 0 my ( $self, $params ) = @_;
404  
405 1 ▶ use Mojito::Filter::MojoMojo::Converter;
Subroutine BEGIN: called CC=1 SCAR=0.0
406 # Get the page ids for the collection.
407 0 my $collection_struct = $self->collector->read($params->{collection_id});
408 0 my @page_ids = @{$collection_struct->{collected_page_ids}};
409 0 my $rendered_bodies;
410 0 foreach my $page_id (@page_ids) {
411 0 $rendered_bodies .= $self->render_body($self->read($page_id));
412 }
413 0 my $collection_title = $collection_struct->{collection_name};
414 0 $collection_title = "<h1 class='collection_title'>$collection_title</h1>";
415 0 my $toc = "\n{{toc 1-}}\n";
416 0 $rendered_bodies = $collection_title . $toc . $rendered_bodies;
417 0 my $convert = Mojito::Filter::MojoMojo::Converter->new( content => $rendered_bodies );
418 0 $convert->toc;
419  
420 0 return $self->wrap_page($convert->content, $collection_struct->{collection_name});
421 }
422  
423 =head2 delete_collection
424  
425 Given a collection id:
426 * Delete it from the mongo DB
427 Return the URL to of the collections index
428  
429 =cut
430  
431 0 ▶sub delete_collection {
Subroutine delete_collection: not called CC=1 SCAR=6.9
Pod documented
432 0 my ( $self, $params ) = @_;
433 0 $self->collector->delete($params->{collection_id});
434 0 return $self->base_url . 'collections';
435 }
436  
437 =head2 epub_collection
438  
439 Create and .epub document from the given collection.
440  
441 =cut
442  
443 0 ▶sub epub_collection {
Subroutine epub_collection: not called CC=6 SCAR=37.4
Pod documented
444 0 my ($self, $params) = @_;
445
446 0 my $authors = $self->get_author_for($params->{collection_id});
447  
448 0 my $collection_html = $self->merge_collection($params);
449 # Strip out HTML::TOC
450 0 $collection_html =~ s/<div class="toc">.*?<\/div>//sig;
451
452 my $tmp_html_file = Path::Class::file(File::Spec->tmpdir, 'collection_'
453 . $params->{collection_id}
454 0 . '.html');
455 0 ▶ open my $html_file, '>', $tmp_html_file or die "Can't open html file: $tmp_html_file";
Branch: 1 branch
BranchTrueFalseTotal
open my $html_file, ">", $tmp_html_file or die "Can't open html file: $tmp_html_file" 0 0 0
456 0 print $html_file $collection_html;
457 0 close $html_file;
458  
459 my $tmp_epub_file = Path::Class::file(File::Spec->tmpdir, 'collection_'
460 . $params->{collection_id}
461 0 . '.epub');
462 0 my $converter = $self->tmpl->config->{ebook_converter};
463
464 # Check that we have a converter defined and that it exists on the file system.
465 0 ▶ return if !($converter && -e $converter);
Branch: 1 branch
BranchTrueFalseTotal
unless $converter and -e $converter 0 0 0
Condition0%0/3
$converter and -e $converter
!ll&&!rl&&r
000
MC/DC0%0/2
$converter and -e $converter
$converter -e $converter
Truth table0%0/3
A and B
A= $converterB= -e $converter
ABresult
0X0
100
111
466 # TODO Handle Exceptions
467 0 `$converter $tmp_html_file $tmp_epub_file --authors "${authors}" --level2-toc //h:h2 --level1-toc //h:h1 --extra-css ".html_body {background-color: white;}"`;
468 0 ▶ open my $epub_file, '<', $tmp_epub_file or die "Can't open epub file: $tmp_epub_file";
Branch: 1 branch
BranchTrueFalseTotal
open my $epub_file, "<", $tmp_epub_file or die "Can't open epub file: $tmp_epub_file" 0 0 0
469 0 my $epub;
470 0 ▶ while (<$epub_file>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $epub_file)) 0 0 0
471 0 $epub .= $_;
472 }
473 0 return $epub;
474 }
475  
476 =head2 delete_page
477  
478 Given a page id:
479 * Delete it from the mongo DB
480 * Remove it from the git repo
481 Return the URL to recent (maybe home someday?)
482  
483 =cut
484  
485 0 ▶sub delete_page {
Subroutine delete_page: not called CC=1 SCAR=6.9
Pod documented
486 0 my ( $self, $params ) = @_;
487  
488 0 $self->delete($params->{id});
489 0 $self->rm_page($params->{id});
490  
491 0 return $self->base_url . 'recent';
492 }
493  
494 =head2 publish_page
495  
496 Publish a page - Currently this means POST to a MM instance.
497  
498 =cut
499  
500 0 ▶sub publish_page {
Subroutine publish_page: not called CC=1 SCAR=6.9
Pod documented
501 0 my ( $self, $params ) = @_;
502
503 0 my $doc = $self->read($params->{id});
504 0 my $content = $doc->{page_source};
505 0 $self->publisher->content($content);
506 0 $self->publisher->target_base_url($params->{target_base_url});
507 0 $self->publisher->target_page($params->{name});
508 0 $self->publisher->user($params->{user});
509 0 $self->publisher->password($params->{password});
510 0 my $result = $self->publisher->publish;
511 # return redirect location
512 0 my $redirect_url = $self->publisher->target_base_url . $self->publisher->target_page;
513 0 my $response_href = { redirect_url => $redirect_url, result => $result };
514 }
515  
516 =head2 feed_page
517  
518 Get a feed in a particular format
519  
520 =cut
521  
522 0 ▶sub feed_page {
Subroutine feed_page: not called CC=2 SCAR=17.9
Pod documented
523 0 my ( $self, $params ) = @_;
524 0 my ($feed, $format) = @{$params}{qw/feed_name feed_format/};
525 0 ▶ if ($format eq 'atom') {
Branch: 1 branch
BranchTrueFalseTotal
if ($format eq "atom") 0 0 0
526 0 return $self->get_atom_feed($feed);
527 }
528 0 return;
529 }
530  
531 =head2 bench
532  
533 A path for benchmarking to get an basic idea of performance.
534  
535 =cut
536  
537 0 ▶sub bench {
Subroutine bench: not called CC=1 SCAR=6.9
Pod documented
538 0 my $self = shift;
539  
540 0 $self->parser->page($self->bench_fixture);
541 0 my $page_struct = $self->page_structure;
542  
543 # Let's run our bench stuff in its own DB to keep it separate from
544 # real (user created) pages.
545 0 $self->editer->db_name('bench');
546 0 $self->create($page_struct);
547  
548 0 return $self->render_page($page_struct);
549 }
550  
551 0 ▶sub _build_bench_fixture {
Subroutine _build_bench_fixture: not called CC=1 SCAR=6.9
552 0 my $self = shift;
553  
554 0 my $implicit_section = <<'END';
555 h1. Greetings
556  
557 <sx c=Perl>
558 use Modern::Perl;
559 say 'something';
560 </sx>
561  
562 Implicit Section
563  
564 <sx c="JavaScript">
565 function () { var one = 1 }
566 </sx>
567  
568 Stuff After
569  
570 END
571 0 return $implicit_section;
572 }
573  
574 1 ▶BEGIN { require 5.010001; }
Subroutine BEGIN: called CC=1 SCAR=0.0
575  
576 1 1;
577 __END__
« Mojito/Model/Doc/Elasticsearch.pm ↑ Summary Mojito/Model/Doc/Deep.pm »