| 1 | 4 | ▶ | use strictures 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | package Mojito::Template; | ||||||||||||||||||||||||||||
| 3 | 4 | $Mojito::Template::VERSION = '0.25'; | |||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Mojito::Model::Link; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Mojito::Collection::CRUD; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Mojito::Page::Publish; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Syntax::Keyword::Junction qw/ any /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use HTML::Entities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Data::Dumper::Concise; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | with('Mojito::Template::Role::Javascript'); | |||||||||||||||||||||||||||
| 16 | 4 | with('Mojito::Template::Role::CSS'); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 Name | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Mojito::Template - the main HTML class | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 4 | has 'template' => ( | |||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||
| 26 | lazy => 1, | ||||||||||||||||||||||||||||
| 27 | builder => '_build_template', | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | has 'page_id' => ( | |||||||||||||||||||||||||||
| 31 | is => 'rw', | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # Allow Template to receive a db attribute upon construction | ||||||||||||||||||||||||||||
| 35 | # currently it's passed to the $mojito->tmpl handler | ||||||||||||||||||||||||||||
| 36 | 4 | has 'db' => ( is => 'ro', lazy => 1); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | has 'base_url' => ( is => 'rw', ); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | has linker => ( | ||||||||||||||||||||||||||||
| 41 | is => 'ro', | ||||||||||||||||||||||||||||
| 42 | 2 | ▶ | isa => sub { die "Need a Link Model object. Have ref($_[0]) instead." unless $_[0]->isa('Mojito::Model::Link') }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 4 | lazy => 1, | |||||||||||||||||||||||||||
| 44 | handles => { | ||||||||||||||||||||||||||||
| 45 | recent_links_view => 'get_recent_links', | ||||||||||||||||||||||||||||
| 46 | collection_page_view => 'view_collection_page', | ||||||||||||||||||||||||||||
| 47 | select_collection_pages_view => 'view_selectable_page_list', | ||||||||||||||||||||||||||||
| 48 | sort_collection_pages_view => 'view_sortable_page_list', | ||||||||||||||||||||||||||||
| 49 | collections_index_view => 'view_collections_index', | ||||||||||||||||||||||||||||
| 50 | get_docs_for_month => 'get_docs_for_month', | ||||||||||||||||||||||||||||
| 51 | get_collection_list => 'get_collections_index_link_data', | ||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||
| 53 | writer => '_set_linker', | ||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | has collector => ( | ||||||||||||||||||||||||||||
| 57 | is => 'ro', | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | isa => sub { die "Need a Collection::CRUD object" unless $_[0]->isa('Mojito::Collection::CRUD') }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | 'default' => sub { my $self = shift; return Mojito::Collection::CRUD->new(config => $self->config, db => $self->db) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 60 | 4 | lazy => 1, | |||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 4 | has 'home_page' => ( | |||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||
| 65 | lazy => 1, | ||||||||||||||||||||||||||||
| 66 | builder => '_build_home_page', | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | has 'collect_page_form' => ( | |||||||||||||||||||||||||||
| 70 | is => 'ro', | ||||||||||||||||||||||||||||
| 71 | lazy => 1, | ||||||||||||||||||||||||||||
| 72 | builder => '_build_collect_page_form', | ||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 4 | has 'collections_index' => ( | |||||||||||||||||||||||||||
| 76 | is => 'ro', | ||||||||||||||||||||||||||||
| 77 | lazy => 1, | ||||||||||||||||||||||||||||
| 78 | builder => '_build_collections_index', | ||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 4 | has 'recent_links' => ( | |||||||||||||||||||||||||||
| 82 | is => 'ro', | ||||||||||||||||||||||||||||
| 83 | lazy => 1, | ||||||||||||||||||||||||||||
| 84 | builder => '_build_recent_links', | ||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 4 | has 'wiki_language_selection' => ( | |||||||||||||||||||||||||||
| 88 | is => 'ro', | ||||||||||||||||||||||||||||
| 89 | lazy => 1, | ||||||||||||||||||||||||||||
| 90 | builder => '_build_wiki_language_selection', | ||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||
| 92 | has js_css_html => ( | ||||||||||||||||||||||||||||
| 93 | is => 'ro', | ||||||||||||||||||||||||||||
| 94 | isa => Value, | ||||||||||||||||||||||||||||
| 95 | lazy => 1, | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | default => sub { my $self = shift; join "\n", @{$self->javascript_html}, @{$self->css_html} } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 97 | 4 | ); | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 4 | has page_wrap_end => ( | |||||||||||||||||||||||||||
| 100 | is => 'ro', | ||||||||||||||||||||||||||||
| 101 | lazy => 1, | ||||||||||||||||||||||||||||
| 102 | builder => '_build_page_wrap_end', | ||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub _build_template { | ||||||||||||||||||||||||||
|
Subroutine
_build_template: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | my $base_url = $self->base_url; | |||||||||||||||||||||||||||
| 109 | 0 | my $mojito_version = $self->config->{VERSION}; | |||||||||||||||||||||||||||
| 110 | 0 | my $wiki_language_selection = $self->wiki_language_selection; | |||||||||||||||||||||||||||
| 111 | 0 | my $js_css = $self->js_css_html; | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $page_id = $self->page_id||''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->page_id || ''
MC/DC0%0/1
$self->page_id || ''
$self->page_id
Truth table0%0/2
A
A= $self->page_id
| |||||||||||||||||||||||||||||
| 113 | 0 | my $publisher = Mojito::Page::Publish->new(config => $self->config); | |||||||||||||||||||||||||||
| 114 | 0 | my $publish_form = ''; | |||||||||||||||||||||||||||
| 115 | 0 | ▶ | $publish_form = $publisher->publish_form||'' if $page_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$publisher->publish_form || ''
MC/DC0%0/1
$publisher->publish_form || ''
$publisher->publish_form
Truth table0%0/2
A
A= $publisher->publish_form
| |||||||||||||||||||||||||||||
| 116 | 0 | my @collections_for_page = $self->collector->editer->collections_for_page($page_id); | |||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $collection_list = $self->get_collection_list||[]; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_collection_list || []
MC/DC0%0/1
$self->get_collection_list || []
$self->get_collection_list
Truth table0%0/2
A
A= $self->get_collection_list
| |||||||||||||||||||||||||||||
| 118 | 0 | my $collection_size = scalar @{$collection_list} + 1; | |||||||||||||||||||||||||||
| 119 | 0 | my $collection_options = "<select id='collection_select' name='collection_select' | |||||||||||||||||||||||||||
| 120 | multiple='multiple' size='${collection_size}' form='editForm' style='font-size: 1.00em; display:none;' >\n"; | ||||||||||||||||||||||||||||
| 121 | 0 | $collection_options .= "<option value='0'>- No Collection -</option>\n"; | |||||||||||||||||||||||||||
| 122 | 0 | foreach my $collection (@{$collection_list}) { | |||||||||||||||||||||||||||
| 123 | 0 | $collection_options .= "<option value='$collection->{id}'"; | |||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($collection->{id} eq any(@collections_for_page)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 0 | $collection_options .= " selected='selected' "; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | 0 | $collection_options .= ">$collection->{title}</option>\n"; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | 0 | $collection_options .= "</select>\n"; | |||||||||||||||||||||||||||
| 130 | 0 | my $edit_page = <<"END_HTML"; | |||||||||||||||||||||||||||
| 131 | <!doctype html> | ||||||||||||||||||||||||||||
| 132 | <html> | ||||||||||||||||||||||||||||
| 133 | <head> | ||||||||||||||||||||||||||||
| 134 | <meta charset=utf-8> | ||||||||||||||||||||||||||||
| 135 | <meta http-equiv="powered by" content="Mojito $mojito_version" /> | ||||||||||||||||||||||||||||
| 136 | <title>Mojito page</title> | ||||||||||||||||||||||||||||
| 137 | $js_css | ||||||||||||||||||||||||||||
| 138 | <script></script> | ||||||||||||||||||||||||||||
| 139 | <style></style> | ||||||||||||||||||||||||||||
| 140 | </head> | ||||||||||||||||||||||||||||
| 141 | <body class="html_body"> | ||||||||||||||||||||||||||||
| 142 | <header> | ||||||||||||||||||||||||||||
| 143 | <nav id="edit_link" class="edit_link"></nav> | ||||||||||||||||||||||||||||
| 144 | <nav id="new_link" class="new_link"> <a href=${base_url}page>New</a></nav> | ||||||||||||||||||||||||||||
| 145 | </header> | ||||||||||||||||||||||||||||
| 146 | <section id="message_area"></section> | ||||||||||||||||||||||||||||
| 147 | <section id="collection_nav_area"></section> | ||||||||||||||||||||||||||||
| 148 | <article id="body_wrapper"> | ||||||||||||||||||||||||||||
| 149 | <input type="hidden" id ="page_id" name="page_id" value="$page_id" /> | ||||||||||||||||||||||||||||
| 150 | <section id="edit_area"> | ||||||||||||||||||||||||||||
| 151 | <span style="font-size: 0.82em;"><label id="feeds_label">feeds+</label> | ||||||||||||||||||||||||||||
| 152 | <input id="feeds" name="feeds" form="editForm" value="" size="12" style="font-size: 1.00em; display:none;" /> | ||||||||||||||||||||||||||||
| 153 | </span> | ||||||||||||||||||||||||||||
| 154 | <span style="font-size: 0.82em;"> | ||||||||||||||||||||||||||||
| 155 | <label id="collection_label">collections+</label> | ||||||||||||||||||||||||||||
| 156 | $collection_options | ||||||||||||||||||||||||||||
| 157 | </span> | ||||||||||||||||||||||||||||
| 158 | <form id="editForm" action="" accept-charset="UTF-8" method="post"> | ||||||||||||||||||||||||||||
| 159 | <div id="wiki_language"> | ||||||||||||||||||||||||||||
| 160 | $wiki_language_selection | ||||||||||||||||||||||||||||
| 161 | </div> | ||||||||||||||||||||||||||||
| 162 | <input id="mongo_id" name="mongo_id" type="hidden" form="editForm" value="" /> | ||||||||||||||||||||||||||||
| 163 | <input id="wiki_language" name="wiki_language" type="hidden" form="editForm" value="" /> | ||||||||||||||||||||||||||||
| 164 | <input id="page_title" name="page_title" type="hidden" form="editForm" value="" /> | ||||||||||||||||||||||||||||
| 165 | <textarea id="content" name="content" rows="32" required="required"/></textarea> | ||||||||||||||||||||||||||||
| 166 | <input id="commit_message" name="commit_message" value="commit message" onclick="this.value == 'commit message' ? this.value = '' : true"/> | ||||||||||||||||||||||||||||
| 167 | <input id="submit_save" name="submit" type="submit" value="Save" style="font-size: 66.7%;" /> | ||||||||||||||||||||||||||||
| 168 | <input id="submit_view" name="submit" type="submit" value="Done" style="font-size: 66.7%;" /> | ||||||||||||||||||||||||||||
| 169 | <label style="font-size: 0.667em;" for="public" title="Check if you want a publicly viewable page" > | ||||||||||||||||||||||||||||
| 170 | <input id="public" name="public" value="1" type="checkbox" style="font-size: 0.667em;" /> | ||||||||||||||||||||||||||||
| 171 | public | ||||||||||||||||||||||||||||
| 172 | </label> | ||||||||||||||||||||||||||||
| 173 | </form> | ||||||||||||||||||||||||||||
| 174 | </section> | ||||||||||||||||||||||||||||
| 175 | <section id="view_area" class="view_area_edit_mode"></section> | ||||||||||||||||||||||||||||
| 176 | <nav id="side"> | ||||||||||||||||||||||||||||
| 177 | <section id="search_area"> | ||||||||||||||||||||||||||||
| 178 | <form action=${base_url}search method=POST> | ||||||||||||||||||||||||||||
| 179 | <input type="text" name="word" value="Search" onclick="this.value == 'Search' ? this.value = '' : true"/> | ||||||||||||||||||||||||||||
| 180 | </form> | ||||||||||||||||||||||||||||
| 181 | </section><br /> | ||||||||||||||||||||||||||||
| 182 | <section id="publish_area">$publish_form</section> | ||||||||||||||||||||||||||||
| 183 | <section id="collections_area"></section> | ||||||||||||||||||||||||||||
| 184 | <section id="calendar_area"><a href="${base_url}calendar">Calendar</a></section> | ||||||||||||||||||||||||||||
| 185 | <section id="recent_area"></section> | ||||||||||||||||||||||||||||
| 186 | </nav> | ||||||||||||||||||||||||||||
| 187 | </article> | ||||||||||||||||||||||||||||
| 188 | <footer id="footer_area"> | ||||||||||||||||||||||||||||
| 189 | <nav id="edit_link" class="edit_link"></nav> | ||||||||||||||||||||||||||||
| 190 | <nav id="new_link" class="new_link"> <a href=${base_url}page>New</a></nav> | ||||||||||||||||||||||||||||
| 191 | </footer> | ||||||||||||||||||||||||||||
| 192 | </body> | ||||||||||||||||||||||||||||
| 193 | </html> | ||||||||||||||||||||||||||||
| 194 | END_HTML | ||||||||||||||||||||||||||||
| 195 | 0 | $edit_page =~ s/<script><\/script>/<script>mojito.base_url = '${base_url}';<\/script>/s; | |||||||||||||||||||||||||||
| 196 | 0 | return $edit_page; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub _build_wiki_language_selection { | ||||||||||||||||||||||||||
|
Subroutine
_build_wiki_language_selection: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 200 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my $selection; | |||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $default_wiki_language =$self->config->{default_wiki_language}||'markdown'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->config->{'default_wiki_language'} || 'markdown'
MC/DC0%0/1
$self->config->{'default_wiki_language'} || 'markdown'
$self->config->{'default_wiki_language'}
Truth table0%0/2
A
A= $self->config->{'default_wiki_language'}
| |||||||||||||||||||||||||||||
| 204 | 0 | foreach my $language (qw/textile markdown creole html pod/) { | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($language =~ m/$default_wiki_language/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | $selection .= qq{<input type="radio" id="$language" name="wiki_language" value="$language" checked="checked" /><label for="$language">$language</label>}; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | else { | ||||||||||||||||||||||||||||
| 209 | 0 | $selection .= qq{<input type="radio" id="$language" name="wiki_language" value="$language" /><label for="$language">$language</label>}; | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | 0 | return $selection; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub page_wrap_start { | ||||||||||||||||||||||||||
|
Subroutine
page_wrap_start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 217 | 0 | my ($self, $title) = @_; | |||||||||||||||||||||||||||
| 218 | 0 | my $mojito_version = $self->config->{VERSION}; | |||||||||||||||||||||||||||
| 219 | 0 | my $js_css = $self->js_css_html; | |||||||||||||||||||||||||||
| 220 | 0 | my $page_start = <<"START_HTML"; | |||||||||||||||||||||||||||
| 221 | <!doctype html> | ||||||||||||||||||||||||||||
| 222 | <html> | ||||||||||||||||||||||||||||
| 223 | <head> | ||||||||||||||||||||||||||||
| 224 | <meta charset=utf-8> | ||||||||||||||||||||||||||||
| 225 | <meta name="application-name" content="Mojito $mojito_version" /> | ||||||||||||||||||||||||||||
| 226 | <title>$title</title> | ||||||||||||||||||||||||||||
| 227 | $js_css | ||||||||||||||||||||||||||||
| 228 | <script></script> | ||||||||||||||||||||||||||||
| 229 | <style></style> | ||||||||||||||||||||||||||||
| 230 | </head> | ||||||||||||||||||||||||||||
| 231 | <body class="html_body"> | ||||||||||||||||||||||||||||
| 232 | <section id="message_area"></section> | ||||||||||||||||||||||||||||
| 233 | <article id="body_wrapper"> | ||||||||||||||||||||||||||||
| 234 | START_HTML | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | return $page_start; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub page_wrap_start_vanilla { | ||||||||||||||||||||||||||
|
Subroutine
page_wrap_start_vanilla: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 240 | 0 | my ($self, $title) = @_; | |||||||||||||||||||||||||||
| 241 | 0 | my $mojito_version = $self->config->{VERSION}; | |||||||||||||||||||||||||||
| 242 | 0 | my $static_url = $self->config->{static_url}; | |||||||||||||||||||||||||||
| 243 | 0 | my $page_start = <<"START_HTML"; | |||||||||||||||||||||||||||
| 244 | <!doctype html> | ||||||||||||||||||||||||||||
| 245 | <html> | ||||||||||||||||||||||||||||
| 246 | <head> | ||||||||||||||||||||||||||||
| 247 | <meta charset=utf-8> | ||||||||||||||||||||||||||||
| 248 | <meta name="application-name" content="Mojito $mojito_version" /> | ||||||||||||||||||||||||||||
| 249 | <title>$title</title> | ||||||||||||||||||||||||||||
| 250 | <link href=${static_url}css/mojito.css type=text/css rel=stylesheet /> | ||||||||||||||||||||||||||||
| 251 | </head> | ||||||||||||||||||||||||||||
| 252 | <body class="vanilla_body"> | ||||||||||||||||||||||||||||
| 253 | <article id="body_wrapper_vanilla"> | ||||||||||||||||||||||||||||
| 254 | START_HTML | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | return $page_start; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub _build_page_wrap_end { | ||||||||||||||||||||||||||
|
Subroutine
_build_page_wrap_end: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 260 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | my $page_end =<<'END_HTML'; | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | </article> | ||||||||||||||||||||||||||||
| 265 | </body> | ||||||||||||||||||||||||||||
| 266 | </html> | ||||||||||||||||||||||||||||
| 267 | END_HTML | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | return $page_end; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 wrap_page | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Wrap a page body with start and end HTML. | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub wrap_page { | ||||||||||||||||||||||||||
|
Subroutine
wrap_page: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 279 | 0 | my ($self, $page_body, $title) = @_; | |||||||||||||||||||||||||||
| 280 | 0 | ▶ | $title //= 'Mojito page'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$title //= "Mojito page"
MC/DC0%0/1
$title //= "Mojito page"
$title
Truth table0%0/2
A
A= $title
| |||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $page_body //= 'Empty page'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$page_body //= "Empty page"
MC/DC0%0/1
$page_body //= "Empty page"
$page_body
Truth table0%0/2
A
A= $page_body
| |||||||||||||||||||||||||||||
| 282 | 0 | return ($self->page_wrap_start($title) . $page_body . $self->page_wrap_end); | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =head2 wrap_page_vanilla | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | Wrap a page body with start and end HTML, and NO Javascript or CSS links | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | =cut | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub wrap_page_vanilla { | ||||||||||||||||||||||||||
|
Subroutine
wrap_page_vanilla: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 292 | 0 | my ($self, $page_body, $title) = @_; | |||||||||||||||||||||||||||
| 293 | 0 | ▶ | $title //= 'Mojito page'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$title //= "Mojito page"
MC/DC0%0/1
$title //= "Mojito page"
$title
Truth table0%0/2
A
A= $title
| |||||||||||||||||||||||||||||
| 294 | 0 | ▶ | $page_body //= 'Empty page'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$page_body //= "Empty page"
MC/DC0%0/1
$page_body //= "Empty page"
$page_body
Truth table0%0/2
A
A= $page_body
| |||||||||||||||||||||||||||||
| 295 | 0 | return ($self->page_wrap_start_vanilla($title) . $page_body . $self->page_wrap_end); | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub _build_collect_page_form { | ||||||||||||||||||||||||||
|
Subroutine
_build_collect_page_form: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 299 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 300 | 0 | return $self->wrap_page($self->select_collection_pages_view); | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub _build_collections_index { | ||||||||||||||||||||||||||
|
Subroutine
_build_collections_index: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 304 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 305 | 0 | return $self->wrap_page($self->collections_index_view); | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub _build_recent_links { | ||||||||||||||||||||||||||
|
Subroutine
_build_recent_links: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 309 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 310 | 0 | return $self->wrap_page($self->recent_links_view({want_delete_link => 1})); | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =head2 sort_collection_form | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | A form to sort a collection of pages. | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | =cut | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub sort_collection_form { | ||||||||||||||||||||||||||
|
Subroutine
sort_collection_form: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 320 | 0 | my ($self, $params) = (shift, shift); | |||||||||||||||||||||||||||
| 321 | 0 | return $self->wrap_page($self->sort_collection_pages_view({ collection_id => $params->{id} })); | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =head2 collection_page | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | Given a collection id, show a list of belonging pages. | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | =cut | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub collection_page { | ||||||||||||||||||||||||||
|
Subroutine
collection_page: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 331 | 0 | my ($self, $params) = (shift, shift); | |||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | my $base_url = $self->base_url; | |||||||||||||||||||||||||||
| 334 | 0 | ▶ | $base_url .= 'public/' if $params->{public}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | 0 | my $collector = Mojito::Collection::CRUD->new(config => $self->config, db => $self->db); | |||||||||||||||||||||||||||
| 336 | 0 | my $collection = $collector->read( $params->{id} ); | |||||||||||||||||||||||||||
| 337 | return $self->wrap_page( | ||||||||||||||||||||||||||||
| 338 | $self->collection_page_view( { collection_id => $params->{id}, is_public => $params->{public} }), | ||||||||||||||||||||||||||||
| 339 | $collection->{collection_name}, | ||||||||||||||||||||||||||||
| 340 | 0 | ); | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 0 | ▶ | sub _build_home_page { | ||||||||||||||||||||||||||
|
Subroutine
_build_home_page: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 344 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 0 | my $base_url = $self->base_url; | |||||||||||||||||||||||||||
| 347 | 0 | my $mojito_version = $self->config->{VERSION}; | |||||||||||||||||||||||||||
| 348 | 0 | my $js_css = $self->js_css_html; | |||||||||||||||||||||||||||
| 349 | 0 | my $home_page = <<"END_HTML"; | |||||||||||||||||||||||||||
| 350 | <!doctype html> | ||||||||||||||||||||||||||||
| 351 | <html> | ||||||||||||||||||||||||||||
| 352 | <head> | ||||||||||||||||||||||||||||
| 353 | <meta charset=utf-8> | ||||||||||||||||||||||||||||
| 354 | <meta name="application-name" content="Mojito $mojito_version" /> | ||||||||||||||||||||||||||||
| 355 | <title>Mojito page</title> | ||||||||||||||||||||||||||||
| 356 | $js_css | ||||||||||||||||||||||||||||
| 357 | <script></script> | ||||||||||||||||||||||||||||
| 358 | <style></style> | ||||||||||||||||||||||||||||
| 359 | </head> | ||||||||||||||||||||||||||||
| 360 | <body class=html_body> | ||||||||||||||||||||||||||||
| 361 | <header> | ||||||||||||||||||||||||||||
| 362 | <nav id="new_link" class="new_link"> <a href=${base_url}page>New</a></nav> | ||||||||||||||||||||||||||||
| 363 | </header> | ||||||||||||||||||||||||||||
| 364 | <article id="body_wrapper"> | ||||||||||||||||||||||||||||
| 365 | <nav id="side"> | ||||||||||||||||||||||||||||
| 366 | <section id="search_area"><form action=${base_url}search method=POST><input type="text" name="word" value="Search" onclick="this.value == 'Search' ? this.value = '' : true" /></form></section><br /> | ||||||||||||||||||||||||||||
| 367 | <section id="recent_area"></section> | ||||||||||||||||||||||||||||
| 368 | </nav> | ||||||||||||||||||||||||||||
| 369 | </article> | ||||||||||||||||||||||||||||
| 370 | <footer id="footer_area"> | ||||||||||||||||||||||||||||
| 371 | <nav id="new_link" class="new_link"> <a href=${base_url}page>New</a></nav> | ||||||||||||||||||||||||||||
| 372 | </footer> | ||||||||||||||||||||||||||||
| 373 | </body> | ||||||||||||||||||||||||||||
| 374 | </html> | ||||||||||||||||||||||||||||
| 375 | END_HTML | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 0 | return $home_page; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | =head1 Methods | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =head2 fillin_edit_page | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Get the contents of the edit page proper given the starting template and some data. | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =cut | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub fillin_edit_page { | ||||||||||||||||||||||||||
|
Subroutine
fillin_edit_page: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 389 | 0 | my ( $self, $page, $page_view, $mongo_id ) = @_; | |||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | # Encode source content with HTML entities since it will be displayed in a textarea | ||||||||||||||||||||||||||||
| 392 | 0 | my $page_source = encode_entities($page->{page_source}); | |||||||||||||||||||||||||||
| 393 | 0 | my $wiki_language = $page->{default_format}; | |||||||||||||||||||||||||||
| 394 | 0 | ▶ | my $page_title = $page->{title}||'no title'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$page->{'title'} || 'no title'
MC/DC0%0/1
$page->{'title'} || 'no title'
$page->{'title'}
Truth table0%0/2
A
A= $page->{'title'}
| |||||||||||||||||||||||||||||
| 395 | 0 | my @feeds = (); | |||||||||||||||||||||||||||
| 396 | 0 | ▶ | if (ref($page->{feeds}) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 0 | @feeds = @{$page->{feeds}}; | |||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | 0 | my $feeds = join ':', @feeds; | |||||||||||||||||||||||||||
| 400 | 0 | my $public = $page->{public}; | |||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | # Set page_id for the template | ||||||||||||||||||||||||||||
| 403 | 0 | $self->page_id($mongo_id); | |||||||||||||||||||||||||||
| 404 | 0 | my $output = $self->template; | |||||||||||||||||||||||||||
| 405 | 0 | my $base_url = $self->base_url; | |||||||||||||||||||||||||||
| 406 | 0 | $output =~ | |||||||||||||||||||||||||||
| 407 | s/<script><\/script>/<script>mojito.preview_url = '${base_url}preview';<\/script>/s; | ||||||||||||||||||||||||||||
| 408 | # Set some form values | ||||||||||||||||||||||||||||
| 409 | 0 | $output =~ s/(<input id="mongo_id".*?value=)""/$1"${mongo_id}"/si; | |||||||||||||||||||||||||||
| 410 | # $output =~ s/(<input .*? id ="page_id" .*? value=)""/$1"${mongo_id}"/si; | ||||||||||||||||||||||||||||
| 411 | 0 | $output =~ s/(<input id="wiki_language".*?value=)""/$1"${wiki_language}"/si; | |||||||||||||||||||||||||||
| 412 | 0 | $output =~ s/(<input id="page_title".*?value=)""/$1"${page_title}"/si; | |||||||||||||||||||||||||||
| 413 | 0 | $output =~ s/(<input id="feeds".*?value=)""/$1"${feeds}"/si; | |||||||||||||||||||||||||||
| 414 | 0 | ▶ | if ($public) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 0 | $output =~ s/(<input id="public")/$1 checked="checked"/si; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | $output =~ | ||||||||||||||||||||||||||||
| 418 | 0 | s/(<textarea\s+id="content"[^>]*>)<\/textarea>/$1${page_source}<\/textarea>/si; | |||||||||||||||||||||||||||
| 419 | 0 | $output =~ | |||||||||||||||||||||||||||
| 420 | s/(<section\s+id="view_area"[^>]*>)<\/section>/$1${page_view}<\/section>/si; | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | # An Experiment in Design: take out the save button, because we have autosave every few seconds | ||||||||||||||||||||||||||||
| 423 | 0 | $output =~ s/<input id="submit_save".*?>//sig; | |||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | # Remove side, recent area and wiki_language (for create only) | ||||||||||||||||||||||||||||
| 426 | 0 | $output =~ s/<nav id="side">.*?<\/nav>//si; | |||||||||||||||||||||||||||
| 427 | # $output =~ s/<section id="recent_area".*?><\/section>//si; | ||||||||||||||||||||||||||||
| 428 | 0 | $output =~ s/<div id="wiki_language".*?>.*?<\/div>//si; | |||||||||||||||||||||||||||
| 429 | 0 | $output =~ s|(<section id="edit_area">)|$1\n<button id="toggle_view">Toggle View</button>|si; | |||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | # Remove edit and new links | ||||||||||||||||||||||||||||
| 432 | 0 | $output =~ s/<nav id="edit_link".*?><\/nav>//sig; | |||||||||||||||||||||||||||
| 433 | 0 | $output =~ s/<nav id="new_link".*?>.*?<\/nav>//sig; | |||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | # body with no style | ||||||||||||||||||||||||||||
| 436 | 0 | $output =~ s/<body.*?>/<body>/si; | |||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | # Give the page a title | ||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if ($page_title) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 440 | 0 | $output =~ s/<title>.*?<\/title>/<title>${page_title}<\/title>/si; | |||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||
| 442 | 0 | return $output; | |||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | =head2 fillin_create_page | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | Get the contents of the create page proper given the starting template and some data. | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | =cut | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 0 | ▶ | sub fillin_create_page { | ||||||||||||||||||||||||||
|
Subroutine
fillin_create_page: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 452 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | 0 | my $output = $self->template; | |||||||||||||||||||||||||||
| 455 | 0 | my $base_url = $self->base_url; | |||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | # Set mojito preiview_url variable | ||||||||||||||||||||||||||||
| 458 | 0 | $output =~ | |||||||||||||||||||||||||||
| 459 | s/<script><\/script>/<script>mojito.preview_url = '${base_url}preview'<\/script>/; | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | # Take out view button and change save to create. | ||||||||||||||||||||||||||||
| 462 | 0 | $output =~ s/<input id="submit_view".*?>//; | |||||||||||||||||||||||||||
| 463 | 0 | $output =~ s/<input id="submit_save"(.*?>)/<input id="submit_create"$1/; | |||||||||||||||||||||||||||
| 464 | 0 | $output =~ s/(id="submit_create".*?value=)"Save"/$1"Create"/i; | |||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | # Remove side nav area | ||||||||||||||||||||||||||||
| 467 | 0 | $output =~ s/<nav id="side">.*?<\/nav>//si; | |||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | # Remove wiki_language hidden input (for edit) | ||||||||||||||||||||||||||||
| 470 | 0 | $output =~ s/<input id="wiki_language".*?\/>//sig; | |||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | # Remove edit and new links | ||||||||||||||||||||||||||||
| 473 | 0 | $output =~ s/<nav id="edit_link".*?><\/nav>//sig; | |||||||||||||||||||||||||||
| 474 | 0 | $output =~ s/<nav id="new_link".*?>.*?<\/nav>//sig; | |||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | # body with no style | ||||||||||||||||||||||||||||
| 477 | 0 | $output =~ s/<body.*?>/<body>/si; | |||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | 0 | return $output; | |||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | 0 | ▶ | sub calendar_for_month { | ||||||||||||||||||||||||||
|
Subroutine
calendar_for_month: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 483 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 484 | 0 | ▶ | my %args = ref($_[0]) ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 485 | 0 | my ($month, $year, $title) = @args{qw/month year title/}; | |||||||||||||||||||||||||||
| 486 | 0 | my $base_url = $self->base_url; | |||||||||||||||||||||||||||
| 487 | #$title ||= 'Monthly Notes'; | ||||||||||||||||||||||||||||
| 488 | 0 | my %monthly_docs = $self->get_docs_for_month($month, $year); | |||||||||||||||||||||||||||
| 489 | 0 | my ($m_j, $m_k, $y_j, $y_k) = next_and_previous_month_year($month, $year); | |||||||||||||||||||||||||||
| 490 | 0 | my $calendar = "<section id='calendar_month'>\n"; | |||||||||||||||||||||||||||
| 491 | 0 | ▶ | $calendar .= "<h1>${title}</h1>\n" if $title; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 492 | 0 | $calendar .= "<table class='monthly_calendar'>"; | |||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | # Got to turn off highlight of current day else we'd have to strip the \b's around it. | ||||||||||||||||||||||||||||
| 495 | # TODO: Allow variable path to cal | ||||||||||||||||||||||||||||
| 496 | 0 | ▶ | open(my $CAL, '-|', "/usr/bin/cal -h $month $year") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 497 | || die "Can't open /usr/bin/cal\n"; | ||||||||||||||||||||||||||||
| 498 | 0 | ▶ | while (<$CAL>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | 0 | ▶ | last if /^\s+$/; ## ignore cal's terminating blank line | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 501 | 0 | s/^\s*(.*?)\s*$/$1/; ## trim whitespace | |||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if ($. == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 504 | 0 | $calendar .= | |||||||||||||||||||||||||||
| 505 | "<tr><th class='previous' colspan='3'><a href='${base_url}calendar/year/${y_j}/month/${m_j}'>Previous Month</a></th> | ||||||||||||||||||||||||||||
| 506 | <th class='calendar_month' colspan='1'>$_</th> | ||||||||||||||||||||||||||||
| 507 | <th class='next' colspan='3'><a href='${base_url}calendar/year/${y_k}/month/${m_k}'>Next Month</a></th></tr>\n"; | ||||||||||||||||||||||||||||
| 508 | 0 | next; | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 0 | my $tag; | |||||||||||||||||||||||||||
| 512 | 0 | ▶ | if ($. == 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | 0 | $tag = "th class='weekdays'"; | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | 0 | else { $tag = "td" } | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | ## make a row, padding first week of the month as necessary | ||||||||||||||||||||||||||||
| 518 | 0 | my @data = (); | |||||||||||||||||||||||||||
| 519 | 0 | @data = split(/\s+/, $_); | |||||||||||||||||||||||||||
| 520 | 0 | $calendar .= "<tr>\n"; | |||||||||||||||||||||||||||
| 521 | 0 | ▶ | if ($. == 3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 522 | 0 | for (1 .. 6 - $#data) { $calendar .= "<td> </td>\n"; } | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | 0 | for my $i (0 .. $#data) { | |||||||||||||||||||||||||||
| 525 | 0 | $calendar .= "<$tag>$data[$i]"; | |||||||||||||||||||||||||||
| 526 | # Just process the digits found. | ||||||||||||||||||||||||||||
| 527 | 0 | ▶ | next if ($data[$i] !~ m/^\d+$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 528 | 0 | foreach my $ref (@{ $monthly_docs{ $data[$i] } }) { | |||||||||||||||||||||||||||
| 529 | # Make srue we have some type of title | ||||||||||||||||||||||||||||
| 530 | 0 | ▶ | $ref->{title} ||= 'No title found'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ref->{"title"} ||= "No title found"
MC/DC0%0/1
$ref->{"title"} ||= "No title found"
$ref->{"title"}
Truth table0%0/2
A
A= $ref->{"title"}
| |||||||||||||||||||||||||||||
| 531 | 0 | $calendar .= | |||||||||||||||||||||||||||
| 532 | "<div class='calendar_note'><a href='${base_url}page/$ref->{id}'>* $ref->{title}</a></div>"; | ||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||
| 534 | 0 | $calendar .= "</td>\n"; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | 0 | $calendar .= "</tr>\n"; | |||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||
| 538 | 0 | close($CAL); | |||||||||||||||||||||||||||
| 539 | 0 | $calendar .= "</table>\n</section>\n"; | |||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 0 | return $calendar; | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 0 | ▶ | sub calendar_month_page { | ||||||||||||||||||||||||||
|
Subroutine
calendar_month_page: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 545 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 546 | 0 | ▶ | my %args = ref($_[0]) ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 547 | @args{qw/month year/} = get_current_month_year() | ||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if not($args{month} && $args{year}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"month"} and $args{"year"}
MC/DC0%0/2
$args{"month"} and $args{"year"}
$args{"month"}
$args{"year"}
Truth table0%0/3
A and B
A= $args{"month"}B= $args{"year"}
| |||||||||||||||||||||||||||||
| 549 | 0 | my ($month, $year, $title) = @args{qw/month year title/}; | |||||||||||||||||||||||||||
| 550 | 0 | ▶ | $title ||= "Notes Calendar for $month/$year"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$title ||= "Notes Calendar for $month/$year"
MC/DC0%0/1
$title ||= "Notes Calendar for $month/$year"
$title
Truth table0%0/2
A
A= $title
| |||||||||||||||||||||||||||||
| 551 | 0 | return $self->wrap_page_vanilla($self->calendar_for_month(\%args), $title); | |||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | 0 | ▶ | sub get_current_month_year { | ||||||||||||||||||||||||||
|
Subroutine
get_current_month_year: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 555 | 0 | my $now = DateTime->now; | |||||||||||||||||||||||||||
| 556 | 0 | return ($now->month, $now->year); | |||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 0 | ▶ | sub next_and_previous_month_year { | ||||||||||||||||||||||||||
|
Subroutine
next_and_previous_month_year: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 560 | 0 | my ($month, $year) = @_; | |||||||||||||||||||||||||||
| 561 | ## Set up for previous and next month link | ||||||||||||||||||||||||||||
| 562 | 0 | my ($m_j, $m_k, $y_j, $y_k); | |||||||||||||||||||||||||||
| 563 | 0 | ▶ | if ($month == 12) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 564 | 0 | $m_j = 11; | |||||||||||||||||||||||||||
| 565 | 0 | $m_k = 1; | |||||||||||||||||||||||||||
| 566 | 0 | $y_j = $year; | |||||||||||||||||||||||||||
| 567 | 0 | $y_k = $year + 1; | |||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||
| 569 | elsif ($month == 1) { | ||||||||||||||||||||||||||||
| 570 | 0 | $m_j = 12; | |||||||||||||||||||||||||||
| 571 | 0 | $m_k = 2; | |||||||||||||||||||||||||||
| 572 | 0 | $y_j = $year - 1; | |||||||||||||||||||||||||||
| 573 | 0 | $y_k = $year; | |||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||
| 575 | else { | ||||||||||||||||||||||||||||
| 576 | 0 | $m_j = $month - 1; | |||||||||||||||||||||||||||
| 577 | 0 | $m_k = $month + 1; | |||||||||||||||||||||||||||
| 578 | 0 | $y_j = $year; | |||||||||||||||||||||||||||
| 579 | 0 | $y_k = $year; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | 0 | return ($m_j, $m_k, $y_j, $y_k); | |||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | 2 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 585 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 586 | 2 | my $constructor_args_href = shift; | |||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | # pass the options into the delegatees | ||||||||||||||||||||||||||||
| 589 | 2 | $self->_set_linker(Mojito::Model::Link->new($constructor_args_href)); | |||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||
| 591 | 4 | 1 | |||||||||||||||||||||||||||