From: Marius Gavrilescu Date: Tue, 8 Jul 2014 06:39:16 +0000 (+0300) Subject: Use File::Share(Dir) for templates X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=8dd68edb17156d846480991d2db9844c2b3ba6e6;p=app-edwardng.git Use File::Share(Dir) for templates --- 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/share/tmpl/en/encrypt b/share/tmpl/en/encrypt new file mode 100644 index 0000000..28891f0 --- /dev/null +++ b/share/tmpl/en/encrypt @@ -0,0 +1,7 @@ +Message decrypted successfully. + +You said: +[% plaintext %] + +GnuPG said: +[% message %] \ No newline at end of file diff --git a/share/tmpl/en/encrypt_error b/share/tmpl/en/encrypt_error new file mode 100644 index 0000000..842f06f --- /dev/null +++ b/share/tmpl/en/encrypt_error @@ -0,0 +1 @@ +Could not decrypt message: [% message %] \ No newline at end of file diff --git a/share/tmpl/en/error b/share/tmpl/en/error new file mode 100644 index 0000000..8acf24f --- /dev/null +++ b/share/tmpl/en/error @@ -0,0 +1 @@ +Error while processing message: [% message %] \ No newline at end of file diff --git a/share/tmpl/en/plain b/share/tmpl/en/plain new file mode 100644 index 0000000..4ca17e3 --- /dev/null +++ b/share/tmpl/en/plain @@ -0,0 +1 @@ +This message is neither signed nor encrypted. \ No newline at end of file diff --git a/share/tmpl/en/sign b/share/tmpl/en/sign new file mode 100644 index 0000000..b111854 --- /dev/null +++ b/share/tmpl/en/sign @@ -0,0 +1,4 @@ +This message is correctly signed with key [% keyid %] from [% email %]. + +GnuPG said: +[% message %] \ No newline at end of file diff --git a/share/tmpl/en/sign_error b/share/tmpl/en/sign_error new file mode 100644 index 0000000..f35899d --- /dev/null +++ b/share/tmpl/en/sign_error @@ -0,0 +1 @@ +Could not verify message signature: [% message %] \ No newline at end of file diff --git a/share/tmpl/en/signencrypt b/share/tmpl/en/signencrypt new file mode 100644 index 0000000..9fee0c2 --- /dev/null +++ b/share/tmpl/en/signencrypt @@ -0,0 +1,7 @@ +Message encrypted and signed with key [% keyid %] from [% email %]. + +You said; +[% plaintext %] + +GnuPG said: +[% message %] \ No newline at end of file diff --git a/tmpl/en/encrypt b/tmpl/en/encrypt deleted file mode 100644 index 28891f0..0000000 --- a/tmpl/en/encrypt +++ /dev/null @@ -1,7 +0,0 @@ -Message decrypted successfully. - -You said: -[% plaintext %] - -GnuPG said: -[% message %] \ No newline at end of file diff --git a/tmpl/en/encrypt_error b/tmpl/en/encrypt_error deleted file mode 100644 index 842f06f..0000000 --- a/tmpl/en/encrypt_error +++ /dev/null @@ -1 +0,0 @@ -Could not decrypt message: [% message %] \ No newline at end of file diff --git a/tmpl/en/error b/tmpl/en/error deleted file mode 100644 index 8acf24f..0000000 --- a/tmpl/en/error +++ /dev/null @@ -1 +0,0 @@ -Error while processing message: [% message %] \ No newline at end of file diff --git a/tmpl/en/plain b/tmpl/en/plain deleted file mode 100644 index 4ca17e3..0000000 --- a/tmpl/en/plain +++ /dev/null @@ -1 +0,0 @@ -This message is neither signed nor encrypted. \ No newline at end of file diff --git a/tmpl/en/sign b/tmpl/en/sign deleted file mode 100644 index b111854..0000000 --- a/tmpl/en/sign +++ /dev/null @@ -1,4 +0,0 @@ -This message is correctly signed with key [% keyid %] from [% email %]. - -GnuPG said: -[% message %] \ No newline at end of file diff --git a/tmpl/en/sign_error b/tmpl/en/sign_error deleted file mode 100644 index f35899d..0000000 --- a/tmpl/en/sign_error +++ /dev/null @@ -1 +0,0 @@ -Could not verify message signature: [% message %] \ No newline at end of file diff --git a/tmpl/en/signencrypt b/tmpl/en/signencrypt deleted file mode 100644 index 9fee0c2..0000000 --- a/tmpl/en/signencrypt +++ /dev/null @@ -1,7 +0,0 @@ -Message encrypted and signed with key [% keyid %] from [% email %]. - -You said; -[% plaintext %] - -GnuPG said: -[% message %] \ No newline at end of file