Commit 9fafa1d8 authored by Christophe Maudoux's avatar Christophe Maudoux

Override msg with local json files (#1595)

parent 53eb78c5
......@@ -720,13 +720,27 @@ sub sendHtml {
$args{params}->{TROVER} = $self->trOver;
$args{templateDir}
= $self->conf->{templateDir} . '/' . $self->getSkin($req);
my $tmpl = $args{templateDir} . "/$template.tpl";
my $tmpl = $args{templateDir} . "/$template.tpl";
my $troverJson = $args{templateDir} . "/$template.json";
unless ( -f $tmpl ) {
$self->logger->debug("Template : $tmpl NOT found!!!");
$args{templateDir} = $self->conf->{templateDir} . '/bootstrap';
$tmpl = $args{templateDir} . "/$template.tpl";
$tmpl = $args{templateDir} . "/$template.tpl";
$troverJson = $args{templateDir} . "/$template.json";
$self->logger->debug("-> Trying to load $tmpl");
}
if ( -r $troverJson ) {
open my $tr_file, '<', $troverJson
or die "Can't open"
. $troverJson . " : $!";
while (<$tr_file>) {
chomp;
$args{params}->{TROVERbyJSON} .= $_;
}
close $tr_file or die "Can't close $tr_file : $!";
$self->logger->debug(" -> Overriding messages with $troverJson");
$self->logger->debug(" -> File content : $args{params}->{TROVERbyJSON}");
}
my $res = $self->SUPER::sendHtml( $req, $template, %args );
push @{ $res->[1] },
'X-XSS-Protection' => '1; mode=block',
......
<script type="application/init">
{
"trOver":{"all":{},"fr":{"PE5":"Pas de chance, râté ! Merci de réessayer ..."},"en":{}}
}
</script>
\ No newline at end of file
{
"trOver":{"all":{},"fr":{"PE5":"Pas de chance, râté ! Merci de réessayer ..."},"en":{}}
}
\ No newline at end of file
<TMPL_INCLUDE NAME="header.tpl">
<TMPL_INCLUDE NAME="error.json">
<div id="errorcontent" class="container">
<TMPL_IF AUTH_ERROR>
......
......@@ -39,6 +39,7 @@
<link rel="openid2.provider" href="<TMPL_VAR NAME="PROVIDERURI">" />
</TMPL_IF>
<TMPL_INCLUDE NAME="../common/script.tpl">
<TMPL_INCLUDE NAME="../common/trover.tpl">
<!-- //if:usedebianlibs
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX"><TMPL_VAR NAME="SKIN">/js/skin.min.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/portal.min.js"></script>
......
<script type="application/init">
{
"trOver":{"all":{},"en":{"PE9":"You are welcome! Please login..."},"fr":{}}
}
</script>
\ No newline at end of file
{
"trOver":{"all":{},"en":{"PE9":"You are welcome! Please login..."},"fr":{}}
}
<TMPL_INCLUDE NAME="header.tpl">
<TMPL_INCLUDE NAME="login.json">
<main id="logincontent" class="container">
......
<TMPL_IF NAME="TROVERbyJSON">
<script type="application/init">
<TMPL_VAR NAME="TROVERbyJSON">
</script>
</TMPL_IF>
\ No newline at end of file
......@@ -31,9 +31,9 @@ ok( $res->[2]->[0] =~ m%"trOver"%,
ok( $res->[2]->[0] =~ m%"all":\{\}%,
' all found' )
or print STDERR Dumper( $res->[2]->[0] );
#ok( $res->[2]->[0] =~ m%"en":\{"PE5":"Big brother is watching you, authenticated user"\}%,
# ' en found' )
#or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ m%"en":\{"PE9":"You are welcome! Please login..."\}%,
' en found' )
or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ m%"PE0":"Souriez, vous êtes surveillés !"%,
' PE0 found' )
or print STDERR Dumper( $res->[2]->[0] );
......@@ -46,8 +46,8 @@ ok( $res->[2]->[0] =~ m%"fr":\{%,
ok( $res->[2]->[0] =~ m%"PE85":"From lemonlap-ng.ini"%,
' PE85 found' )
or print STDERR Dumper( $res->[2]->[0] );
#count(9);
count(8);
count(9);
# Try yo authenticate
# -------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment