/
build
63 lines (47 loc) · 1.21 KB
/
build
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
#!/usr/bin/perl
use strict;
use warnings;
use Template;
use File::Copy::Recursive 'dircopy';
use Time::Piece;
use Literature::Schema;
my %resources = qw[
actors Actor
authors Author
characters Character
productions Production
works Work
];
my $tt = Template->new({
INCLUDE_PATH => [ qw( in tt_lib ) ],
OUTPUT_PATH => 'docs',
# PRE_PROCESS => 'header.tt',
# POST_PROCESS => 'footer.tt',
});
my $sch = Literature::Schema->get_schema;
$tt->process('index.tt', {}, 'index.html')
or die $tt->error;
my $vars = {
url => 'https://literatureon.tv',
date => localtime->strftime('%Y-%m-%d'),
};
for (keys %resources) {
print "Processing $_\n";
my $rs = $sch->resultset($resources{$_});
$tt->process("$_.tt", { $_ => $rs }, "$_/index.html")
or die $tt->error;
foreach my $obj ($rs->all) {
my $singular = s/s$//r;
$tt->process("$singular.tt", { $singular => $obj },
"$_/" . $obj->slug . '/index.html')
or die $tt->error;
push @{$vars->{$_}}, $obj;
}
}
$tt = Template->new({
INCLUDE_PATH => [ qw( in tt_lib ) ],
OUTPUT_PATH => 'docs',
});
$tt->process('sitemap.tt', $vars, 'sitemap.xml')
or die $tt->error;
dircopy('static', 'docs');