-
Notifications
You must be signed in to change notification settings - Fork 3
/
testlazy
executable file
·78 lines (65 loc) · 1.44 KB
/
testlazy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env perl
# Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch
# This is free software. See the file COPYING.md that came bundled
# with this file.
use strict; use warnings; use warnings FATAL => 'uninitialized';
use Cwd 'abs_path';
our ($mydir, $myname); BEGIN {
my $location= (-l $0) ? abs_path ($0) : $0;
$location=~ /(.*?)([^\/]+?)_?\z/s or die "?";
($mydir, $myname)=($1,$2);
}
use lib "$mydir/../lib";
use PXML::XHTML ':all';
use FP::Lazy;
use FP::List;
use PXML::Serialize;
use utf8;
$|=1;
sub countdown {
my ($i)=@_;
lazyLight {
#sleep 1;
if ($i >= 0) {
cons (P($i),
countdown ($i-1));
} else {
null
# XX should test undef here, too
}
}
}
sub page {
my ($title,$mtime,$main)= @_;
HTML(
HEAD(
TITLE($title)),
BODY(
$main,
HR(),
P(
"By ", A({href=> "http://christianjaeger.ch"},
"Christian Jaeger"),
", last modified at ", localtime($mtime)."", " (or something).")))
}
our $numbers= {
1=> "one",
2=> "two",
3=> "three"};
sub examplepage {
my ($title)= @_;
page("example page - $title",
$ENV{T} // time,
[
H1($title),
P("Garçon méchanique, \"1 < 2\" is true. ",
A({href=> "\"1 < 2\""},
"this will be 404")),
TABLE({border=>1},
map {
TR(TD($_), TD($$numbers{$_}))
} (1..3)),
countdown ($ENV{N} || 1e9),
])
}
pxml_xhtml_print examplepage ("Hello World"), *STDOUT{IO}, "en";