aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-01 03:07:36 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-01 03:07:36 +0200
commitcd2e069816416dd42ed2528e4843c07309a31f27 (patch)
treea5321840e80c6d9979e36bfd2e71ffbebeeeda3e
parent0b099273c878e84b5829f7b44eaa77686c2cd587 (diff)
Caching the templates.
-rw-r--r--lib/FPanel/Interface.pm14
-rw-r--r--lib/FPanel/Login.pm12
-rw-r--r--template/domain-list.html2
3 files changed, 18 insertions, 10 deletions
diff --git a/lib/FPanel/Interface.pm b/lib/FPanel/Interface.pm
index adac0f0..0d2cd0e 100644
--- a/lib/FPanel/Interface.pm
+++ b/lib/FPanel/Interface.pm
@@ -18,7 +18,9 @@ sub cgiapp_init {
sub index : Runmode {
my $self = shift;
- my $template = $self->load_tmpl("index.html");
+ my $template = $self->load_tmpl('index.html'
+ , cache => 1
+ , utf8 => 1 );
my $domain = (split /\//, $ENV{PATH_INFO},3)[1];
$template->param({
NAME => 'INDEX',
@@ -55,19 +57,19 @@ sub DomainList : StartRunmode {
die $domains->error if $domains->code;
- my $template = $self->load_tmpl("domain-list.html");
+ my $template = $self->load_tmpl('domain-list.html'
+ , cache => 1
+ , utf8 => 1
+ , loop_context_vars => 1 );
my $url = $self->query->url();
$template->param( URL => $url );
$template->param( USER_LOCALPART => $u, USER_DOMAINPART => $d);
- my $i = 1;
$template->param( DOMAIN => [
- map { $i = 1-$i;
- { DOMAIN => $_->get_value('fvd')
+ map { { DOMAIN => $_->get_value('fvd')
, PERMS => &list_perms($_, $dn)
, DESCRIPTION => join ("\n", $_->get_value('description'))
, ISACTIVE => $_->get_value('fripostIsStatusActive') eq 'TRUE' ? 1 : 0
, URL => $url
- , ODD => $i
};
}
$domains->sorted('fvd')
diff --git a/lib/FPanel/Login.pm b/lib/FPanel/Login.pm
index 332a380..dc5ae3a 100644
--- a/lib/FPanel/Login.pm
+++ b/lib/FPanel/Login.pm
@@ -67,7 +67,7 @@ sub setup {
}
-# This method choses the Run Mode depending on the URL and query string.
+# This method chooses the Run Mode depending on the URL and query string.
sub mymode_param {
my $self = shift;
my $q = $self->query;
@@ -135,7 +135,9 @@ sub login : Runmode {
sub login_box {
my $self = shift;
- my $template = $self->load_tmpl('login.html');
+ my $template = $self->load_tmpl('login.html'
+ , cache => 1
+ , utf8 => 1 );
my $destination = $self->query->param('destination') //
$self->mymode_param();
@@ -159,10 +161,14 @@ sub logout : Runmode {
sub error_rm : ErrorRunmode {
my $self = shift;
my $error = shift;
- my $template = $self->load_tmpl("template/error.html");
+
+ my $template = $self->load_tmpl('error.html'
+ , cache => 1
+ , utf8 => 1 );
$template->param(NAME => 'ERROR');
$template->param(MESSAGE => $error);
$template->param(URL => $self->query->url);
+
return $template->output;
}
diff --git a/template/domain-list.html b/template/domain-list.html
index 771434d..3dae0bb 100644
--- a/template/domain-list.html
+++ b/template/domain-list.html
@@ -26,7 +26,7 @@
</tr>
</thead>
<TMPL_LOOP NAME=DOMAIN>
- <TMPL_IF NAME=ODD><tr class="odd"><TMPL_ELSE><tr></TMPL_IF>
+ <TMPL_IF NAME=__even__><tr class="odd"><TMPL_ELSE><tr></TMPL_IF>
<td><a href="<TMPL_VAR NAME=URL>/<TMPL_VAR NAME=DOMAIN>/"><TMPL_VAR NAME=DOMAIN></a></td>
<td><TMPL_IF NAME=PERMS><TMPL_VAR NAME=PERMS><TMPL_ELSE><span class=none>(none)</span></TMPL_IF></td>
<td><TMPL_IF NAME=DESCRIPTION><TMPL_VAR NAME=DESCRIPTION><TMPL_ELSE><span class=none>(none)</span></TMPL_IF></td>