line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package meon::Web; |
2
|
2
|
|
|
2
|
|
1422905
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use namespace::autoclean; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Path::Class 'file', 'dir'; |
6
|
|
|
|
|
|
|
use meon::Web::SPc; |
7
|
|
|
|
|
|
|
use meon::Web::Util; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Catalyst::Plugin::Authentication::Store::UserXML 0.02; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Catalyst::Runtime 5.80; |
12
|
|
|
|
|
|
|
use Catalyst::Plugin::Session 0.37; |
13
|
|
|
|
|
|
|
use Catalyst qw( |
14
|
|
|
|
|
|
|
ConfigLoader |
15
|
|
|
|
|
|
|
Authentication |
16
|
|
|
|
|
|
|
Session |
17
|
|
|
|
|
|
|
Session::Store::File |
18
|
|
|
|
|
|
|
Session::State::Cookie |
19
|
|
|
|
|
|
|
Authentication::Store::UserXML |
20
|
|
|
|
|
|
|
SmartURI |
21
|
|
|
|
|
|
|
Unicode::Encoding |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
extends 'Catalyst'; |
24
|
|
|
|
|
|
|
use Catalyst::View::XSLT 0.10; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__PACKAGE__->config( |
29
|
|
|
|
|
|
|
name => 'meon_web', |
30
|
|
|
|
|
|
|
'Plugin::ConfigLoader' => { file => dir(meon::Web::SPc->sysconfdir, 'meon', 'web-config.pl') }, |
31
|
|
|
|
|
|
|
'Plugin::SmartURI' => { disposition => 'relative', }, |
32
|
|
|
|
|
|
|
'root' => dir(meon::Web::SPc->datadir, 'meon', 'web', 'www'), |
33
|
|
|
|
|
|
|
'authentication' => { |
34
|
|
|
|
|
|
|
'userxml' => { |
35
|
|
|
|
|
|
|
'folder' => dir(meon::Web::SPc->sharedstatedir, 'meon-web', 'global-members'), |
36
|
|
|
|
|
|
|
'user_folder_file' => 'index.xml', |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
'Plugin::Authentication' => { |
40
|
|
|
|
|
|
|
default_realm => 'members', |
41
|
|
|
|
|
|
|
members => { |
42
|
|
|
|
|
|
|
credential => { |
43
|
|
|
|
|
|
|
class => 'Password', |
44
|
|
|
|
|
|
|
password_type => 'self_check', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
store => { |
47
|
|
|
|
|
|
|
class => 'UserXML', |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
default_view => 'XSLT', |
52
|
|
|
|
|
|
|
'View::XSLT' => { |
53
|
|
|
|
|
|
|
INCLUDE_PATH => [ |
54
|
|
|
|
|
|
|
dir(meon::Web::SPc->datadir, 'meon-web', 'template', 'xsl') |
55
|
|
|
|
|
|
|
], |
56
|
|
|
|
|
|
|
TEMPLATE_EXTENSION => '.xsl', |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
'View::JSON' => { |
59
|
|
|
|
|
|
|
allow_callback => 1, |
60
|
|
|
|
|
|
|
callback_param => 'cb', |
61
|
|
|
|
|
|
|
expose_stash => 'json', |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->setup(); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub static_include_path { |
68
|
|
|
|
|
|
|
my $c = shift; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $uri = $c->req->uri; |
71
|
|
|
|
|
|
|
my $hostname = $uri->host; |
72
|
|
|
|
|
|
|
my $hostname_dir = meon::Web::Config->hostname_to_folder($hostname); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$c->detach('/status_not_found', ['no such domain '.$hostname.' configured']) |
75
|
|
|
|
|
|
|
unless $hostname_dir; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return [ dir(meon::Web::SPc->srvdir, 'www', 'meon-web', $hostname_dir, 'www') ]; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub json_reply { |
81
|
|
|
|
|
|
|
my ( $c, $json_data ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$c->res->header('X-Ajax-Controller',1); |
84
|
|
|
|
|
|
|
$c->stash->{json} = $json_data; |
85
|
|
|
|
|
|
|
$c->detach('View::JSON'); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub member { |
89
|
|
|
|
|
|
|
my $c = shift; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $members_folder = $c->default_auth_store->folder; |
92
|
|
|
|
|
|
|
return meon::Web::Member->new( |
93
|
|
|
|
|
|
|
members_folder => $members_folder, |
94
|
|
|
|
|
|
|
username => $c->user->username, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub traverse_uri { |
99
|
|
|
|
|
|
|
my ($c,$path) = @_; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$path = meon::Web::Util->path_fixup($path); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# redirect absolute urls with hostname |
104
|
|
|
|
|
|
|
if ($path =~ m{^https?://}) { |
105
|
|
|
|
|
|
|
return URI->new($path); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# redirect absolute urls |
109
|
|
|
|
|
|
|
if ($path =~ m{^/}) { |
110
|
|
|
|
|
|
|
my $new_uri = $c->req->base->clone; |
111
|
|
|
|
|
|
|
$new_uri->path($path); |
112
|
|
|
|
|
|
|
return $new_uri; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $new_uri = $c->req->uri->clone; |
116
|
|
|
|
|
|
|
my @segments = $new_uri->path_segments; |
117
|
|
|
|
|
|
|
pop(@segments) if length($path); # allow keeping current uri with path set to '' |
118
|
|
|
|
|
|
|
$new_uri->path_segments( |
119
|
|
|
|
|
|
|
@segments, |
120
|
|
|
|
|
|
|
URI->new($path)->path_segments |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
return $new_uri; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub format_dt { |
126
|
|
|
|
|
|
|
my ($c, $datetime) = @_; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my $dt = $datetime->clone; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# FIXME $c->user preferred timezone + format |
131
|
|
|
|
|
|
|
$dt->set_time_zone('Europe/Vienna'); |
132
|
|
|
|
|
|
|
return $dt->strftime('%d.%m.%Y %H:%M:%S'); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 NAME |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
meon::Web - XML+XSLT file based "CMS" |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SYNOPSIS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
script/run_meon-web_devel |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
cpan -i meon::Web |
148
|
|
|
|
|
|
|
cd /srv/www/meon-web/localhost/ |
149
|
|
|
|
|
|
|
tree |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# in apache virtual host |
152
|
|
|
|
|
|
|
<Perl> |
153
|
|
|
|
|
|
|
use Plack::Handler::Apache2; |
154
|
|
|
|
|
|
|
Plack::Handler::Apache2->preload("/usr/local/bin/meon-web.psgi"); |
155
|
|
|
|
|
|
|
</Perl> |
156
|
|
|
|
|
|
|
<Location /> |
157
|
|
|
|
|
|
|
SetHandler perl-script |
158
|
|
|
|
|
|
|
PerlResponseHandler Plack::Handler::Apache2 |
159
|
|
|
|
|
|
|
PerlSetVar psgi_app /usr/local/bin/meon-web.psgi |
160
|
|
|
|
|
|
|
</Location> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 WARNING |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Highly experimental at the moment, usable only for real adventurers. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 DESCRIPTION |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
meon-Web is CMS for designers or publishers that wants to use the whole |
169
|
|
|
|
|
|
|
power of HTML for their sites, but doesn't want to bother with |
170
|
|
|
|
|
|
|
programming. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Main implementation goal is be able to have sites as files and go as |
173
|
|
|
|
|
|
|
far as possible with standard XML+XSLT without database usage. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Each web pages is XML files with content part of given page. Then the |
176
|
|
|
|
|
|
|
rest of the page (menu + header + footer) are added via XSLT. Any advanced |
177
|
|
|
|
|
|
|
dynamically generated content on the page can be easily implemented as |
178
|
|
|
|
|
|
|
special tag, which will be rendered via XSLT. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 FEATURES |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=over 4 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
multiple domains/websites at once support - stored simple in different folders, switched per request based on "Host:" header. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
login + members area - users + credentials are stored in XML files. Login restriction simply by adding XML tag to meta headers. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
form2email - send form to email address |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 EXAMPLES |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
See F<srv/www/meon-web/localhost/> inside this distribution for simple example. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 SEE ALSO |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L<Template::Tools::ttree> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 AUTHOR |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Jozef Kutej, C<< <jkutej at cpan.org> >> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Copyright 2012 jkutej@cpan.org |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
215
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
216
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 srv/www/meon-web/bootstrap/ |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Are examples from L<https://github.com/twbs/bootstrap>, check there for |
223
|
|
|
|
|
|
|
license and copyright. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |