[vhffs-dev] [1759] Use common template for SCM preferences.

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


Revision: 1759
Author:   beuss
Date:     2011-05-16 22:50:56 +0200 (Mon, 16 May 2011)
Log Message:
-----------
Use common template for SCM preferences.

By the way... No more HTML::Template in mercurial/prefs

Modified Paths:
--------------
    trunk/vhffs-panel/mercurial/prefs.pl
    trunk/vhffs-panel/svn/prefs.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/scm/
    trunk/vhffs-panel/templates/scm/prefs.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/mercurial/prefs.tmpl
    trunk/vhffs-panel/templates/svn/prefs.tt

Modified: trunk/vhffs-panel/mercurial/prefs.pl
===================================================================
--- trunk/vhffs-panel/mercurial/prefs.pl	2011-05-16 20:50:48 UTC (rev 1758)
+++ trunk/vhffs-panel/mercurial/prefs.pl	2011-05-16 20:50:56 UTC (rev 1759)
@@ -32,7 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -40,12 +39,7 @@
 use strict;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Object;
-use Vhffs::Panel::Template;
 use Vhffs::Services::Mercurial;
 
 my $panel = new Vhffs::Panel::Main();
@@ -65,72 +59,25 @@
 my $mercurial = Vhffs::Services::Mercurial::get_by_reponame( $vhffs , $repo_name );
 my $group = Vhffs::Group::get_by_gid( $vhffs , $mercurial->{'owner_gid'} );
 
-unless( defined $repo_name )
-{
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE => gettext( 'CGI Error !' ) );
-}
-elsif( !defined $mercurial )
-{
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE => gettext( 'Cannot get informations on this object' ) );
-}
-elsif( !$user->can_view( $mercurial ) )
-{
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
-}
-else
-{
+unless( defined $repo_name ) {
+    $panel->render('misc/message.tt', { message => gettext( 'CGI Error !' ) } );
+} elsif( !defined $mercurial ) {
+    $panel->render('misc/message.tt', { message => gettext( 'Cannot get informations on this object' ) } );
+} elsif( !$user->can_view( $mercurial ) ) {
+    $panel->render('misc/message.tt', { message => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) } );
+} else {
 	if(defined $cgi->param('save_prefs_submit') ) {
-		if(save_prefs()) {
-			exit;
-		}
+		save_prefs();
 	}
 
-	$template = new Vhffs::Panel::Template( filename => $templatedir."/panel/mercurial/prefs.tmpl" );
-
-	$panel->set_title( gettext("Admin Mercurial Repository") );    
-    
-	$template->param( TEXT_REPONAME => $mercurial->get_reponame );
-	$template->param( TITLE_PUBLIC => gettext("Public") );
-	$template->param( TEXT_PUBLIC => gettext("Is this a public repository ?") );
-	$template->param( PUBLIC_YES => gettext("Yes") );
-	$template->param( PUBLIC_NO => gettext("No") );
-	$template->param( TEXT_SEND => gettext("Modify") );
-	$template->param( TEXT_DELETE_CVS => gettext("Delete this repository") );
-	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. This mercurial repository will be DESTROYED.") );
-	$template->param( ASK_DELETE_CVS => gettext("Are you SURE you want DELETE this mercurial repository?") );
-	$template->param( YES => gettext("Yes I'm sure of what I do") );
-	$template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
-	$template->param( TEXT_DELETE => gettext("Delete") );
-
-	$template->param( VALUE_OID => $mercurial->get_oid );
-	$template->param( TEXT_ACL_ADMIN => gettext('Admin Rights on this object (ACL)') );
-	$template->param( EXPLAIN_ADMIN_ACL => gettext('You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it.') );
-	$template->param( ADMIN_ACL => gettext('Ok, go to ACL admin') );
-
-	$template->param( TITLE_OPT => gettext('Options') );
-	$template->param( TEXT_OPT_ML => gettext('Notify changes on mailing-list :'));
-	$template->param( TEXT_OPT_ML_REMINDER => sprintf( gettext('Don\'t forget to subscribe %s to your mailing list if you are filtering posts') , $vhffs->get_config->get_service('mercurial')->{notify_from} ) );
-	$template->param( TEXT_ML_NAME => $mercurial->{ml_name} );
-    
-	if( $mercurial->is_public == 1 )
-	{
-		$template->param( YES_SELECTED => "selected" );
-	}
-	else
-	{
-		$template->param( NO_SELECTED => "selected" );
-	}
-
-	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $mercurial );
-	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+    $panel->set_title( gettext("Modify Mercurial repository") );
+    my $vars = {};
+    $vars->{repository} = $mercurial;
+    $vars->{notify_from} = $vhffs->get_config->get_service('mercurial')->{notify_from};
+    $vars->{type} = 'mercurial';
+    $panel->render( 'scm/prefs.tt', $vars );
 }
 
-$panel->build( $template );
-$panel->display;
-
 sub save_prefs {
     my $public = $cgi->param('public');
     my $ml_name = $cgi->param('ml_name');

Modified: trunk/vhffs-panel/svn/prefs.pl
===================================================================
--- trunk/vhffs-panel/svn/prefs.pl	2011-05-16 20:50:48 UTC (rev 1758)
+++ trunk/vhffs-panel/svn/prefs.pl	2011-05-16 20:50:56 UTC (rev 1759)
@@ -40,7 +40,6 @@
 
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Object;
 use Vhffs::Services::Svn;
 
 my $panel = new Vhffs::Panel::Main();
@@ -63,14 +62,15 @@
 } elsif( !$user->can_view( $svn ) ) {
     $panel->render('misc/message.tt', { message => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) } );
 } else {
-    if(defined $cgi->param('prefs_save_submit')) {
+    if(defined $cgi->param('save_prefs_submit')) {
         save_prefs();
     }
     $panel->set_title( gettext("Modify Subversion repository") );
     my $vars = {};
     $vars->{repository} = $svn;
     $vars->{notify_from} = $vhffs->get_config->get_service('svn')->{notify_from};
-    $panel->render( 'svn/prefs.tt', $vars );
+    $vars->{type} = 'svn';
+    $panel->render( 'scm/prefs.tt', $vars );
 }
 
 sub save_prefs {

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-16 20:50:48 UTC (rev 1758)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-16 20:50:56 UTC (rev 1759)
@@ -90,7 +90,6 @@
 	misc/simplemsg.tmpl \
 	git/create.tmpl \
 	git/prefs.tmpl \
-	mercurial/prefs.tmpl \
 	bazaar/create.tmpl \
 	bazaar/prefs.tmpl \
 	cron/create.tmpl \
@@ -132,8 +131,8 @@
 	pgsql/create.tt \
 	repository/create.tt \
 	repository/prefs.tt \
+	scm/prefs.tt \
 	svn/create.tt \
-	svn/prefs.tt \
 	user/prefs.tt \
 	web/create.tt \
 	web/prefs.tt

Deleted: trunk/vhffs-panel/templates/mercurial/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mercurial/prefs.tmpl	2011-05-16 20:50:48 UTC (rev 1758)
+++ trunk/vhffs-panel/templates/mercurial/prefs.tmpl	2011-05-16 20:50:56 UTC (rev 1759)
@@ -1,70 +0,0 @@
-<h2><TMPL_VAR ESCAPE=1 NAME="TITLE_PUBLIC"></h2>
-
-
-<form method="post" action="/mercurial/prefs.pl" accept-charset="utf-8">
-	<p>
-		<label for="public">
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_PUBLIC"> :
-		</label>
-		<select name="public" id="public">
-			<option value="1" <TMPL_VAR ESCAPE=1 NAME="YES_SELECTED">><TMPL_VAR ESCAPE=1 NAME="PUBLIC_YES"></option>
-			<option value="0" <TMPL_VAR ESCAPE=1 NAME="NO_SELECTED">><TMPL_VAR ESCAPE=1 NAME="PUBLIC_NO"></option>
-		</select>
-	</p>
-<h2><TMPL_VAR ESCAPE=1 NAME="TITLE_OPT"></h2>
-	<p>
-		<label for="ml_name"><TMPL_VAR ESCAPE=1 NAME="TEXT_OPT_ML"></label>
-                <input type="text" name="ml_name" id="ml_name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_ML_NAME">" />
-		<br/>
-		<TMPL_VAR ESCAPE=1 NAME="TEXT_OPT_ML_REMINDER">
-	</p>
-	<p class="button">
-		<input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="save_prefs_submit"/>
-	</p>
-</form>
-
-
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_ADMIN"></h2>
-		
-<form method="post" action="../acl/view.pl" accept-charset="utf-8">
-	<p><TMPL_VAR ESCAPE=1 NAME="EXPLAIN_ADMIN_ACL"></p>
-
-	<input type="hidden" name="target_oid" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_OID">" />
-	<p class="button" id="buttonAclAdmin">
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="ADMIN_ACL">" />
-	</p>
-</form>
-
-
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE_CVS"></h2>
-
-<form method="post" action="delete.pl" accept-charset="utf-8">
-	<fieldset class="delete">
-		<legend>
-			<TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_CVS">:
-		</legend>
-
-		<p class="warning"><TMPL_VAR ESCAPE=1 NAME="TEXT_BEFORE_DELETE"></p>
-		<p>
-			<input type="radio" name="DELETE" id="DELETE_NO"  value="0" checked="checked" />
-			<label for="DELETE_NO">
-				<TMPL_VAR ESCAPE=1 NAME="NO">
-			</label>
-		</p>
-		<p>
-			<input type="radio" name="DELETE" id="DELETE_YES" value="1" />
-			<label for="DELETE_YES">
-				<TMPL_VAR ESCAPE=1 NAME="YES">
-			</label>
-		</p>
-	</fieldset>
-	
-	<p class="button" id="buttonDelete">
-		<input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE">" />
-	</p>
-				
-</form>
-
-<TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">

Copied: trunk/vhffs-panel/templates/scm/prefs.tt (from rev 1758, trunk/vhffs-panel/templates/svn/prefs.tt)
===================================================================
--- trunk/vhffs-panel/templates/scm/prefs.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/scm/prefs.tt	2011-05-16 20:50:56 UTC (rev 1759)
@@ -0,0 +1,36 @@
+<form method="post" action="/[% type %]/prefs.pl" accept-charset="utf-8">
+<h2>[% 'Public' | i18n | html %]</h2>
+	<p>
+		<label for="is-public">[% 'Is this a public repository?' | i18n | html %]</label>
+		<select name="public" id="is-public">
+			<option value="1"[% ' selected="selected"' IF repository.is_public %]>[% 'Yes' | i18n | html %]</option>
+			<option value="0"[% ' selected="selected"' UNLESS repository.is_public %]>[% 'No' | i18n | html %]</option>
+		</select>
+	</p>
+[% IF repository.supports_notifications %]
+<h2>[% 'Options' | i18n | html %]</h2>
+	<p>
+		<label for="option">[% 'Notify changes on mailing-list:' | i18n | html %]</label>
+                <input type="text" name="ml_name" value="[% repository.ml_name | html %]" />
+		<br/>
+        [% 'Don\'t forget to subscribe %s to your mailing list if you are filtering posts.' | i18n | pretty_print(notify_from) %]
+	</p>
+[% END %]
+	<p class="button">
+		<input type="hidden" name="name" value="[% repository.get_reponame %]" />
+		<input type="submit" value="[% 'Update' | i18n | html %]" name="save_prefs_submit"/>
+	</p>
+</form>
+
+[% INCLUDE 'acl/form.tt' 
+    object = repository %]
+
+[% INCLUDE 'object/delete.tt'
+    type = type
+    oid = repository.get_oid %]
+
+[% IF current_user.is_admin %]
+    [% INCLUDE 'admin/object/edit.tt' 
+        object = repository %]
+[% END %]
+

Deleted: trunk/vhffs-panel/templates/svn/prefs.tt
===================================================================
--- trunk/vhffs-panel/templates/svn/prefs.tt	2011-05-16 20:50:48 UTC (rev 1758)
+++ trunk/vhffs-panel/templates/svn/prefs.tt	2011-05-16 20:50:56 UTC (rev 1759)
@@ -1,33 +0,0 @@
-<form method="post" action="/svn/prefs.pl" accept-charset="utf-8">
-<h2>[% 'Public' | i18n | html %]</h2>
-	<p>
-		<label for="is-public">[% 'Is this a public repository?' | i18n | html %]</label>
-		<select name="public" id="is-public">
-			<option value="1"[% ' selected="selected"' IF repository.is_public %]>[% 'Yes' | i18n | html %]</option>
-			<option value="0"[% ' selected="selected"' UNLESS repository.is_public %]>[% 'No' | i18n | html %]</option>
-		</select>
-	</p>
-<h2>[% 'Options' | i18n | html %]</h2>
-	<p>
-		<label for="option">[% 'Notify changes on mailing-list:' | i18n | html %]</label>
-                <input type="text" name="ml_name" value="[% repository.ml_name | html %]" />
-		<br/>
-        [% 'Don\'t forget to subscribe %s to your mailing list if you are filtering posts.' | i18n | pretty_print(notify_from) %]
-	</p>
-	<p class="button">
-		<input type="hidden" name="name" value="[% repository.get_reponame %]" />
-		<input type="submit" value="[% 'Update' | i18n | html %]" name="prefs_save_submit"/>
-	</p>
-</form>
-
-[% INCLUDE 'acl/form.tt' 
-    object = repository %]
-
-[% INCLUDE 'object/delete.tt'
-    type = 'svn'
-    oid = repository.get_oid %]
-
-[% IF current_user.is_admin %]
-    [% INCLUDE 'admin/object/edit.tt' 
-        object = repository %]
-[% END %]


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