]>
Commit | Line | Data |
---|---|---|
832cb45e MG |
1 | package Gruntmaster::Page::Common; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | use parent qw/Exporter/; | |
6d78fc24 MG |
7 | our @EXPORT_OK = qw/header footer patch_templates/; |
8 | ||
9 | use File::Slurp qw/read_file/; | |
832cb45e MG |
10 | |
11 | my %header_templates = ( | |
12 | en => <<'HTML', | |
13 | <!DOCTYPE html> | |
14 | <title>TITLE_GOES_HERE</title> | |
15 | <link rel="stylesheet" href="/gm.css"> | |
16 | <script src="/jquery-2.0.3.min.js"></script> | |
17 | <script src="/view.js"></script> | |
18 | <meta charset="utf-8"> | |
19 | ||
20 | <span id="admin"></span> | |
21 | <div id="title"><span class="i">i</span><span class="Eval">Eval</span></div> | |
22 | <div id="subtitle">TITLE_GOES_HERE</div> | |
23 | ||
e5a94ee5 | 24 | <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> |
832cb45e MG |
25 | |
26 | HTML | |
27 | ); | |
28 | ||
29 | my %footer_templates = ( | |
30 | en => <<'HTML', | |
31 | ||
32 | <footer> | |
33 | Dilmom: Why don't you call your product the Gruntmaster 6000? | |
34 | Dilbert: What kind of product do you see when you imagine a Gruntmaster 6000? | |
35 | Dilmom: Well, it's a stripped-down version of the Gruntmaster 9000, of course. But it's software-upgradeable. | |
36 | </footer> | |
37 | HTML | |
38 | ); | |
39 | ||
6d78fc24 MG |
40 | sub patch_templates (\%$){ |
41 | my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT} or return; | |
42 | my ($templates, $name) = @_; | |
43 | for (<$root/$name*>) { | |
44 | m/\.(.+)$/; | |
45 | $templates->{$1} = read_file $_ | |
46 | } | |
47 | } | |
48 | ||
49 | patch_templates %header_templates, 'header'; | |
50 | patch_templates %footer_templates, 'footer'; | |
51 | ||
832cb45e MG |
52 | sub header{ |
53 | my ($language, $title) = @_; | |
54 | $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger; | |
55 | } | |
56 | ||
57 | sub footer{ | |
58 | $footer_templates{$_[0]}; | |
59 | } | |
60 | ||
61 | 1; |