blib/lib/Lemonldap/NG/Portal/Plugins/PublicPages.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 37 CC 3 SCAR 19.5
CC
3
Cov
0%
run
12.0
init
2.0
BEGIN
2.0
CRAP 7.0
1 package Lemonldap::NG::Portal::Plugins::PublicPages;
2  
3 use strict;
4 use Mouse;
5  
6 extends 'Lemonldap::NG::Portal::Main::Plugin';
7  
8 our $VERSION = '2.23.0';
9  
10 sub init {
11 my ($self) = @_;
12 $self->addAuthRoute( public => { ':tpl' => 'run' }, ['GET'] )
13 ->addUnauthRoute( public => { ':tpl' => 'run' }, ['GET'] );
14  
15 return 1;
16 }
17  
18 sub run {
19 my ( $self, $req ) = @_;
20 my $tpl = $req->param('tpl');
21  
22 unless ( $tpl =~ /^[\w\.\-]+$/ ) {
23 $self->userLogger->error("Bad public path $tpl");
24 return $self->p->sendError( $req, 'File not found', 404 );
25 }
26  
27 $tpl = "public/$tpl";
28 my $path =
29 $self->conf->{templateDir} . '/'
30 . $self->conf->{portalSkin}
31 . "/$tpl.tpl";
32  
33 unless ( -e $path ) {
34 $self->userLogger->warn("File not found: $path");
35 return $self->p->sendError( $req, 'File not found', 404 );
36 }
37 return $self->p->sendHtml( $req, $tpl );
38 }
39  
40 1;
41  
42 __END__
43  
44 =pod
45  
46 =encoding utf8
47  
48 =head1 NAME
49  
50 Lemonldap::NG::Portal::Plugins::PublicPages - LLNG portal plugin that allows
51 one to publish HTML pages using LLNG framework
52 system.
53  
54 =head1 SYNOPSIS
55  
56 =over
57  
58 =item Add "C<::Plugins::PublicPages>" to custom plugins list
59  
60 =item Create a "public" subdir in your template directory
61  
62 =item Create your .tpl files inside
63  
64 =item To access them, use "http://auth.your.domain/public/name" where "name" is
65 the template name
66  
67 =back
68  
69 =head1 DESCRIPTION
70  
71 Lemonldap::NG::Portal::Plugins::PublicPages is a simple LLNG portal plugin that
72 allows one to publish HTML pages using LLNG portal framework. See SYNOPSIS for
73 more.
74  
75 =head1 SEE ALSO
76  
77 Most of the documentation is available on the website
78 L<http://lemonldap-ng.org>
79  
80 =head2 OTHER POD FILES
81  
82 =over
83  
84 =item Writing an authentication module: L<Lemonldap::NG::Portal::Auth>
85  
86 =item Writing a UserDB module: L<Lemonldap::NG::Portal::UserDB>
87  
88 =item Writing a second factor module: L<Lemonldap::NG::Portal::Main::SecondFactor>
89  
90 =item Writing an issuer module: L<Lemonldap::NG::Portal::Main::Issuer>
91  
92 =item Writing another plugin: L<Lemonldap::NG::Portal::Main::Plugin>
93  
94 =item Request object: L<Lemonldap::NG::Portal::Main::Request>
95  
96 =item Adding parameters in the manager: L<Lemonldap::NG::Manager::Build>
97  
98 =back
99  
100 =head1 AUTHORS
101  
102 =over
103  
104 =item LemonLDAP::NG team L<http://lemonldap-ng.org/team>
105  
106 =back
107  
108 =head1 BUG REPORT
109  
110 Use OW2 system to report bug or ask for features:
111 L<https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
112  
113 =head1 DOWNLOAD
114  
115 Lemonldap::NG is available at
116 L<https://lemonldap-ng.org/download>
117  
118 =head1 COPYRIGHT AND LICENSE
119  
120 See COPYING file for details.
121  
122 This library is free software; you can redistribute it and/or modify
123 it under the terms of the GNU General Public License as published by
124 the Free Software Foundation; either version 2, or (at your option)
125 any later version.
126  
127 This program is distributed in the hope that it will be useful,
128 but WITHOUT ANY WARRANTY; without even the implied warranty of
129 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130 GNU General Public License for more details.
131  
132 You should have received a copy of the GNU General Public License
133 along with this program. If not, see L<http://www.gnu.org/licenses/>.
134  
135 =cut