From 832cb45e325364ca1de645a2256efa69284fcf06 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 1 Dec 2013 22:09:49 +0200 Subject: [PATCH] Move header / footer to a separate module and update MANIFEST --- MANIFEST | 5 +++- lib/Gruntmaster/Page.pm | 40 +------------------------- lib/Gruntmaster/Page/Common.pm | 47 +++++++++++++++++++++++++++++++ lib/Gruntmaster/Page/Ct.pm | 2 +- lib/Gruntmaster/Page/Ct/Entry.pm | 2 +- lib/Gruntmaster/Page/Index.pm | 2 +- lib/Gruntmaster/Page/Log.pm | 2 +- lib/Gruntmaster/Page/Log/Entry.pm | 2 +- lib/Gruntmaster/Page/Pb.pm | 2 +- lib/Gruntmaster/Page/Pb/Entry.pm | 2 +- lib/Gruntmaster/Page/Submit.pm | 2 +- 11 files changed, 60 insertions(+), 48 deletions(-) create mode 100644 lib/Gruntmaster/Page/Common.pm diff --git a/MANIFEST b/MANIFEST index 1464eb1..80ce6d4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,6 +1,9 @@ - Changes +gruntmaster-genallpages gruntmaster-genpage +lib/Gruntmaster/Page/Common.pm +lib/Gruntmaster/Page/Ct/Entry.pm +lib/Gruntmaster/Page/Ct.pm lib/Gruntmaster/Page/Index.pm lib/Gruntmaster/Page/Log/Entry.pm lib/Gruntmaster/Page/Log.pm diff --git a/lib/Gruntmaster/Page.pm b/lib/Gruntmaster/Page.pm index d014ac1..12e7329 100644 --- a/lib/Gruntmaster/Page.pm +++ b/lib/Gruntmaster/Page.pm @@ -4,7 +4,7 @@ use 5.014000; use strict; use warnings; use parent qw/Exporter/; -our @EXPORT_OK = qw/generate header footer/; +our @EXPORT_OK = qw/generate/; use File::Basename qw/fileparse/; use File::Slurp qw/write_file/; @@ -19,44 +19,6 @@ use constant CONTENT_TYPES => { txt => 'text/plain; charset=UTF-8', }; -my %header_templates = ( - en => <<'HTML', - -TITLE_GOES_HERE - - - - - - -
iEval
-
TITLE_GOES_HERE
- - - -HTML -); - -my %footer_templates = ( - en => <<'HTML', - - -HTML -); - -sub header{ - my ($language, $title) = @_; - $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger; -} - -sub footer{ - $footer_templates{$_[0]}; -} - sub declaregen{ my ($generator, $regex) = @_; $generator = "Gruntmaster::Page::$generator"; diff --git a/lib/Gruntmaster/Page/Common.pm b/lib/Gruntmaster/Page/Common.pm new file mode 100644 index 0000000..5ed4050 --- /dev/null +++ b/lib/Gruntmaster/Page/Common.pm @@ -0,0 +1,47 @@ +package Gruntmaster::Page::Common; + +use 5.014000; +use strict; +use warnings; +use parent qw/Exporter/; +our @EXPORT_OK = qw/header footer/; + +my %header_templates = ( + en => <<'HTML', + +TITLE_GOES_HERE + + + + + + +
iEval
+
TITLE_GOES_HERE
+ + + +HTML +); + +my %footer_templates = ( + en => <<'HTML', + + +HTML +); + +sub header{ + my ($language, $title) = @_; + $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger; +} + +sub footer{ + $footer_templates{$_[0]}; +} + +1; diff --git a/lib/Gruntmaster/Page/Ct.pm b/lib/Gruntmaster/Page/Ct.pm index c222e62..5a04b3a 100644 --- a/lib/Gruntmaster/Page/Ct.pm +++ b/lib/Gruntmaster/Page/Ct.pm @@ -14,7 +14,7 @@ use HTML::Template::Compiled; use IO::File; use POSIX qw/strftime/; use YAML::Any qw/LoadFile/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; my %templates = ( en => <<'HTML', diff --git a/lib/Gruntmaster/Page/Ct/Entry.pm b/lib/Gruntmaster/Page/Ct/Entry.pm index 625020d..50ee0c2 100644 --- a/lib/Gruntmaster/Page/Ct/Entry.pm +++ b/lib/Gruntmaster/Page/Ct/Entry.pm @@ -14,7 +14,7 @@ use POSIX qw/strftime/; use YAML::Any qw/LoadFile/; use File::Basename qw/fileparse/; use File::Slurp qw/slurp/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; use constant TITLE => ''; diff --git a/lib/Gruntmaster/Page/Index.pm b/lib/Gruntmaster/Page/Index.pm index 5cf282d..604be12 100644 --- a/lib/Gruntmaster/Page/Index.pm +++ b/lib/Gruntmaster/Page/Index.pm @@ -12,7 +12,7 @@ use constant TITLE => 'Gruntmaster 6000'; use Fcntl qw/:flock/; use HTML::Template::Compiled; use IO::File; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; my %templates = ( en => <<'HTML', diff --git a/lib/Gruntmaster/Page/Log.pm b/lib/Gruntmaster/Page/Log.pm index 957b510..c92bf4d 100644 --- a/lib/Gruntmaster/Page/Log.pm +++ b/lib/Gruntmaster/Page/Log.pm @@ -14,7 +14,7 @@ use HTML::Template::Compiled; use IO::File; use POSIX qw/strftime/; use YAML::Any qw/LoadFile/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; my %templates = ( en => <<'HTML', diff --git a/lib/Gruntmaster/Page/Log/Entry.pm b/lib/Gruntmaster/Page/Log/Entry.pm index 4dd13ba..e849876 100644 --- a/lib/Gruntmaster/Page/Log/Entry.pm +++ b/lib/Gruntmaster/Page/Log/Entry.pm @@ -14,7 +14,7 @@ use HTML::Template::Compiled; use IO::File; use POSIX qw/strftime/; use YAML::Any qw/LoadFile/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; my %templates = ( en => <<'HTML', diff --git a/lib/Gruntmaster/Page/Pb.pm b/lib/Gruntmaster/Page/Pb.pm index de9db87..617112a 100644 --- a/lib/Gruntmaster/Page/Pb.pm +++ b/lib/Gruntmaster/Page/Pb.pm @@ -14,7 +14,7 @@ use HTML::Template::Compiled; use IO::File; use POSIX qw/strftime/; use YAML::Any qw/LoadFile/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; my %templates = ( en => <<'HTML', diff --git a/lib/Gruntmaster/Page/Pb/Entry.pm b/lib/Gruntmaster/Page/Pb/Entry.pm index 6252b99..53cc210 100644 --- a/lib/Gruntmaster/Page/Pb/Entry.pm +++ b/lib/Gruntmaster/Page/Pb/Entry.pm @@ -14,7 +14,7 @@ use POSIX qw/strftime/; use YAML::Any qw/LoadFile/; use File::Basename qw/fileparse/; use File::Slurp qw/slurp/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; use constant FORMATS => [qw/CPP/]; use constant TITLE => ''; diff --git a/lib/Gruntmaster/Page/Submit.pm b/lib/Gruntmaster/Page/Submit.pm index e6f44de..a57b7b1 100644 --- a/lib/Gruntmaster/Page/Submit.pm +++ b/lib/Gruntmaster/Page/Submit.pm @@ -14,7 +14,7 @@ use Fcntl qw/:flock/; use HTML::Template::Compiled; use IO::File; use YAML::Any qw/LoadFile/; -use Gruntmaster::Page qw/header footer/; +use Gruntmaster::Page::Common qw/header footer/; my %templates = ( en => <<'HTML', -- 2.39.2