From 8dd68edb17156d846480991d2db9844c2b3ba6e6 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Tue, 8 Jul 2014 09:39:16 +0300 Subject: [PATCH] Use File::Share(Dir) for templates --- MANIFEST | 14 +++++++------- Makefile.PL | 13 ++++++++++++- lib/App/EdwardNG.pm | 3 ++- {tmpl => share/tmpl}/en/encrypt | 0 {tmpl => share/tmpl}/en/encrypt_error | 0 {tmpl => share/tmpl}/en/error | 0 {tmpl => share/tmpl}/en/plain | 0 {tmpl => share/tmpl}/en/sign | 0 {tmpl => share/tmpl}/en/sign_error | 0 {tmpl => share/tmpl}/en/signencrypt | 0 10 files changed, 21 insertions(+), 9 deletions(-) rename {tmpl => share/tmpl}/en/encrypt (100%) rename {tmpl => share/tmpl}/en/encrypt_error (100%) rename {tmpl => share/tmpl}/en/error (100%) rename {tmpl => share/tmpl}/en/plain (100%) rename {tmpl => share/tmpl}/en/sign (100%) rename {tmpl => share/tmpl}/en/sign_error (100%) rename {tmpl => share/tmpl}/en/signencrypt (100%) diff --git a/MANIFEST b/MANIFEST index a001eb1..79df2cd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,10 +14,10 @@ t/data/mime-signed-encrypted t/keydir/pubring.gpg t/keydir/secring.gpg t/keydir/trustdb.gpg -tmpl/en/encrypt -tmpl/en/encrypt_error -tmpl/en/error -tmpl/en/plain -tmpl/en/sign -tmpl/en/sign_error -tmpl/en/signencrypt +share/tmpl/en/encrypt +share/tmpl/en/encrypt_error +share/tmpl/en/error +share/tmpl/en/plain +share/tmpl/en/sign +share/tmpl/en/sign_error +share/tmpl/en/signencrypt diff --git a/Makefile.PL b/Makefile.PL index 99e91db..8b028b9 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,5 +1,8 @@ use 5.014000; use ExtUtils::MakeMaker; +use File::ShareDir::Install; + +install_share 'share'; WriteMakefile( NAME => 'App::EdwardNG', @@ -11,6 +14,7 @@ WriteMakefile( SIGN => 1, PREREQ_PM => { qw/Email::Sender::Simple 0 + File::Share 0 File::Slurp 0 Getopt::Long 0 MIME::Entity 5.419 @@ -18,7 +22,11 @@ WriteMakefile( Mail::GnuPG 0 PerlX::Maybe 0 Template 0 - Try::Tiny 0/ + Try::Tiny 0/, + }, + BUILD_REQUIRES => { + qw/ExtUtils::MakeMaker 0 + File::ShareDir::Install 0/, }, META_MERGE => { dynamic_config => 0, @@ -27,3 +35,6 @@ WriteMakefile( } } ); + +package MY; +use File::ShareDir::Install qw/postamble/; diff --git a/lib/App/EdwardNG.pm b/lib/App/EdwardNG.pm index a9cac08..4da1968 100644 --- a/lib/App/EdwardNG.pm +++ b/lib/App/EdwardNG.pm @@ -8,6 +8,7 @@ our $VERSION = '0.001'; our @EXPORT = qw/process_message/; use Email::Sender::Simple qw/sendmail/; +use File::Share qw/dist_file/; use File::Slurp qw/read_file/; use File::Spec::Functions qw/rel2abs/; use Getopt::Long; @@ -117,7 +118,7 @@ sub run { $params{plaintext} = first_part $params{decrypted} if $params{decrypted}; - my $tt = Template->new(INCLUDE_PATH => rel2abs $tmpl_path, 'tmpl'); + my $tt = Template->new(INCLUDE_PATH => rel2abs $tmpl_path, dist_file 'App-EdwardNG', 'tmpl'); my $data; $tt->process($tmpl, \%params, \$data); my $email = MIME::Entity->build( diff --git a/tmpl/en/encrypt b/share/tmpl/en/encrypt similarity index 100% rename from tmpl/en/encrypt rename to share/tmpl/en/encrypt diff --git a/tmpl/en/encrypt_error b/share/tmpl/en/encrypt_error similarity index 100% rename from tmpl/en/encrypt_error rename to share/tmpl/en/encrypt_error diff --git a/tmpl/en/error b/share/tmpl/en/error similarity index 100% rename from tmpl/en/error rename to share/tmpl/en/error diff --git a/tmpl/en/plain b/share/tmpl/en/plain similarity index 100% rename from tmpl/en/plain rename to share/tmpl/en/plain diff --git a/tmpl/en/sign b/share/tmpl/en/sign similarity index 100% rename from tmpl/en/sign rename to share/tmpl/en/sign diff --git a/tmpl/en/sign_error b/share/tmpl/en/sign_error similarity index 100% rename from tmpl/en/sign_error rename to share/tmpl/en/sign_error diff --git a/tmpl/en/signencrypt b/share/tmpl/en/signencrypt similarity index 100% rename from tmpl/en/signencrypt rename to share/tmpl/en/signencrypt -- 2.39.2