[vhffs-dev] [1708] No more infamous HTML::Template in group view

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1708
Author:   beuss
Date:     2011-05-13 08:13:57 +0200 (Fri, 13 May 2011)
Log Message:
-----------
No more infamous HTML::Template in group view

Modified Paths:
--------------
    trunk/vhffs-panel/group/view.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/group/info.tt
    trunk/vhffs-panel/templates/misc/service-index.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/group/info.tmpl

Modified: trunk/vhffs-panel/group/view.pl
===================================================================
--- trunk/vhffs-panel/group/view.pl	2011-05-13 06:13:50 UTC (rev 1707)
+++ trunk/vhffs-panel/group/view.pl	2011-05-13 06:13:57 UTC (rev 1708)
@@ -32,7 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use strict;
@@ -46,20 +45,58 @@
 my $session = $panel->get_session;
 exit 0 unless $session;
 
-my $templatedir = $panel->{templatedir};
 my $vhffs = $panel->{'vhffs'};
 my $cgi = $panel->{'cgi'};
 my $group = Vhffs::Group::get_by_groupname( $vhffs , $cgi->param('group') );
 
 unless( defined $group )
 {
-	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'You must specify a project name' ) );
-	$panel->build( $template );
+    $panel->render('misc/message.tt', { message => gettext( 'You must specify a project name' ) });
 }
 else
 {
-	$panel->build( $panel->project_info );
+    my $vars = {
+        group => $group
+    };
+    my $config = $vhffs->get_config;
+    my $groups_config = $config->get_groups;
+    my $services = {};
+    my $services_help = {};
+    my $services_labels = {
+        cvs => 'CVS repositories',
+        dns => 'Domain names',
+        mail => 'Mail domains',
+        mailinglist => 'Mailing lists',
+        mysql => 'MySQL DBs',
+        pgsql => 'PostgreSQL DBs',
+        repository => 'Download repositories',
+        svn => 'SVN repositories',
+        git => 'Git repositories',
+        mercurial => 'Mercurial repositories',
+        bazaar => 'Bazaar repositories',
+        web => 'Webareas',
+        cron => 'Cron jobs',
+    };
+
+    $panel->set_title( sprintf( gettext("Group %s") , $group->get_groupname ) );
+    if(defined $groups_config and defined $groups_config->{url_doc}) {
+        $vars->{help_url} = $groups_config->{url_doc};
+    }
+
+    foreach my $s(qw/web mysql pgsql cvs svn git mercurial bazaar mailinglist mail repository dns cron/) {
+        if($config->get_service_availability($s)) {
+            my $module = 'Vhffs::Panel::'.($s eq 'dns' ? 'DNS' : ($s eq 'mailinglist' ? 'MailingList' : ucfirst($s)));
+            eval("require $module;");
+            {
+                no strict 'refs';
+                $services->{$s} = &{"$module\::getall_per_group"}($vhffs, $group->get_gid);
+                $services_help->{$s} = $config->get_service($s)->{url_doc} if(defined $config->get_service($s)->{url_doc});
+            }
+        }
+    }
+    $vars->{services} = $services;
+    $vars->{services_labels} = $services_labels;
+
+
+    $panel->render('group/info.tt', $vars);
 }
-
-$panel->display;

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-13 06:13:50 UTC (rev 1707)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-13 06:13:57 UTC (rev 1708)
@@ -69,7 +69,6 @@
 	dns/list_srv_sub.tmpl \
 	dns/list_txt_sub.tmpl \
 	dns/prefs.tmpl \
-	group/info.tmpl \
 	mail/create.tmpl \
 	mailinglist/create.tmpl \
 	mailinglist/list_part.tmpl \
@@ -130,6 +129,7 @@
 	anonymous/subscribe.tt \
 	group/create.tt \
 	group/index.tt \
+	group/info.tt \
 	group/prefs.tt \
 	group/tags.tt \
 	layouts/anonymous.tt \
@@ -146,4 +146,5 @@
 	misc/infos.tt \
 	misc/languages.tt \
 	misc/message.tt \
+	misc/service-index.tt \
 	misc/welcome.tt

Deleted: trunk/vhffs-panel/templates/group/info.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/info.tmpl	2011-05-13 06:13:50 UTC (rev 1707)
+++ trunk/vhffs-panel/templates/group/info.tmpl	2011-05-13 06:13:57 UTC (rev 1708)
@@ -1,21 +0,0 @@
-<TMPL_IF NAME="MESSAGE">
-<p class="info"><TMPL_VAR ESCAPE=1 NAME="MESSAGE"></p>
-</TMPL_IF>
-
-<fieldset>
-    <legend><TMPL_VAR ESCAPE=1 NAME="TEXT_GENERAL"></legend>
-    <ul class="generalList">
-	<li><TMPL_VAR ESCAPE=1 NAME="QUOTA_TEXT"> &mdash;
-		<div id="group_quota">
-		<img src="/themes/<TMPL_VAR ESCAPE=1 NAME="THEME">/images/quota_progress.png" width="<TMPL_VAR ESCAPE=1 NAME="QUOTA_WIDTH">" alt="<TMPL_VAR ESCAPE=1 NAME="QUOTA_WIDTH">"/>
-		</div>
-	</li>
-        <li><a href="/group/history.pl?group=<TMPL_VAR ESCAPE=1 NAME="GROUPNAME">"><TMPL_VAR ESCAPE=1 NAME="TEXT_FULLHISTORY"></a></li>
-        <li><a href="/group/prefs.pl?group=<TMPL_VAR ESCAPE=1 NAME="GROUPNAME">"><TMPL_VAR ESCAPE=1 NAME="TEXT_PREFS"></a></li>
-	<TMPL_IF NAME="HELP_URL">
-        <li><a href="<TMPL_VAR ESCAPE=1 NAME="HELP_URL">"><TMPL_VAR ESCAPE=1 NAME="HELP_TEXT"></a></li>
-	</TMPL_IF>
-    </ul>
-</fieldset>
-
-<TMPL_VAR ESCAPE=0 NAME="SERVICES">

Added: trunk/vhffs-panel/templates/group/info.tt
===================================================================
--- trunk/vhffs-panel/templates/group/info.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/group/info.tt	2011-05-13 06:13:57 UTC (rev 1708)
@@ -0,0 +1,25 @@
+[% SET quota_percent = (group.get_quota_used / group.get_quota) * 100 %]
+
+<fieldset>
+    <legend>[% 'General' | i18n | html %]</legend>
+    <ul class="generalList">
+	<li>[% 'Quota (used/total): %d/%dMB' | i18n | pretty_print(group.get_quota_used, group.get_quota) | html %] &mdash;
+		<div id="group_quota">
+		<img src="/themes/[% theme %]/images/quota_progress.png" width="[% (group.get_quota_used / group.get_quota * 100) | format('%d') %]%" alt="[% (group.get_quota_used / group.get_quota * 100) | format('%.2f') %]%" title="[% (group.get_quota_used / group.get_quota * 100) | format('%.2f') %]%"/>
+		</div>
+	</li>
+        <li><a href="/group/history.pl?group=[% group.get_groupname | html %]">[% 'Full history' | i18n | html %]</a></li>
+        <li><a href="/group/prefs.pl?group=[% group.get_groupname | html %]">[% 'Preferences' | i18n | html %]</a></li>
+[% IF help_url.defined %]
+        <li><a href="[% help_url %]">[% 'Help' | i18n | html %]</a></li>
+[% END %]
+    </ul>
+</fieldset>
+
+[% FOREACH service_name IN services.keys %]
+[% INCLUDE 'misc/service-index.tt'
+    type = service_name
+    label = services_labels.item(service_name)
+    help_url = services_help.item(service_name)
+    list = services.item(service_name) %]
+[% END %]

Added: trunk/vhffs-panel/templates/misc/service-index.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/service-index.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/misc/service-index.tt	2011-05-13 06:13:57 UTC (rev 1708)
@@ -0,0 +1,27 @@
+<fieldset>
+    <legend>[% label | format('%s for %%s') | i18n | pretty_print(group.get_groupname) %]</legend>
+    <ul class="[% type %]List">
+[% IF list.size() %]
+[% FOREACH s IN list %]
+        <li>[% s.displayname | html %]
+            [% IF s.active %]
+                &mdash; <a href="/[% type %]/prefs.pl?name=[% s.displayname | html %]">[% 'Go to administration' | i18n | html %]</a>
+            [% ELSE %]
+                ([% s.state | html %])
+                [% IF s.refused %]
+                &mdash;  <a href="/object/resubmit.pl?oid=[% s.oid %]">[% 'Propose a new description' | i18n | html %]</a>
+                &mdash; <a href="/object/quickdelete.pl?oid=[% s.oid %]">[% 'Cancel request' | i18n | html %]</a>
+                [% END %]
+            [% END %]
+            &mdash; <a href="/history.pl?OID=[% s.oid %]">[% 'History' | i18n | html %]</a>
+        </li>
+[% END # s IN list %]
+[% ELSE %]
+        <li>[% 'None' | i18n | html %]</li>
+[% END # list.size() %]
+        <li><a href="/[% type %]/create.pl?group=[% group.get_groupname | html %]">[% 'New' | i18n | html %]</a></li>
+[% IF help_url %]
+        <li><a href="[% help_url | html %]"> [% 'Help' | i18n | html %]</a></li>
+[% END %]
+    </ul>
+</fieldset>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/