[Bps-public-commit] r8736 - in SVKUI: . trunk/lib/SVKUI trunk/lib/SVKUI/Model trunk/share/web/templates

clsung at bestpractical.com clsung at bestpractical.com
Fri Aug 24 23:18:43 EDT 2007


Author: clsung
Date: Fri Aug 24 23:18:43 2007
New Revision: 8736

Modified:
   SVKUI/   (props changed)
   SVKUI/trunk/etc/config.yml
   SVKUI/trunk/etc/log.conf
   SVKUI/trunk/lib/SVKUI/Dispatcher.pm
   SVKUI/trunk/lib/SVKUI/Model/Project.pm
   SVKUI/trunk/lib/SVKUI/View.pm
   SVKUI/trunk/share/web/templates/event

Log:
 r8750 at going04:  clsung | 2007-08-23 15:12:52 +0800
 - Good with render_with TD (time2)
 r8751 at going04:  clsung | 2007-08-23 15:15:41 +0800
 - bunch of test codes to test PubSub/Jifty-popup
 r8752 at going04:  clsung | 2007-08-23 15:16:06 +0800
 - hey, use Fork/Prefork instead of single threaded server
 r8753 at going04:  clsung | 2007-08-23 15:18:24 +0800
 - should'nt use fork, pubsub should help me with that (?)
 r8754 at going04:  clsung | 2007-08-23 17:30:39 +0800
 - subscribe move to Dispatcher ( before '*')
 r8793 at going04:  clsung | 2007-08-25 11:18:24 +0800
 - now it can pop-up syncing information :)
 - thanks to clkao. for *local ....


Modified: SVKUI/trunk/etc/config.yml
==============================================================================
--- SVKUI/trunk/etc/config.yml	(original)
+++ SVKUI/trunk/etc/config.yml	Fri Aug 24 23:18:43 2007
@@ -70,3 +70,4 @@
     ServeStaticFiles: 1
     StaticRoot: share/web/static
     TemplateRoot: share/web/templates
+    ServerClass: Jifty::Server::Prefork

Modified: SVKUI/trunk/etc/log.conf
==============================================================================
--- SVKUI/trunk/etc/log.conf	(original)
+++ SVKUI/trunk/etc/log.conf	Fri Aug 24 23:18:43 2007
@@ -2,7 +2,7 @@
 # A simple root logger with a Log::Log4perl::Appender::File 
 # file appender in Perl.
 ############################################################
-log4perl.rootLogger=INFO, UIInfo, AppWarn, AppError, SVKUIInfo
+log4perl.rootLogger=INFO, UIInfo, AppWarn, AppError
 
 # Filter to match level ERROR
 log4perl.filter.MatchError = Log::Log4perl::Filter::LevelMatch
@@ -35,8 +35,3 @@
 log4perl.appender.UIInfo.layout=PatternLayout
 log4perl.appender.UIInfo.Filter   = MatchInfo
 log4perl.appender.UIInfo.layout.ConversionPattern=%m%n
-
-log4perl.appender.SVKUIInfo=Log::Log4perl::Appender::String
-log4perl.appender.SVKUIInfo.layout=PatternLayout
-log4perl.appender.SVKUIInfo.Filter   = MatchInfo
-log4perl.appender.SVKUIInfo.layout.ConversionPattern=%m%n

Modified: SVKUI/trunk/lib/SVKUI/Dispatcher.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/Dispatcher.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/Dispatcher.pm	Fri Aug 24 23:18:43 2007
@@ -7,6 +7,17 @@
     $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 $_";
+#    }
 }
 
 on qr'^/sync/([^/]+)/?$' => run {
@@ -51,6 +62,12 @@
     set mirror => $mirror;
     $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';
 };
 

Modified: SVKUI/trunk/lib/SVKUI/Model/Project.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/Model/Project.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/Model/Project.pm	Fri Aug 24 23:18:43 2007
@@ -3,6 +3,7 @@
 
 package SVKUI::Model::Project;
 use Jifty::DBI::Schema;
+use Data::Dumper;
 
 use SVKUI::Record schema {
 
@@ -98,22 +99,23 @@
 sub try_sync {
     my $self = shift;
     warn 'svk sync '.$self->repospath;
-    my $pid;
-    if ($pid = fork) {
-    } else {
-	while (!$self->synced) {
-	    my $line = SVKUI->peek->getline;
-	    #Syncing https://opensvn.csie.org/elixus
-	    #Retrieving log information from 1 to 73
-	    warn "hi";
-	    if ($line) {
-		warn $line;
-		SVKUI::Event::Notification->new($line)->publish;
-	    }
-	    sleep 0.5;
+    my $old_log = Log::Log4perl::Appender::File->can('log');
+
+    local *Log::Log4perl::Appender::File::log = sub {
+	my ($self, %param) = @_;
+
+	if ($self->{name} eq 'UIInfo') {
+	    my $message = $param{message};
+	    chomp($message);
+	    $message =~ s/\n//g;
+	    warn "publish UIInfo $message";
+	    SVKUI::Event::Notification->new($message)->publish;
 	}
-	exit;
-    }
+
+#	warn Dumper(%param);
+
+	goto $old_log;
+    };
     if (SVKUI->_svkcmd('sync', $self->repospath)) {
 	warn 'svk sync '.$self->repospath.' fail!';
 	return 1;

Modified: SVKUI/trunk/lib/SVKUI/View.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/View.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/View.pm	Fri Aug 24 23:18:43 2007
@@ -55,6 +55,39 @@
     }
 };
 
+template 'notify' => sub {
+    my $message = get('message');
+    script { { type is 'text/javascript' }
+	outs_raw(qq{ 
+	    var x = document.createElement("message")
+	    x.innerHTML = '$message'
+	    show_action_result("SVKUI",x)
+	    }) 
+    }
+    warn "hi here";
+};
+
+template 'notification' => sub {
+    my $message = get('event');
+    script { { type is 'text/javascript' }
+	outs_raw(qq{ 
+	    var x = document.createElement("message");
+	    x.innerHTML = "$$message";
+	    show_action_result("SVKUI",x);
+	    }) 
+    }
+};
+
+template 'time2' => sub {
+    my $event = get ('event');
+    span {
+	outs ($$event)
+    };
+    span {
+	outs ('hihih')
+    };
+};
+
 template 'sync/view' => page {
     my $name = get('project_name');
     my $project = SVKUI::Model::Project->new();
@@ -64,19 +97,31 @@
     }
     title { _('Sync project') };
     h2 { _('Information') };
+#    outs_raw(
+#    );
+    div {
+	{ id is 'jifty-result-popup' }
+    };
+    Jifty->web->region (name => 'message', path => '/__jifty/empty');
     if ($project->synced) {
 	dl { 
 	    dt {'This project already synced' }
+	    #set(message => 'yoyo');show('notify');
+	    warn "hi";
+	    SVKUI::Event::Notification->new( 'haha' )->publish;
+	    warn "there";
 	    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';
 	}
 	warn "Success?";
 	dl { 
 	    dt {'This project synced' }
-	    blockquote { SVKUI->output };
+	    #    blockquote { SVKUI->output };
 	};
 	warn "or fail?";
     }
@@ -135,6 +180,16 @@
 template '/' => page {
     title { _('Welcome to SVKUI') };
     h2 { _('Available mirror sites') }
+    div {
+	{ id is 'jifty-result-popup' }
+    };
+    Jifty->subs->add(
+	class       => 'Notification',
+	mode        => 'Top',
+	region      => "clock-time",
+	render_with => 'time2',
+    );
+    Jifty->web->region (name => 'message', path => '/__jifty/empty');
     dl {
 	my $mirrors = SVKUI::Model::ProjectCollection->new;
 	$mirrors->unlimit();

Modified: SVKUI/trunk/share/web/templates/event
==============================================================================
--- SVKUI/trunk/share/web/templates/event	(original)
+++ SVKUI/trunk/share/web/templates/event	Fri Aug 24 23:18:43 2007
@@ -13,9 +13,10 @@
 
 Jifty->subs->add(
     class       => 'Notification',
-    mode        => 'Replace',
+    mode        => 'Top',
     region      => "clock-time",
-    render_with => '/fragments/time',
+#    render_with => '/fragments/time',
+render_with => 'time2',
 );
 
 </%init>



More information about the Bps-public-commit mailing list