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