[Bps-public-commit] r9221 - in SVKUI: . trunk/share/web/templates trunk/share/web/templates/project

clsung at bestpractical.com clsung at bestpractical.com
Thu Oct 4 05:10:48 EDT 2007


Author: clsung
Date: Thu Oct  4 05:10:45 2007
New Revision: 9221

Removed:
   SVKUI/trunk/share/web/templates/index2
   SVKUI/trunk/share/web/templates/projects
   SVKUI/trunk/share/web/templates/svksync
Modified:
   SVKUI/   (props changed)
   SVKUI/trunk/lib/SVKUI/Dispatcher.pm
   SVKUI/trunk/lib/SVKUI/View.pm
   SVKUI/trunk/share/web/templates/project/index.html

Log:
 r9312 at going04:  clsung | 2007-10-04 17:10:20 +0800
 - code clean up, prepare for beta release
 - Move most codes into TD
 Unsolved: 
 - SVKUI PubSub will display the following warning
   (in cleanup) Can't call method "remove_publisher" on an undefined value at /usr/local/lib/perl5/site_perl/5.8.8/IPC/PubSub/Publisher.pm line 61 during global destruction.
    at /usr/local/lib/perl5/site_perl/5.8.8/Jifty/DBI/Schema.pm line 174


Modified: SVKUI/trunk/lib/SVKUI/Dispatcher.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/Dispatcher.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/Dispatcher.pm	Thu Oct  4 05:10:45 2007
@@ -7,17 +7,13 @@
     $top->child( 'About' => url => '/about' );
     $top->child( 'Add Site' => url => '/addproject' );
     $top->child( 'List Site' => url => '/projects' );
-    Jifty->subs->add(
-	class       => 'Notification',
-	mode        => 'Top',
-	region      => "message",
-	render_with => 'notification',
-    );
-#    my @sids = Jifty->subs->list;
-#    foreach (@sids) {
-#	Jifty->subs->cancel($_);
-#	warn "Removing $_";
-#    }
+#   XXX: subscribe at '*' might not a good idea 
+#    Jifty->subs->add(
+#	class       => 'Notification',
+#	mode        => 'Top',
+#	region      => "message",
+#	render_with => 'notification',
+#    );
 }
 
 on qr'^/sync/([^/]+)/?$' => run {
@@ -42,39 +38,19 @@
     show '/project/index.html';
 };
 
-on qr'^/projects/?$' => run {
-    my $projects = SVKUI::Model::ProjectCollection->new();
-    $projects->unlimit();
-    set projects => $projects;
-    show '/projects';
-};
-
-on qr'^/index2/?$' => run {
-    my $projects = SVKUI::Model::ProjectCollection->new();
-    $projects->unlimit();
-    set projects => $projects;
-    show '/index2';
-};
-
 on qr'^/project/([^/]+)/?$' => run {
     my $name    = $1;
     warn "Got project $1";
 
     $name = URI::Escape::uri_unescape($name);
-    my $mirror = SVKUI::Model::Project->new();
-    $mirror->load_by_cols( name => $name );
-    unless ($mirror->id) {
+    my $project = SVKUI::Model::Project->new();
+    $project->load_by_cols( name => $name );
+    unless ($project->id) {
         redirect '/__jifty/error/project/not_found';
     }
-    set mirror => $mirror;
+    set project => $project;
     $message = "Welcome to SVKUI, project ".$name;
     set message => $message;
-#    Jifty->subs->add(
-#	class       => 'Notification',
-#	mode        => 'Top',
-#	region      => 'message',
-#	render_with => 'notification',
-#    );
     show '/project/index.html';
 };
 
@@ -139,7 +115,6 @@
     my $command = SVKUI::Model::Command->new();
     my $ret;
 
-#    my $rootpath = Jifty->config->app('checkoutroot')."/".$name;
     my $copath = SVK::Path::Checkout->copath (Jifty->config->app('checkoutroot'), $name);
     my $rootpath = $copath;
     warn $rootpath;
@@ -163,7 +138,7 @@
         show '/__jifty/error/command_failed';
     }
     set command => $command;
-    show '/ia/index.html';
+    show '/ia';
 };
 
 on qr'^/pullyu/([^/]+)/?$' => run {

Modified: SVKUI/trunk/lib/SVKUI/View.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/View.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/View.pm	Thu Oct  4 05:10:45 2007
@@ -97,32 +97,54 @@
     warn "sync/view entering...";
     title { _('Sync project') };
     h2 { _('Information') };
-#    outs_raw(
-#    );
     div {
 	{ id is 'jifty-result-popup' }
     };
+    Jifty->subs->add(
+	class       => 'Notification',
+	mode        => 'Top',
+	region      => "message",
+	render_with => 'notification',
+    );
     Jifty->web->region (name => 'message', path => '/__jifty/empty');
-    Jifty->web->region (name => 'syncing', path => '/svksync');
-#    if ($project->synced) {
-#	dl { 
-#	    dt {'This project already synced' }
-	    #set(message => 'yoyo');show('notify');
-#	    SVKUI::Event::Notification->new( 'haha' )->publish;
-#	    dt {Jifty->web->link( url => '/project/'.$project->name, label => "Go to project page");}
-#	}
-#    } else {
-#	set(message => 'test');show('notify');
-	#SVKUI::Event::Notification->new( 'ahaha' )->publish;
-#	if ($project->try_sync()) {
-#	    redirect '/__jifty/error/sync_failed';
-#	}
-#	dl { 
-#	    dt {'This project synced' }
-	    #    blockquote { SVKUI->output };
-#	};
-#    }
+#    Jifty->web->region (name => 'syncing', path => '/svksync');
+#    set ( project => $project, dosync => 0 );
+#    show ('/svksync2');
+#   XXX: show () will not have the same arguments passing when click
+    render_region (name => 'svksync2', 
+	force_path => '/svksync2',
+	force_arguments => { project_name => $project->name, dosync => 0 });
+};
 
+template 'svksync2' => sub { # TD implementation of share/web/templates/svksync
+    my $p_name = get('project_name');
+    my $project = SVKUI::Model::Project->new();
+    $project->load_by_cols( name => $p_name );
+    unless ($project->id) {
+        redirect '/';
+    }
+    my $dosync = get('dosync');
+    my $message;
+    if ($dosync > 0) {
+	h3 { "Syncing project $p_name ..." };
+    } else {
+	h3 { "$p_name does not synced..." };
+    };
+    dl {
+    if ($project->synced == 1) {
+	dt { Jifty->web->link( label => "Project synced", url => '/project/'.$p_name ); }
+    } elsif ($dosync == 0) {
+	dt { Jifty->web->link( label => "Sync $p_name", onclick => { args => { project_name => $p_name, dosync => 1 } }); }
+    };
+    }; # dl
+    if ($project->id and $dosync) {
+	if ($project->try_sync()) {
+	    $message = 'sync failed';
+	} else {
+	    $message = 'success';
+	};
+    }
+    div { $message };
 };
 
 template 'ia2/view' => page {
@@ -161,7 +183,6 @@
     }
     if ($ret) {
 	set mirror => $mirror;
-#        show ('error/failed');
 	show '/__jifty/error/command_failed';
     } else {
 	dl {
@@ -170,6 +191,54 @@
     }
 };
 
+template '/ia' => page { # TD implementation of share/web/templates/ia/index.html
+    my $cmd = get('command');
+    my $cmd_output = $cmd->output;
+    title { _('SVKUI Command Output') };
+    div {
+	{ id is 'jifty-result-popup' }
+    };
+    Jifty->subs->add(
+	class       => 'Notification',
+	mode        => 'Top',
+	region      => "message",
+	render_with => 'notification',
+    );
+    Jifty->web->region (name => 'message', path => '/__jifty/empty');
+    h2 { _('Output') }
+    div { {class is 'output' } 
+	outs_raw(qq{ $cmd_output })
+    }
+};
+
+template '/projects' => page { # TD implementation of share/web/templates/projects
+    title { _('Projects to SVKUI') };
+    div {
+	{ id is 'jifty-result-popup' }
+    };
+    Jifty->subs->add(
+	class       => 'Notification',
+	mode        => 'Top',
+    );
+    Jifty->web->region (name => 'message', path => '/__jifty/empty');
+    ul {
+	my $projects = SVKUI::Model::ProjectCollection->new;
+	$projects->unlimit();
+	redirect '/addproject' unless $projects->count;
+	Jifty->web->form->start;
+	while ( my $p = $projects->next ) {
+	    my $del = new_action(class => 'DeleteProject', record => $p, moniker => 'delete-project-'.$p->id);
+	    li {
+		div { Jifty->web->link( label=> $p->name, url => '/ia2/'.$p->name) }
+		div { $del->button( label    => 'Delete project',
+			    class    => 'delete',
+			    onclick  => qq|return confirm('Really delete this project?');| ) }
+	    }
+	}
+	Jifty->web->form->end;
+    }
+};
+
 template '/' => page {
     title { _('Welcome to SVKUI') };
     h2 { _('Available mirror sites') }
@@ -179,6 +248,8 @@
     Jifty->subs->add(
 	class       => 'Notification',
 	mode        => 'Top',
+	region      => "message",
+	render_with => 'notification',
     );
     Jifty->web->region (name => 'message', path => '/__jifty/empty');
     dl {

Modified: SVKUI/trunk/share/web/templates/project/index.html
==============================================================================
--- SVKUI/trunk/share/web/templates/project/index.html	(original)
+++ SVKUI/trunk/share/web/templates/project/index.html	Thu Oct  4 05:10:45 2007
@@ -1,13 +1,13 @@
 <%args>
-$mirror
+$project
 $message => undef
 </%args>
 <%init>
 my @outputs = SVKUI->peek->getlines;
 my $output = join "", @outputs;
-my $edit = Jifty->web->new_action(class =>'UpdateProject', record => $mirror);
+my $edit = Jifty->web->new_action(class =>'UpdateProject', record => $project);
 </%init>
-<&|/_elements/wrapper,title => $mirror->name &>
+<&|/_elements/wrapper,title => $project->name &>
 <div id="jifty-result-popup"></div>
 % if ($message) {
 <script>
@@ -18,9 +18,9 @@
 % }
 <div class="yui-gc">
     <div class="yui-u first">
-<h1><%$mirror->name%></h1>
+<h1><%$project->name%></h1>
 <blockquote>
-    <%$mirror->description%>
+    <%$project->description%>
 </blockquote>
 
 <h2>System Output Info</h2>
@@ -30,33 +30,33 @@
 <h2>Project site Info</h2>
 
 <h3>Repository browser</h3>
-<%Jifty->web->link( url => $mirror->url, label => $mirror->url)%>
+<%Jifty->web->link( url => $project->url, label => $project->url)%>
 
 <h4>Click to generate dump file</h4>
-<%Jifty->web->link( url => '/pullyu/'.$mirror->name, label => 'Pullyu')%>
+<%Jifty->web->link( url => '/pullyu/'.$project->name, label => 'Pullyu')%>
 
 <h3>Repository</h3>
-<% $mirror->repospath %>
+<% $project->repospath %>
 
 <h3>Local Repository</h3>
 
-% if ($mirror->localrepos) {
-<% $mirror->localrepos %>
+% if ($project->localrepos) {
+<% $project->localrepos %>
 <h4>Click to enter interactive mode</h4>
-<%Jifty->web->link( url => '/ia/'.$mirror->name, label => 'Commands')%>
+<%Jifty->web->link( url => '/ia/'.$project->name, label => 'Commands')%>
 % } else {
 <h4>Click to copy a local branch</h4>
-<%Jifty->web->link( url => '/copy/'.$mirror->name, label => 'Click here')%>
+<%Jifty->web->link( url => '/copy/'.$project->name, label => 'Click here')%>
 % }
 <h3>Local Repository revision</h3>
-% if ($mirror->revision == 0) {
+% if ($project->revision == 0) {
 <h4>Not checkout-ed yet <br>
 click to see checkout-ed files</h4>
-<%Jifty->web->link( url => '/ia2/'.$mirror->name.'/checkout', label => 'Checkout')%>
+<%Jifty->web->link( url => '/ia2/'.$project->name.'/checkout', label => 'Checkout')%>
 % } else {
-<% $mirror->revision %>
+<% $project->revision %>
 <h4>Browse checkout-ed files</h4>
-<%Jifty->web->link( url => '/browse/'.$mirror->name, label => 'List')%>
+<%Jifty->web->link( url => '/browse/'.$project->name, label => 'List')%>
 % }
 
 </div>



More information about the Bps-public-commit mailing list