From b26648112dbe0c44bae7ef96ed762157b8e3351b Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 7 Jul 2014 20:58:57 +0300 Subject: [PATCH] Make template path customizable --- edwardng | 8 ++++++++ lib/App/EdwardNG.pm | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/edwardng b/edwardng index a300792..7e1363f 100755 --- a/edwardng +++ b/edwardng @@ -51,6 +51,10 @@ Path to GnuPG homedir. Private key passphrase. +=item B<--tmpl-path>=I + +Path to the template directory. Users of the default templates can select the language with this argument. Available languages: en. Defaults to B<--tmpl-path=en>. + =item B<--use-agent>, B<--no-use-agent> If B<--use-agent>, use L. Defaults to B<--no-gpg-agent>. @@ -87,6 +91,10 @@ Corresponds to B<--keydir>. Corresponds to B<--passphrase>. +=item EDWARDNG_TMPL_PATH + +Corresponds to B<--tmpl-path>. + =item EDWARDNG_USE_AGENT Corresponds to B<--use-agent> (if true) and B<--no-use-agent> (if false). diff --git a/lib/App/EdwardNG.pm b/lib/App/EdwardNG.pm index 2d81020..9a01dc0 100644 --- a/lib/App/EdwardNG.pm +++ b/lib/App/EdwardNG.pm @@ -9,6 +9,7 @@ our @EXPORT = qw/process_message/; use Email::Sender::Simple qw/sendmail/; use File::Slurp qw/read_file/; +use File::Spec::Functions qw/rel2abs/; use Getopt::Long; use MIME::Entity; use MIME::Parser; @@ -95,8 +96,10 @@ sub run { 'key=s' => \$ENV{EDWARDNG_KEY}, 'keydir=s' => \$ENV{EDWARDNG_KEYDIR}, 'passphrase=s' => \$ENV{EDWARDNG_PASSPHRASE}, + 'tmpl-path=s' => \$ENV{EDWARDNG_TMPL_PATH}, 'use-agent!' => \$ENV{EDWARDNG_USE_AGENT}, ); + my $tmpl_path = $ENV{EDWARDNG_TMPL_PATH} // 'en'; my $parser = MIME::Parser->new; $parser->decode_bodies(0); @@ -112,7 +115,7 @@ sub run { $params{plaintext} = first_part $params{decrypted} if $params{decrypted}; - my $tt = Template->new(INCLUDE_PATH => 'tmpl/en'); + my $tt = Template->new(INCLUDE_PATH => rel2abs $tmpl_path, 'tmpl'); my $data; $tt->process($tmpl, \%params, \$data); my $email = MIME::Entity->build( -- 2.39.2