X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FCommon.pm;fp=lib%2FGruntmaster%2FPage%2FCommon.pm;h=0000000000000000000000000000000000000000;hb=bb95f538bf263c0294d87cfb90d58c66117b9aab;hp=37cdf710fc60e21223a52f01a7b00fe379f262ad;hpb=4aa8ba862bf3a79362df73c3d1e8707e8135af23;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Common.pm b/lib/Gruntmaster/Page/Common.pm deleted file mode 100644 index 37cdf71..0000000 --- a/lib/Gruntmaster/Page/Common.pm +++ /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', - -TITLE_GOES_HERE - - - - - - - -
iEval
-
TITLE_GOES_HERE
- - - -HTML -); - -my %orig_footer_templates = ( - en => <<'HTML', - - -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;