1 package Gruntmaster
::Page
::Common
;
6 use parent qw
/Exporter/;
7 our @EXPORT_OK = qw
/header footer patch_templates/;
9 use File
::Slurp qw
/read_file/;
11 my %header_templates = (
14 <title>TITLE_GOES_HERE</title>
15 <link rel="stylesheet" href="/gm.css">
16 <script src="/zepto.var" defer></script>
17 <script src="/view.js" defer></script>
18 <script src="/form.js" defer></script>
19 <meta charset="utf-8">
21 <span id="admin"></span>
22 <div id="title"><span class="i">i</span><span class="Eval">Eval</span></div>
23 <div id="subtitle">TITLE_GOES_HERE</div>
25 <nav><ul><li><a href="/learn.var">Learn</a><li><a href="/pb/">Practice</a><li><a href="/ct/">Compete</a><li><a href="/log/">Job log</a></ul></nav>
30 my %footer_templates = (
34 Dilmom: Why don't you call your product the Gruntmaster 6000?
35 Dilbert: What kind of product do you see when you imagine a Gruntmaster 6000?
36 Dilmom: Well, it's a stripped-down version of the Gruntmaster 9000, of course. But it's software-upgradeable.
41 sub patch_templates
(\
%$){
42 my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT
} or return;
43 my ($templates, $name) = @_;
44 for (<$root/$name*>) {
46 $templates->{$1} = read_file
$_
50 patch_templates
%header_templates, 'header';
51 patch_templates
%footer_templates, 'footer';
54 my ($language, $title) = @_;
55 $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger;
59 $footer_templates{$_[0]};