Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Maxime Besson
lemonldap-ng
Commits
774707ad
Commit
774707ad
authored
Mar 26, 2019
by
Yadd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cache to avoid parsing and compiling JSON files at each request (#1595)
parent
81c88216
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
+20
-15
No files found.
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
View file @
774707ad
...
...
@@ -17,6 +17,8 @@ use strict;
use
URI::
Escape
;
use
JSON
;
has
trOverCache
=>
(
is
=>
'
rw
',
default
=>
sub
{
{}
}
);
# List constants
sub
authProcess
{
qw(extractFormInfo getUser authenticate)
}
...
...
@@ -749,23 +751,26 @@ sub sendHtml {
# Override messages
my
$trOverMessages
=
JSON::
from_json
(
$self
->
trOver
);
opendir
(
DIR
,
$templateDir
);
my
@langfiles
=
grep
(
/\.json$/
,
readdir
(
DIR
)
);
close
(
DIR
);
foreach
my
$file
(
@langfiles
)
{
my
(
$lang
)
=
(
$file
=~
/^(\w+)\.json/
);
$self
->
logger
->
debug
("
Use
$file
to override messages
");
if
(
open
my
$json
,
"
<
",
$templateDir
.
"
/
"
.
$file
)
{
local
$/
=
undef
;
$trOverMessages
->
{
$lang
}
=
JSON::
from_json
(
<
$json
>
);
}
else
{
$self
->
logger
->
error
("
Unable to read
$file
");
unless
(
$self
->
trOverCache
->
{
$templateDir
}
)
{
opendir
(
DIR
,
$templateDir
);
my
@langfiles
=
grep
(
/\.json$/
,
readdir
(
DIR
)
);
close
(
DIR
);
foreach
my
$file
(
@langfiles
)
{
my
(
$lang
)
=
(
$file
=~
/^(\w+)\.json/
);
$self
->
logger
->
debug
("
Use
$file
to override messages
");
if
(
open
my
$json
,
"
<
",
$templateDir
.
"
/
"
.
$file
)
{
local
$/
=
undef
;
$trOverMessages
->
{
$lang
}
=
JSON::
from_json
(
<
$json
>
);
}
else
{
$self
->
logger
->
error
("
Unable to read
$file
");
}
}
}
$args
{
params
}
->
{
TROVER
}
=
JSON::
to_json
(
$trOverMessages
);
$self
->
trOverCache
->
{
$templateDir
}
=
JSON::
to_json
(
$trOverMessages
);
}
$args
{
params
}
->
{
TROVER
}
=
$self
->
trOverCache
->
{
$templateDir
};
my
$res
=
$self
->
SUPER::
sendHtml
(
$req
,
$template
,
%args
);
push
@
{
$res
->
[
1
]
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment