Skip to content
Snippets Groups Projects
Commit d6d5085a authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

templates simplification: chomp by default

parent e7a0ae00
Branches
Tags
No related merge requests found
...@@ -10,6 +10,7 @@ use HTTP::AcceptLanguage; ...@@ -10,6 +10,7 @@ use HTTP::AcceptLanguage;
use Log::Any::Adapter; use Log::Any::Adapter;
use List::MoreUtils qw(uniq); use List::MoreUtils qw(uniq);
use Template; use Template;
use Template::Constants qw(:chomp);
use Text::CSV; use Text::CSV;
use AccountManager::Account; use AccountManager::Account;
...@@ -179,7 +180,8 @@ sub respond { ...@@ -179,7 +180,8 @@ sub respond {
## Parse template ## Parse template
my $tt2 = Template->new({ my $tt2 = Template->new({
ENCODING => 'utf8', ENCODING => 'utf8',
PRE_CHOMP => CHOMP_ONE,
INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/web/$lang" INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/web/$lang"
}); });
...@@ -480,7 +482,8 @@ sub req_complete_challenge { ...@@ -480,7 +482,8 @@ sub req_complete_challenge {
my $lang = HTTP::AcceptLanguage->new($ENV{HTTP_ACCEPT_LANGUAGE})->match(qw/en fr/) || 'en'; my $lang = HTTP::AcceptLanguage->new($ENV{HTTP_ACCEPT_LANGUAGE})->match(qw/en fr/) || 'en';
my $tt2 = Template->new({ my $tt2 = Template->new({
ENCODING => 'utf8', ENCODING => 'utf8',
PRE_CHOMP => CHOMP_ONE,
INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail/$lang" INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail/$lang"
}); });
my $template = 'send_authentication_token.tt2.eml'; my $template = 'send_authentication_token.tt2.eml';
......
...@@ -10,6 +10,7 @@ use List::Util qw(shuffle); ...@@ -10,6 +10,7 @@ use List::Util qw(shuffle);
use List::MoreUtils qw(pairwise); use List::MoreUtils qw(pairwise);
use MIME::Base64; use MIME::Base64;
use Template; use Template;
use Template::Constants qw(:chomp);
use Template::Stash; use Template::Stash;
sub encrypt { sub encrypt {
...@@ -109,6 +110,7 @@ sub update_ssp_authsources { ...@@ -109,6 +110,7 @@ sub update_ssp_authsources {
my $tt2 = Template->new({ my $tt2 = Template->new({
ENCODING => 'utf8', ENCODING => 'utf8',
PRE_CHOMP => CHOMP_ONE,
INCLUDE_PATH => $templates_dir . '/accounts' INCLUDE_PATH => $templates_dir . '/accounts'
}); });
my $template = 'accounts.php.tt2'; my $template = 'accounts.php.tt2';
......
...@@ -3,41 +3,41 @@ ...@@ -3,41 +3,41 @@
$validTestAccounts = array ( $validTestAccounts = array (
'authcrypt:Hash', 'authcrypt:Hash',
[% FOREACH account IN accounts -%] [% FOREACH account IN accounts %]
'user[% account.id() %]:{SHA256}[% account.password_hash() %]=' => array( 'user[% account.id() %]:{SHA256}[% account.password_hash() %]=' => array(
'internal_uid' => array([% account.internal_uid().quote %]), 'internal_uid' => array([% account.internal_uid().quote %]),
'associatedSP' => array([% account.associatedSP().quote %]), 'associatedSP' => array([% account.associatedSP().quote %]),
[% IF account.cn() -%] [% IF account.cn() %]
'cn' => array([% account.cn().quote %]), 'cn' => array([% account.cn().quote %]),
[% END -%] [% END %]
[% IF account.sn() -%] [% IF account.sn() %]
'sn' => array([% account.sn().quote %]), 'sn' => array([% account.sn().quote %]),
[% END -%] [% END %]
[% IF account.displayName() -%] [% IF account.displayName() %]
'displayName' => array([% account.displayName().quote %]), 'displayName' => array([% account.displayName().quote %]),
[% END -%] [% END %]
[% IF account.givenName() -%] [% IF account.givenName() %]
'givenName' => array([% account.givenName().quote %]), 'givenName' => array([% account.givenName().quote %]),
[% END -%] [% END %]
[% IF account.mail() -%] [% IF account.mail() %]
'mail' => array([% account.mail().quote %]), 'mail' => array([% account.mail().quote %]),
[% END -%] [% END %]
[% IF account.eduPersonAffiliation() -%] [% IF account.eduPersonAffiliation() %]
'eduPersonAffiliation' => array([% account.eduPersonAffiliation().quote.join(', ') %]), 'eduPersonAffiliation' => array([% account.eduPersonAffiliation().quote.join(', ') %]),
[% END -%] [% END %]
[% IF account.eduPersonScopedAffiliation() -%] [% IF account.eduPersonScopedAffiliation() %]
'eduPersonScopedAffiliation' => array([% account.eduPersonScopedAffiliation().quote.join(', ') %]), 'eduPersonScopedAffiliation' => array([% account.eduPersonScopedAffiliation().quote.join(', ') %]),
[% END -%] [% END %]
[% IF account.eduPersonPrincipalName() -%] [% IF account.eduPersonPrincipalName() %]
'eduPersonPrincipalName' => array([% account.eduPersonPrincipalName().quote %]), 'eduPersonPrincipalName' => array([% account.eduPersonPrincipalName().quote %]),
[% END -%] [% END %]
[% IF account.schacHomeOrganization() -%] [% IF account.schacHomeOrganization() %]
'schacHomeOrganization' => array([% account.schacHomeOrganization().quote %]), 'schacHomeOrganization' => array([% account.schacHomeOrganization().quote %]),
[% END -%] [% END %]
[% IF account.schacHomeOrganizationType() -%] [% IF account.schacHomeOrganizationType() %]
'schacHomeOrganizationType' => array([% account.schacHomeOrganizationType().quote %]), 'schacHomeOrganizationType' => array([% account.schacHomeOrganizationType().quote %]),
[% END -%] [% END %]
), ),
[% END -%] [% END %]
); );
...@@ -49,14 +49,14 @@ provider.</p> ...@@ -49,14 +49,14 @@ provider.</p>
<div> <div>
<table> <table>
<caption>List of user attributes</caption> <caption>List of user attributes</caption>
[% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] -%] [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] %]
<tr> <tr>
<th>[% attribute %]</th><td> [% account.$attribute() %]</td> <th>[% attribute %]</th><td>[% account.$attribute() %]</td>
</tr> </tr>
[% END %] [% END %]
[% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] -%] [% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] %]
<tr> <tr>
<th>[% attribute %]</th><td> [% account.$attribute().join(', ') %]</td> <th>[% attribute %]</th><td>[% account.$attribute().join(', ') %]</td>
</tr> </tr>
[% END %] [% END %]
<tr> <tr>
......
...@@ -51,14 +51,14 @@ service fédéré. Pour le faire, sélectionnez <strong>[% idp_displayname ...@@ -51,14 +51,14 @@ service fédéré. Pour le faire, sélectionnez <strong>[% idp_displayname
<div> <div>
<table> <table>
<caption>Liste des attributs utilisateur</caption> <caption>Liste des attributs utilisateur</caption>
[% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] -%] [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] %]
<tr> <tr>
<th>[% attribute %]</th><td> [% account.$attribute() %]</td> <th>[% attribute %]</th><td>[% account.$attribute() %]</td>
</tr> </tr>
[% END %] [% END %]
[% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] -%] [% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] %]
<tr> <tr>
<th>[% attribute %]</th><td> [% account.$attribute().join(', ') %]</td> <th>[% attribute %]</th><td>[% account.$attribute().join(', ') %]</td>
</tr> </tr>
[% END %] [% END %]
<tr> <tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment