]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Gruntmaster/Page/Common.pm
Make all generators inherit from a common base
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Common.pm
diff --git a/lib/Gruntmaster/Page/Common.pm b/lib/Gruntmaster/Page/Common.pm
deleted file mode 100644 (file)
index 37cdf71..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-package Gruntmaster::Page::Common;
-
-use 5.014000;
-use strict;
-use warnings;
-use parent qw/Exporter/;
-our @EXPORT_OK = qw/header footer cook_templates reload_templates/;
-
-use File::Slurp qw/read_file/;
-
-my %orig_header_templates = (
-  en => <<'HTML',
-<!DOCTYPE html>
-<title>TITLE_GOES_HERE</title>
-<link rel="stylesheet" href="/gm.css">
-<script src="/zepto.var" defer></script>
-<script src="/view.js" defer></script>
-<script src="/form.js" defer></script>
-<meta charset="utf-8">
-
-<span id="admin"></span>
-<div id="title"><span class="i">i</span><span class="Eval">Eval</span></div>
-<div id="subtitle">TITLE_GOES_HERE</div>
-
-<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>
-
-HTML
-);
-
-my %orig_footer_templates = (
-  en => <<'HTML',
-
-<footer>
-Dilmom: Why don't you call your product the Gruntmaster 6000?
-Dilbert: What kind of product do you see when you imagine a Gruntmaster 6000?
-Dilmom: Well, it's a stripped-down version of the Gruntmaster 9000, of course. But it's software-upgradeable.
-</footer>
-HTML
-);
-
-sub patch_templates {
-       my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT} or return;
-       my ($templates, $name) = @_;
-       my %out = %$templates;
-       for (<$root/$name*>) {
-               m/\.(.+)$/;
-               $out{$1} = read_file $_
-       }
-
-       %out
-}
-
-my %header_templates = patch_templates \%orig_header_templates, 'header';
-my %footer_templates = patch_templates \%orig_footer_templates, 'footer';
-
-sub reload_templates () { $ENV{GRUNTMASTER_RELOAD_TEMPLATES} }
-
-sub header{
-  my ($language, $title) = @_;
-  %header_templates = patch_templates \%orig_header_templates, 'header' if reload_templates;
-  $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger;
-}
-
-sub footer{
-  %footer_templates = patch_templates \%orig_footer_templates, 'footer' if reload_templates;
-  $footer_templates{$_[0]};
-}
-
-sub cook_templates (\%@) {
-       my ($templates, $name, $title) = @_;
-
-       my %out = patch_templates $templates, $name;
-       $out{$_}  = header ($_, $title) . $out{$_} for keys %out;
-       $out{$_} .= footer  $_  for keys %out;
-
-       %out
-}
-
-1;
This page took 0.024934 seconds and 4 git commands to generate.