[vhffs-dev] [1676] Login page uses Template::Toolkit.

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


Revision: 1676
Author:   beuss
Date:     2011-04-30 23:26:58 +0200 (Sat, 30 Apr 2011)
Log Message:
-----------
Login page uses Template::Toolkit.

Also added generic templates.

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Commons.pm
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/anonymous/
    trunk/vhffs-panel/templates/anonymous/login.tt
    trunk/vhffs-panel/templates/layouts/
    trunk/vhffs-panel/templates/layouts/anonymous.tt
    trunk/vhffs-panel/templates/misc/errors.tt
    trunk/vhffs-panel/templates/misc/infos.tt
    trunk/vhffs-panel/templates/misc/languages.tt

Modified: trunk/vhffs-api/src/Vhffs/Panel/Commons.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Commons.pm	2011-04-30 21:26:02 UTC (rev 1675)
+++ trunk/vhffs-api/src/Vhffs/Panel/Commons.pm	2011-04-30 21:26:58 UTC (rev 1676)
@@ -41,56 +41,35 @@
 
 use Vhffs::Constants;
 
-sub display_login($$)
+sub display_login
 {
     my ($vhffs, $panel) = @_;
 
     my $hostname = $vhffs->get_config->get_host_name;
     my $website = $vhffs->get_config->get_host_website;
     my $cgi = $panel->{cgi};
-
-    my $hosturl;
-    if( defined $website )  {
-        $hosturl = '<a href="'.$vhffs->get_config->get_host_website.'">'.$vhffs->get_config->get_host_name.'</a>';
-    } else {
-        $hosturl = $hostname;
-    }
-
-    my $templatedir = $panel->{templatedir};
-    my $template = new HTML::Template( filename => $templatedir.'/panel/main/auth.tmpl' );
-
-    $template->param( TEXT_WELCOME => sprintf( gettext("Welcome on %s") , $hosturl )   );
-    $template->param( VHFFS_INFO => sprintf( "Run VHFFS %s (%s)" , Vhffs::Constants::VHFFS_VERSION , Vhffs::Constants::VHFFS_RELEASE_NAME ) );
-    $template->param( TEXT_PLEASEIDENTIFY => gettext("Please enter your username and password") );
-    $template->param( TEXT_USERNAME => gettext("Username") );
-    $template->param( VALUE_USERNAME => $cgi->param('username') );
-    $template->param( TEXT_PASSWORD => gettext("Password") );
-    $template->param( TEXT_LOGIN => gettext("Access to panel") );
-    $template->param( TEXT_LOSTPASSWORD => gettext("I've lost my password") );
-    if( $vhffs->get_config->get_allow_subscribe ) {
-    	$template->param( SUBSCRIBE_OPEN => 1 );
-    	$template->param( TEXT_SUBSCRIBE => gettext("Subscribe") );
-    }
-
-    $template->param( LANGS => $panel->select_lang );
-
-
+    my $vars = {};
+    $vars->{username} = $cgi->param('username');
+    $vars->{subscription_allowed} = $vhffs->get_config->get_allow_subscribe;
+    $vars->{website} = $website;
+    $vars->{hostname} = $hostname;
     if( $vhffs->get_config->get_panel->{'stats_on_home'} eq 'yes' ) {
-        use Vhffs::Stats;
+        require Vhffs::Stats;
         my $stats = new Vhffs::Stats( $vhffs );
-        my $users  = $stats->get_user_total;
-        my $groups = $stats->get_groups_activated;
-
-        $template->param( TEXT_STATS => sprintf( gettext( "Woah, %s users and %s groups already trust %s" ) , $users, $groups , $hosturl ) );
+        $vars->{stats} = {
+            users => $stats->get_user_total,
+            groups => $stats->get_groups_activated
+        };
     }
-
+    $vars->{version_info} = {
+        version => Vhffs::Constants::VHFFS_VERSION,
+        name => Vhffs::Constants::VHFFS_RELEASE_NAME
+    };
     if( $panel->is_public ) {
-        $template->param( TEXT_PUBLIC => gettext( "Go to public area" ) );
-        $template->param( URL_PUBLIC => $vhffs->get_config->get_panel->{'url_public'} );
+        $vars->{public_url} = $vhffs->get_config->get_panel->{'url_public'};
     }
 
-    $panel->light( $template );
-    $panel->display;
+    $panel->render( 'anonymous/login.tt', $vars, 'anonymous.tt' );
 }
 
 =head2 paginate

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-04-30 21:26:02 UTC (rev 1675)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-04-30 21:26:58 UTC (rev 1676)
@@ -141,4 +141,9 @@
 	web/mailuser.tmpl \
 	web/prefs.tmpl \
 	cron/create.tmpl \
-	cron/prefs.tmpl
+	cron/prefs.tmpl \
+	anonymous/login.tt \
+	layouts/anonymous.tt \
+	misc/errors.tt \
+	misc/infos.tt \
+	misc/languages.tt

Added: trunk/vhffs-panel/templates/anonymous/login.tt
===================================================================
--- trunk/vhffs-panel/templates/anonymous/login.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/anonymous/login.tt	2011-04-30 21:26:58 UTC (rev 1676)
@@ -0,0 +1,65 @@
+		<div id="chooselang">
+            [% INCLUDE 'misc/languages.tt' %]
+		</div>
+
+		<div class="logo">
+		</div>
+		
+		<div class="misc" id="misc">
+            [% IF website.defined() %]
+                [% website = website | html %]
+                <h1>[% 'Welcome on %s' | i18n | pretty_print('<a href="' _ website _ '">' _ hostname _ '</a>') %]</h1>
+            [% ELSE %]
+                <h1>[% 'Welcome on %s' | i18n | pretty_print(hostname) %]</h1>
+            [% END %]
+			
+			<form action="/auth.pl" method="post" accept-charset="utf-8">
+			<h2>[% 'Please enter your username and password' | i18n %]</h2>
+                [% INCLUDE 'misc/errors.tt' %]
+                [% INCLUDE 'misc/infos.tt' %]
+				<p>
+					<label for="username">
+                        [% 'Username' | i18n | html %]
+					</label>
+					<input type="text" tabindex="1" name="username" id="username" maxlength="32" value="[% username | html %]"/>
+				</p>
+				<p>
+					<label for="password">
+						[% 'Password' | i18n | html %]
+					</label>
+						<input type="password" tabindex="2" name="password" id="password" maxlength="32" />
+				</p>
+				<p class="button">
+					<input type="submit" tabindex="3" value="[% 'Access to panel' | i18n %]" id="login_submit" name="login_submit"/>
+				</p>
+			</form>
+			<div id="sub_opts">
+			<ul>
+                [% IF subscription_allowed %]
+				<li>
+				<a class="loginLinks" href="/subscribe.pl">[% 'Subscribe' | i18n %]</a>
+				</li>
+				[% END %]
+				
+				<li>
+				<a class="loginLinks" href="/lost.pl">[% 'I\'ve lost my password' | i18n %]</a>
+				</li>
+			</ul>
+			</div>
+		</div>
+
+		<div class="foothome">
+        [% IF stats.defined() %]
+            <p>[% 'Woah, %s users and %s groups already trust %s' | i18n | pretty_print(stats.users, stats.groups, hostname) | html %]</p>
+        [% END %]
+        [% IF public_url.defined() %]
+		<p>
+			<a href="[% public_url | i18n %]">[% 'Go to public area' | i18n %]</a>
+		</p>
+        [% END %]
+		</div>
+
+
+		<div id="footer">
+			<a href="http://www.vhffs.org";>[% 'Run VHFFS %s (%s)' | i18n | pretty_print(version_info.version, version_info.name) %]</a>
+		</div>

Added: trunk/vhffs-panel/templates/layouts/anonymous.tt
===================================================================
--- trunk/vhffs-panel/templates/layouts/anonymous.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/layouts/anonymous.tt	2011-04-30 21:26:58 UTC (rev 1676)
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+	<title>[% title | html %]</title>
+	<link rel="stylesheet" type="text/css" href="/themes/[% theme %]/main.css"/>
+	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
+	<script language="javascript" type="text/javascript" charset="utf-8" src="/js/prototype.js"></script>
+	<script language="javascript" type="text/javascript" charset="utf-8" src="/js/commons.js"></script>
+	<script language="javascript" type="text/javascript" charset="utf-8" src="/js/tooltip.js"></script>
+</head>
+<body>
+[% PROCESS $template %]
+</body>
+</html>

Added: trunk/vhffs-panel/templates/misc/errors.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/errors.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/misc/errors.tt	2011-04-30 21:26:58 UTC (rev 1676)
@@ -0,0 +1,7 @@
+[% IF errors.defined() AND errors.size() %]
+    <div id="errors">
+[% FOREACH e IN errors %]
+        <p class="error">[% e.msg | html %]</p>
+[% END %]
+    </div>
+[% END %]

Added: trunk/vhffs-panel/templates/misc/infos.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/infos.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/misc/infos.tt	2011-04-30 21:26:58 UTC (rev 1676)
@@ -0,0 +1,8 @@
+[% IF infos.defined() AND infos.size() %]
+<div id="infos">
+[% FOREACH i IN infos %]
+    <p class="info">[% i.msg | html %]</p>
+[% END %]
+</TMPL_LOOP>
+</div>
+[% END %]

Added: trunk/vhffs-panel/templates/misc/languages.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/languages.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/misc/languages.tt	2011-04-30 21:26:58 UTC (rev 1676)
@@ -0,0 +1,3 @@
+[% FOREACH l IN languages %]
+    <a href="auth.pl?lang=[% l | html %]"><img src="/themes/[% theme %]/images/[% l | html %].png" alt="[% l %]"/></a>
+[% END %]


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