| 1 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | package Rubric::WebApp::URI 0.157; | ||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: URIs for Rubric web requests | ||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 7 | #pod | ||||||||||||||||||||||||||||||||
| 8 | #pod This module provides methods for generating the URIs for Rubric requests. | ||||||||||||||||||||||||||||||||
| 9 | #pod | ||||||||||||||||||||||||||||||||
| 10 | #pod =cut | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Rubric::Config; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | #pod =head1 METHODS | ||||||||||||||||||||||||||||||||
| 16 | #pod | ||||||||||||||||||||||||||||||||
| 17 | #pod =head2 root | ||||||||||||||||||||||||||||||||
| 18 | #pod | ||||||||||||||||||||||||||||||||
| 19 | #pod the URI for the root of the Rubric; taken from uri_root in config | ||||||||||||||||||||||||||||||||
| 20 | #pod | ||||||||||||||||||||||||||||||||
| 21 | #pod =cut | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 434 | ▶ | sub root { Rubric::Config->uri_root } | ||||||||||||||||||||||||||||||
|
Subroutine
root: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | #pod =head2 stylesheet | ||||||||||||||||||||||||||||||||
| 26 | #pod | ||||||||||||||||||||||||||||||||
| 27 | #pod the URI for the stylesheet | ||||||||||||||||||||||||||||||||
| 28 | #pod | ||||||||||||||||||||||||||||||||
| 29 | #pod =cut | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 85 | ▶ | sub stylesheet { | ||||||||||||||||||||||||||||||
|
Subroutine
stylesheet: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 32 | 85 | my $href = Rubric::Config->css_href; | |||||||||||||||||||||||||||||||
| 33 | 85 | ▶ | return $href if $href; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | 85 | return Rubric::Config->uri_root . '/style/rubric.css'; | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | #pod =head2 logout | ||||||||||||||||||||||||||||||||
| 38 | #pod | ||||||||||||||||||||||||||||||||
| 39 | #pod URI to log out | ||||||||||||||||||||||||||||||||
| 40 | #pod | ||||||||||||||||||||||||||||||||
| 41 | #pod =cut | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 13 | ▶ | sub logout { Rubric::Config->uri_root . '/logout' } | ||||||||||||||||||||||||||||||
|
Subroutine
logout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | #pod =head2 login | ||||||||||||||||||||||||||||||||
| 46 | #pod | ||||||||||||||||||||||||||||||||
| 47 | #pod URI to form for log in | ||||||||||||||||||||||||||||||||
| 48 | #pod | ||||||||||||||||||||||||||||||||
| 49 | #pod =cut | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 36 | ▶ | sub login { | ||||||||||||||||||||||||||||||
|
Subroutine
login: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 52 | 36 | my $uri = Rubric::Config->uri_root . '/login'; | |||||||||||||||||||||||||||||||
| 53 | 36 | ▶ | $uri =~ s/^http:/https:/i if Rubric::Config->secure_login; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | 36 | return $uri; | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | #pod =head2 reset_password | ||||||||||||||||||||||||||||||||
| 58 | #pod | ||||||||||||||||||||||||||||||||
| 59 | #pod URI to reset user password | ||||||||||||||||||||||||||||||||
| 60 | #pod | ||||||||||||||||||||||||||||||||
| 61 | #pod =cut | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 6 | ▶ | sub reset_password { | ||||||||||||||||||||||||||||||
|
Subroutine
reset_password: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 64 | 6 | my ($class, $arg) = @_; | |||||||||||||||||||||||||||||||
| 65 | 6 | my $uri = Rubric::Config->uri_root . '/reset_password'; | |||||||||||||||||||||||||||||||
| 66 | 6 | ▶ | if ($arg->{user} and defined $arg->{reset_code}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$arg->{"user"} and defined $arg->{"reset_code"}
MC/DC0%0/2
$arg->{"user"} and defined $arg->{"reset_code"}
$arg->{"user"}
defined $arg->{"reset_code"}
Truth table33%1/3
A and B
A= $arg->{"user"}B= defined $arg->{"reset_code"}
| |||||||||||||||||||||||||||||||||
| 67 | 0 | $uri .= "/$arg->{user}/$arg->{reset_code}"; | |||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | 6 | return $uri; | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | #pod =head2 newuser | ||||||||||||||||||||||||||||||||
| 73 | #pod | ||||||||||||||||||||||||||||||||
| 74 | #pod URI to form for new user registration form; returns false if registration is | ||||||||||||||||||||||||||||||||
| 75 | #pod closed. | ||||||||||||||||||||||||||||||||
| 76 | #pod | ||||||||||||||||||||||||||||||||
| 77 | #pod =cut | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 60 | ▶ | sub newuser { | ||||||||||||||||||||||||||||||
|
Subroutine
newuser: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 80 | 60 | ▶ | return if Rubric::Config->registration_closed; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 60 | return Rubric::Config->uri_root . '/newuser'; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | #pod =head2 entries(\%arg) | ||||||||||||||||||||||||||||||||
| 85 | #pod | ||||||||||||||||||||||||||||||||
| 86 | #pod URI for entry listing; valid keys for C<%arg>: | ||||||||||||||||||||||||||||||||
| 87 | #pod | ||||||||||||||||||||||||||||||||
| 88 | #pod user - entries for one user | ||||||||||||||||||||||||||||||||
| 89 | #pod tags - arrayref of tag names | ||||||||||||||||||||||||||||||||
| 90 | #pod | ||||||||||||||||||||||||||||||||
| 91 | #pod =cut | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 387 | ▶ | sub entries { | ||||||||||||||||||||||||||||||
|
Subroutine
entries: called CC=11 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 94 | 387 | my ($class, $arg) = @_; | |||||||||||||||||||||||||||||||
| 95 | 387 | ▶ | $arg->{tags} ||= {}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg->{"tags"} ||= {}
MC/DC100%1/1
$arg->{"tags"} ||= {}
$arg->{"tags"}
Truth table100%2/2
A
A= $arg->{"tags"}
| |||||||||||||||||||||||||||||||||
| 96 | 221 | $arg->{tags} = { map { $_ => undef } @{$arg->{tags}} } | |||||||||||||||||||||||||||||||
| 97 | 387 | ▶ | if ref $arg->{tags} eq 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 387 | my $format = delete $arg->{format}; | |||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 387 | my $uri = $class->root . '/entries'; | |||||||||||||||||||||||||||||||
| 102 | 387 | ▶ | $uri .= "/user/$arg->{user}" if $arg->{user}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 103 | 387 | ▶ | $uri .= '/tags/' . join('+', keys %{$arg->{tags}}) if %{$arg->{tags}}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 387 | for (qw(has_body has_link)) { | |||||||||||||||||||||||||||||||
| 105 | $uri .= "/$_/" . ($arg->{$_} ? 1 : 0) | ||||||||||||||||||||||||||||||||
| 106 | 774 | ▶ | if (defined $arg->{$_} and $arg->{$_} ne ''); | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $arg->{$_} and $arg->{$_} ne ""
MC/DC0%0/2
defined $arg->{$_} and $arg->{$_} ne ""
defined $arg->{$_}
$arg->{$_} ne ""
Truth table66%2/3
A and B
A= defined $arg->{$_}B= $arg->{$_} ne ""
| |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | 387 | ▶ | $uri .= "/urimd5/$arg->{urimd5}" if $arg->{urimd5}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 109 | 387 | ▶ | $uri .= "?format=$format" if $format; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | 387 | return $uri; | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | #pod =head2 entry($entry) | ||||||||||||||||||||||||||||||||
| 114 | #pod | ||||||||||||||||||||||||||||||||
| 115 | #pod URI to view entry | ||||||||||||||||||||||||||||||||
| 116 | #pod | ||||||||||||||||||||||||||||||||
| 117 | #pod =cut | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 42 | ▶ | sub entry { | ||||||||||||||||||||||||||||||
|
Subroutine
entry: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 120 | 42 | my ($class, $entry) = @_; | |||||||||||||||||||||||||||||||
| 121 | 42 | ▶ | return unless Scalar::Util::blessed($entry) && $entry->isa('Rubric::Entry'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($entry) and $entry->isa("Rubric::Entry")
MC/DC0%0/2
builtin::blessed($entry) and $entry->isa("Rubric::Entry")
builtin::blessed($entry)
$entry->isa("Rubric::Entry")
Truth table33%1/3
A and B
A= builtin::blessed($entry)B= $entry->isa("Rubric::Entry")
| |||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 42 | return Rubric::Config->uri_root . "/entry/" . $entry->id; | |||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | #pod =head2 edit_entry($entry) | ||||||||||||||||||||||||||||||||
| 127 | #pod | ||||||||||||||||||||||||||||||||
| 128 | #pod URI to edit entry | ||||||||||||||||||||||||||||||||
| 129 | #pod | ||||||||||||||||||||||||||||||||
| 130 | #pod =cut | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 3 | ▶ | sub edit_entry { | ||||||||||||||||||||||||||||||
|
Subroutine
edit_entry: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 133 | 3 | my ($class, $entry) = @_; | |||||||||||||||||||||||||||||||
| 134 | 3 | ▶ | return unless Scalar::Util::blessed($entry) && $entry->isa('Rubric::Entry'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($entry) and $entry->isa("Rubric::Entry")
MC/DC0%0/2
builtin::blessed($entry) and $entry->isa("Rubric::Entry")
builtin::blessed($entry)
$entry->isa("Rubric::Entry")
Truth table33%1/3
A and B
A= builtin::blessed($entry)B= $entry->isa("Rubric::Entry")
| |||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 3 | return Rubric::Config->uri_root . "/edit/" . $entry->id; | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | #pod =head2 delete_entry($entry) | ||||||||||||||||||||||||||||||||
| 140 | #pod | ||||||||||||||||||||||||||||||||
| 141 | #pod URI to delete entry | ||||||||||||||||||||||||||||||||
| 142 | #pod | ||||||||||||||||||||||||||||||||
| 143 | #pod =cut | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | sub delete_entry { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_entry: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 146 | 1 | my ($class, $entry) = @_; | |||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | return unless Scalar::Util::blessed($entry) && $entry->isa('Rubric::Entry'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($entry) and $entry->isa("Rubric::Entry")
MC/DC0%0/2
builtin::blessed($entry) and $entry->isa("Rubric::Entry")
builtin::blessed($entry)
$entry->isa("Rubric::Entry")
Truth table33%1/3
A and B
A= builtin::blessed($entry)B= $entry->isa("Rubric::Entry")
| |||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 1 | return Rubric::Config->uri_root . "/delete/" . $entry->id; | |||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | #pod =head2 post_entry | ||||||||||||||||||||||||||||||||
| 153 | #pod | ||||||||||||||||||||||||||||||||
| 154 | #pod URI for new entry form | ||||||||||||||||||||||||||||||||
| 155 | #pod | ||||||||||||||||||||||||||||||||
| 156 | #pod =cut | ||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 33 | ▶ | sub post_entry { Rubric::Config->uri_root . "/post"; } | ||||||||||||||||||||||||||||||
|
Subroutine
post_entry: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | #pod =head2 by_date | ||||||||||||||||||||||||||||||||
| 161 | #pod | ||||||||||||||||||||||||||||||||
| 162 | #pod URI for by_date | ||||||||||||||||||||||||||||||||
| 163 | #pod | ||||||||||||||||||||||||||||||||
| 164 | #pod =cut | ||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | 44 | ▶ | sub by_date { | ||||||||||||||||||||||||||||||
|
Subroutine
by_date: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 167 | 44 | my ($class) = @_; | |||||||||||||||||||||||||||||||
| 168 | 44 | shift; | |||||||||||||||||||||||||||||||
| 169 | 44 | my $year = shift; | |||||||||||||||||||||||||||||||
| 170 | 44 | my $month = shift; | |||||||||||||||||||||||||||||||
| 171 | 44 | my $uri = '/calendar'; | |||||||||||||||||||||||||||||||
| 172 | 44 | ▶ | $uri .= "/$year" if ($year); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | 44 | ▶ | $uri .= "/$month" if ($month); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 44 | Rubric::Config->uri_root . $uri; | |||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | #pod =head2 tag_cloud | ||||||||||||||||||||||||||||||||
| 181 | #pod | ||||||||||||||||||||||||||||||||
| 182 | #pod URI for all tags / tag cloud | ||||||||||||||||||||||||||||||||
| 183 | #pod | ||||||||||||||||||||||||||||||||
| 184 | #pod =cut | ||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | 42 | ▶ | sub tag_cloud { | ||||||||||||||||||||||||||||||
|
Subroutine
tag_cloud: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 187 | 42 | my ($class) = @_; | |||||||||||||||||||||||||||||||
| 188 | 42 | Rubric::Config->uri_root . "/tag_cloud"; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | #pod =head2 preferences | ||||||||||||||||||||||||||||||||
| 192 | #pod | ||||||||||||||||||||||||||||||||
| 193 | #pod URI for preferences form | ||||||||||||||||||||||||||||||||
| 194 | #pod | ||||||||||||||||||||||||||||||||
| 195 | #pod =cut | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 12 | ▶ | sub preferences { Rubric::Config->uri_root . "/preferences"; } | ||||||||||||||||||||||||||||||
|
Subroutine
preferences: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | #pod =head2 verify_user | ||||||||||||||||||||||||||||||||
| 201 | #pod | ||||||||||||||||||||||||||||||||
| 202 | #pod URI for new entry form | ||||||||||||||||||||||||||||||||
| 203 | #pod | ||||||||||||||||||||||||||||||||
| 204 | #pod =cut | ||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub verify_user { | ||||||||||||||||||||||||||||||
|
Subroutine
verify_user: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 207 | 0 | my ($class, $user) = @_; | |||||||||||||||||||||||||||||||
| 208 | 0 | Rubric::Config->uri_root . "/verify/$user/" . $user->verification_code; | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | #pod =head2 doc($doc_page) | ||||||||||||||||||||||||||||||||
| 212 | #pod | ||||||||||||||||||||||||||||||||
| 213 | #pod URI for documentation page. | ||||||||||||||||||||||||||||||||
| 214 | #pod | ||||||||||||||||||||||||||||||||
| 215 | #pod =cut | ||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||
| 217 | 42 | ▶ | sub doc { | ||||||||||||||||||||||||||||||
|
Subroutine
doc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 218 | 42 | my ($class, $doc_page) = @_; | |||||||||||||||||||||||||||||||
| 219 | 42 | Rubric::Config->uri_root . "/doc/" . $doc_page; | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | 5 | 1; | |||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | __END__ | ||||||||||||||||||||||||||||||||