| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package ASP4; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings 'all'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
87
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.001_05'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
1;# return true: |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
ASP4 - Fast, Simple, Scalable Web Development |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
ASP4 is a web development environment. It takes lessons learned from other web |
|
20
|
|
|
|
|
|
|
development environments such as Microsoft ASP.Net, Ruby on Rails and Catalyst. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This project has some top-level priorities: |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item * Test-Driven |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
ASP4 is made for the test-writing fanatic. Anything your web application might do |
|
29
|
|
|
|
|
|
|
can be tested - using L, L and L. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
ASP4 supports test-fixtures, properties files (useful for error messages, etc) |
|
32
|
|
|
|
|
|
|
and uses a simple plain-text JSON configuration file format. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * Keep It Simple, Smartypants (KISS) |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
ASP4 provides a clean slate on which to build web applications. It does not go |
|
37
|
|
|
|
|
|
|
out of its way to do everything for the developer, and does not enforce any kind |
|
38
|
|
|
|
|
|
|
of specific coding style. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * Go Faster |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
On a server configuration which can serve a static "HELLO WORLD" page at 12,000 requests per second, |
|
43
|
|
|
|
|
|
|
ASP4 can serve the "HELLO WORLD" equivalent at 1,200 requests per second. A more |
|
44
|
|
|
|
|
|
|
complex page that involves deeply-nested MasterPages and server-side includes may |
|
45
|
|
|
|
|
|
|
come in at 1,000 requests per second. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * Easy to Learn |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The intrinsic ASP objects - C<$Request>, C<$Response>, C<$Session>, C<$Server> - |
|
50
|
|
|
|
|
|
|
and ASP4 extensions - C<$Form>, C<$Config>, C<$Stash> - focus developer attention |
|
51
|
|
|
|
|
|
|
on a simplified environment, while still offering direct access to the "metal" underneath. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The classic Perl L C<$r> and L objects are always accessible |
|
54
|
|
|
|
|
|
|
via the L api. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * Easy to Scale |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Session state can be stored in a database (or distributed via memcached) which means |
|
59
|
|
|
|
|
|
|
that ASP4 web applications can be served by one machine or many machines. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
B is in the DNA of ASP4. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 ASP Scripts |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
ASP scripts are pretty much as you might expect, if you've ever seen an ASP script before: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Welcome Back, <%= $Session->{email} || "You" %>! |
|
74
|
|
|
|
|
|
|
<% |
|
75
|
|
|
|
|
|
|
for(1..5) { |
|
76
|
|
|
|
|
|
|
%> |
|
77
|
|
|
|
|
|
|
<%= $_ %>: Hello, World! |
|
78
|
|
|
|
|
|
|
<% |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
%> |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Favorite Color: <%= $Server->HTMLEncode( $Form->{favorite_color} ) %> |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 Form Handlers |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Like "Controllers" in the MVC paradigm, "Handlers" respond to user input without |
|
90
|
|
|
|
|
|
|
any of the Perl-embedded-in-HTML distraction. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Some URL-masking happens, so a request to C would go to: |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package hello::world; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use strict; |
|
97
|
|
|
|
|
|
|
use warnings 'all'; |
|
98
|
|
|
|
|
|
|
use base 'ASP4::FormHandler'; |
|
99
|
|
|
|
|
|
|
use vars __PACKAGE__->VARS; # Import $Request, $Response, $Session, etc: |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub run { |
|
102
|
|
|
|
|
|
|
my ($self, $context) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$Response->SetCookie( |
|
105
|
|
|
|
|
|
|
name => "last-seen", |
|
106
|
|
|
|
|
|
|
value => scalar(localtime()), |
|
107
|
|
|
|
|
|
|
expires => 30 * 60 * 60 * 24, # 30 days: |
|
108
|
|
|
|
|
|
|
); |
|
109
|
|
|
|
|
|
|
$Response->Write("Hello World!"); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1;# return true: |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 MasterPages |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Similar to ASP.Net's concept of MasterPages, ASP4's MasterPages allow Page Composition. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Example: (eg: C) |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
<%@ MasterPage %> |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Default Title |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
" /> |
|
127
|
|
|
|
|
|
|
" /> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
HELLO |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Content coming soon! |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
If you access the page directly, you would see the default content displayed. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 Child Pages |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Child pages inherit from MasterPages - exactly like child classes inherit from super classes. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Example: (eg: C) |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
<%@ Page UseMasterPage="/masters/global.asp" %> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Child Title |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
child keywords |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
child description |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The Child Page |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Hello from the Child Page - hooray! |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The result after accessing C you would see the following: |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Child Title |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
The Child Page |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Hello from the Child Page - hooray! |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 MasterPage Inheritance |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
MasterPages can also inherit from other MasterPages. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Example: (eg: C) |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
<%@ MasterPage %> |
|
186
|
|
|
|
|
|
|
<%@ Page UseMasterPage="/masters/global.asp" %> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Submaster Title |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
submaster keywords |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
submaster description |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
The Submaster Page |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
The first part. |
|
198
|
|
|
|
|
|
|
Hello from the subsection! |
|
199
|
|
|
|
|
|
|
The final part. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
A page inheriting from C could get by with only: |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
<%@ Page UseMasterPage="/masters/submaster.asp" %> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Hello from the subsection! |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
The resulting content would be: |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Submaster Title |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
The Submaster Page |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
The first part. |
|
226
|
|
|
|
|
|
|
Hello from the subsection! |
|
227
|
|
|
|
|
|
|
The final part. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
B<**THEN**> you could further subclass like this: |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
<%@ Page UseMasterPage="/masters/submaster.asp" %> |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
My Title! |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
My Content Too! |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
The output would be: |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
My Title! |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
The Submaster Page |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
The first part. |
|
257
|
|
|
|
|
|
|
My Content Too! |
|
258
|
|
|
|
|
|
|
The final part. |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 AUTHOR |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
John Drago |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
This software is Free software and may be used and redistributed under the same |
|
271
|
|
|
|
|
|
|
terms as perl itself. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |
|
274
|
|
|
|
|
|
|
|