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
|
package VNDB::VN::Page;
use strict;
use warnings;
use TUWF ':Html5';
use VNDB::Auth;
use VNDB::VN::DB;
my $VID_RE = qr{v(?<vid>[1-9][0-9]*)};
sub header {
Div class => 'header', sub {
Div class => 'header__nav', sub {
Div class => 'header__logo', 'vndb';
Div class => 'header__menu', 'Games';
};
Div class => 'header__user', auth->username || 'not logged in';
};
}
sub framework {
my $body = shift;
Html sub {
Head sub {
Meta name => 'viewport', content => 'width=device-width, initial-scale=1, shrink-to-fit=no';
Title 'VNDBv3 test';
Link rel => 'stylesheet', href => '/f/style.css';
};
Body sub {
Div class => 'container', sub {
header;
};
$body->();
};
};
Pre style => 'font-size: 8px', sub {
tuwf->dbCommit; # Hack to measure the commit time
Txt "SQL Queries:\n";
for (@{ tuwf->{_TUWF}{DB}{queries} }) {
my($sql, undef, $time) = @$_;
Txt sprintf " [%6.2fms] %s\n", $time*1000, $sql;
}
} if tuwf->debug;
}
TUWF::get qr{/$VID_RE}, sub {
framework sub {
Txt tuwf->capture('vid');
use Data::Dumper 'Dumper';
#Pre Dumper [ VNDB::VN::DB::get(undef, {hidden => 1}) ];
Pre Dumper [ VNDB::DB::entry(v => 1) ];
};
};
|