line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#============================================================================= |
2
|
|
|
|
|
|
|
# LibWeb::HTML::Default -- `stdout' HTML display for libweb applications. |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package LibWeb::HTML::Default; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Copyright (C) 2000 Colin Kong |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
9
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License |
10
|
|
|
|
|
|
|
# as published by the Free Software Foundation; either version 2 |
11
|
|
|
|
|
|
|
# of the License, or (at your option) any later version. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
14
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
|
|
|
|
# GNU General Public License for more details. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
19
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
20
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21
|
|
|
|
|
|
|
#============================================================================= |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# $Id: Default.pm,v 1.6 2000/07/19 20:31:57 ckyc Exp $ |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$VERSION = '0.02'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#-################################ |
28
|
|
|
|
|
|
|
# Use standard libraries. |
29
|
1
|
|
|
1
|
|
3907
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
138
|
|
30
|
1
|
|
|
1
|
|
122
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
105
|
|
31
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1981
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#-################################ |
34
|
|
|
|
|
|
|
# Use custom libraries. |
35
|
|
|
|
|
|
|
require LibWeb::HTML::Standard; |
36
|
|
|
|
|
|
|
require LibWeb::HTML::Error; |
37
|
|
|
|
|
|
|
require LibWeb::Themes::Default; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#-################################ |
40
|
|
|
|
|
|
|
# Inheritance. |
41
|
|
|
|
|
|
|
# Order of ISA is important here! |
42
|
|
|
|
|
|
|
@ISA = qw( LibWeb::HTML::Standard LibWeb::Themes::Default LibWeb::HTML::Error ); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#-################################ |
45
|
|
|
|
|
|
|
# Methods. |
46
|
|
|
|
|
|
|
sub new { |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# Params: _class_, _rc_file_ [, _error_obj_] |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
# - _class_ is the class/package name of this package, be it a string |
51
|
|
|
|
|
|
|
# or a reference. |
52
|
|
|
|
|
|
|
# - _rc_file_ is the absolute path to the rc file for LibWeb. |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# Usage: my $html = new LibWeb::HTML::Default( _rc_file_ ); |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# PLEASE do not edit anything in this ``new'' method unless you know |
57
|
|
|
|
|
|
|
# what you are doing. |
58
|
|
|
|
|
|
|
# |
59
|
1
|
|
|
1
|
0
|
116
|
my ($class, $Class, $self); |
60
|
1
|
|
|
|
|
4
|
$class = shift; |
61
|
1
|
|
33
|
|
|
12
|
$Class = ref($class) || $class; |
62
|
1
|
|
50
|
|
|
37
|
$self = $Class->SUPER::new( shift, shift || bless( {}, $Class ) ); |
63
|
1
|
|
|
|
|
5
|
bless( $self, $Class ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
|
0
|
sub DESTROY {} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _parse_construct { |
69
|
6
|
|
|
6
|
|
7
|
my ($ref, @construct_display); |
70
|
6
|
|
|
|
|
9
|
my $construct = $_[0]; |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
7
|
eval { |
73
|
6
|
|
|
|
|
13
|
foreach (@$construct) { |
74
|
6
|
|
|
|
|
8
|
$ref = ref($_); |
75
|
6
|
50
|
|
|
|
17
|
if ( $ref eq 'SCALAR' ) { push(@construct_display, $$_); } |
|
0
|
50
|
|
|
|
0
|
|
76
|
0
|
|
|
|
|
0
|
elsif ( $ref eq 'ARRAY' ) { push(@construct_display, @$_); } |
77
|
6
|
|
|
|
|
17
|
else { push(@construct_display, $_); } |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
}; |
80
|
6
|
50
|
|
|
|
19
|
croak "$@" if ($@); |
81
|
|
|
|
|
|
|
|
82
|
6
|
|
|
|
|
16
|
return \@construct_display; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#================================================================================== |
86
|
|
|
|
|
|
|
# ISA this class (LibWeb::HTML::Default) and override the following method to |
87
|
|
|
|
|
|
|
# customize normal display. To customize error message display, ISA this class |
88
|
|
|
|
|
|
|
# (LibWeb::HTML::Default) and override LibWeb::Error::display_error(). |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
sub display { |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# Implementing base class method: LibWeb::HTML::Standard::display(). |
93
|
|
|
|
|
|
|
# Params: -content=>, [ -sheader=>, -lpanel=>, -rpanel=>, -header=>, -footer=> ]. |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# -content, -sheader, -lpanel, -rpanel, -header and -footer must be an ARRAY |
96
|
|
|
|
|
|
|
# ref. to elements which are scalar/SCALAR ref/ARRAY ref. |
97
|
|
|
|
|
|
|
# If the the elements are ARRAY ref., then the elements in that ARRAY ref. must |
98
|
|
|
|
|
|
|
# be scalar and NOT ref. |
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# -content default is lines read from $self->content(). |
101
|
|
|
|
|
|
|
# -sheader default is lines read from $self->sheader(). |
102
|
|
|
|
|
|
|
# -lpanel default is lines read from $self->lpanel(). |
103
|
|
|
|
|
|
|
# -rpanel default is lines read from $self->rpanel(). |
104
|
|
|
|
|
|
|
# -header default is lines read from $self->header(). |
105
|
|
|
|
|
|
|
# -footer default is lines read from $self->footer(). |
106
|
|
|
|
|
|
|
# |
107
|
|
|
|
|
|
|
# Return a scalar ref. to a formatted page in HTML format for display |
108
|
|
|
|
|
|
|
# to Web client. |
109
|
|
|
|
|
|
|
# |
110
|
1
|
|
|
1
|
0
|
57
|
my ($self, $content, $sheader, $lpanel, $rpanel, $header, $footer, |
111
|
|
|
|
|
|
|
$content_display, $sheader_display, $lpanel_display, $rpanel_display, |
112
|
|
|
|
|
|
|
$header_display, $footer_display); |
113
|
1
|
|
|
|
|
3
|
$self = shift; |
114
|
1
|
|
|
|
|
17
|
($content, $sheader, $lpanel, $rpanel, $header, $footer) = |
115
|
|
|
|
|
|
|
$self->rearrange(['CONTENT', 'SHEADER', 'LPANEL', 'RPANEL', 'HEADER', |
116
|
|
|
|
|
|
|
'FOOTER'], @_); |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
33
|
|
|
6
|
$content ||= $self->content(); |
119
|
1
|
|
33
|
|
|
10
|
$sheader ||= $self->sheader(); |
120
|
1
|
|
33
|
|
|
7
|
$lpanel ||= $self->lpanel(); |
121
|
1
|
|
33
|
|
|
7
|
$rpanel ||= $self->rpanel(); |
122
|
1
|
|
33
|
|
|
8
|
$header ||= $self->header(); |
123
|
1
|
|
33
|
|
|
8
|
$footer ||= $self->footer(); |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
5
|
$content_display = _parse_construct($content); |
126
|
1
|
|
|
|
|
3
|
$sheader_display = _parse_construct($sheader); |
127
|
1
|
|
|
|
|
3
|
$lpanel_display = _parse_construct($lpanel); |
128
|
1
|
|
|
|
|
4
|
$rpanel_display = _parse_construct($rpanel); |
129
|
1
|
|
|
|
|
3
|
$header_display = _parse_construct($header); |
130
|
1
|
|
|
|
|
3
|
$footer_display = _parse_construct($footer); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# |
133
|
1
|
|
|
|
|
25
|
return \<
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$self->{SITE_NAME} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
@$header_display |
140
|
|
|
|
|
|
|
@$sheader_display |
141
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
@$footer_display |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
HTML |
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
#================================================================================= |
166
|
|
|
|
|
|
|
# Begin implementation for site's default header, sub header, left panel, |
167
|
|
|
|
|
|
|
# right panel, content, footer and possibly other HTML constructs. |
168
|
|
|
|
|
|
|
sub header { |
169
|
1
|
|
|
1
|
0
|
85
|
return [' ']; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub sheader { |
173
|
1
|
|
|
1
|
0
|
5
|
return [' ']; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub lpanel { |
177
|
1
|
|
|
1
|
0
|
4
|
return [' ']; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub content { |
181
|
0
|
|
|
0
|
0
|
0
|
return [' ']; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub rpanel { |
185
|
1
|
|
|
1
|
0
|
4
|
return [' ']; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub footer { |
189
|
1
|
|
|
1
|
0
|
5
|
return [' ']; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
193
|
|
|
|
|
|
|
__DATA__ |