| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package EntityModel::Web; |
|
2
|
|
|
|
|
|
|
use EntityModel::Class { |
|
3
|
1
|
|
|
|
|
15
|
_isa => [qw(EntityModel::Plugin)], |
|
4
|
|
|
|
|
|
|
site => { type => 'array', subclass => 'EntityModel::Web::Site' }, |
|
5
|
1
|
|
|
1
|
|
7222
|
}; |
|
|
1
|
|
|
|
|
4
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
EntityModel::Web - website support for L |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.004 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Support for L-backed websites. Currently an early preview release, so if you're looking for a |
|
22
|
|
|
|
|
|
|
good, production-quality web framework try something from the list. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Accepts a definition for site + page hierarchy, and applies handlers as required to convert incoming requests |
|
25
|
|
|
|
|
|
|
into outgoing responses. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
The following classes provide most of the key functionality: |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item * L - abstraction for an incoming HTTP/HTTPS request, may be subclassed by the |
|
32
|
|
|
|
|
|
|
appropriate server layer. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * L - abstraction for outgoing HTTP/HTTPS response |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item * L - website definition |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item * L - page definition, specfiying the handlers, templates, data and URL(s) for a specific |
|
39
|
|
|
|
|
|
|
page. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item * L - active request handler, includes everything appropriate for a single HTTP request. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * L - support for authorization on a single request. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item * L - support for request authentication. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * L - store and retrieve data between requests for a user session |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Definitions are stored under the C key as a list of sites: |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
web: [ |
|
54
|
|
|
|
|
|
|
host: something.com |
|
55
|
|
|
|
|
|
|
page: [ |
|
56
|
|
|
|
|
|
|
name: 'Index' |
|
57
|
|
|
|
|
|
|
path: '' |
|
58
|
|
|
|
|
|
|
pathtype: string |
|
59
|
|
|
|
|
|
|
title: 'Index page' |
|
60
|
|
|
|
|
|
|
] |
|
61
|
|
|
|
|
|
|
] |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
use URI; |
|
66
|
|
|
|
|
|
|
use EntityModel::Web::Site; |
|
67
|
|
|
|
|
|
|
use EntityModel::Web::Context; |
|
68
|
|
|
|
|
|
|
use EntityModel::Template; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 METHODS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 register |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Registers this module as a plugin with the L main classes. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub register { |
|
81
|
|
|
|
|
|
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
my $model = shift; |
|
83
|
|
|
|
|
|
|
$model->provide_handler_for( |
|
84
|
|
|
|
|
|
|
web => $self->sap(sub { |
|
85
|
|
|
|
|
|
|
my ($self, $model, %args) = @_; |
|
86
|
|
|
|
|
|
|
$self->site->push(EntityModel::Web::Site->new($_)) for @{$args{data}}; |
|
87
|
|
|
|
|
|
|
}) |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
return $self; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 page_from_uri |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub page_from_uri { |
|
97
|
|
|
|
|
|
|
my $self = shift; |
|
98
|
|
|
|
|
|
|
my $uri = shift; |
|
99
|
|
|
|
|
|
|
my ($site) = grep { $_->host eq $uri->host } $self->site->list; |
|
100
|
|
|
|
|
|
|
return EntityModel::Error->new($self, "No site") unless $site; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $page = $site->page_from_uri($uri); |
|
103
|
|
|
|
|
|
|
return EntityModel::Error->new($self, "No page") unless $page; |
|
104
|
|
|
|
|
|
|
return $page; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |