[Bps-public-commit] r16962 - in sd/trunk/lib/App/SD: CLI/Command CLI/Command/Ticket Server

jesse at bestpractical.com jesse at bestpractical.com
Thu Nov 20 19:07:40 EST 2008


Author: jesse
Date: Thu Nov 20 19:07:39 2008
New Revision: 16962

Modified:
   sd/trunk/lib/App/SD/CLI/Command/Help.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm
   sd/trunk/lib/App/SD/Model/Ticket.pm
   sd/trunk/lib/App/SD/Server/Dispatcher.pm
   sd/trunk/lib/App/SD/Server/View.pm

Log:
* refactoring to improve the server view

Modified: sd/trunk/lib/App/SD/CLI/Command/Help.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Help.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Help.pm	Thu Nov 20 19:07:39 2008
@@ -56,8 +56,8 @@
 
 }
 
-__PACKAGE__->meta->make_immutable;
-no Moose;
+#__PACKAGE__->meta->make_immutable;
+#no Moose;
 
 1;
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm	Thu Nov 20 19:07:39 2008
@@ -56,7 +56,7 @@
     my $self = shift;
     my $ticket = shift;
 
-    return 1 if grep  { $_ eq $ticket->prop('status') } @{$self->app_handle->setting(label => 'active_statuses')->get()};
+    return 1 if $ticket->has_active_status();
     return 0;
 }
 

Modified: sd/trunk/lib/App/SD/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Ticket.pm	Thu Nov 20 19:07:39 2008
@@ -6,9 +6,13 @@
 use HTTP::Date;
 
 use constant collection_class => 'App::SD::Collection::Ticket';
-#use constant type => 'ticket';
+use constant type => 'ticket';
 
-has type => ( default => 'ticket');
+
+sub default_prop_milestone { 
+    my $self = shift; 
+    return $self->app_handle->setting(label => 'default_milestone')->get()->[0];
+}
 
 =head2 default_prop_status
 
@@ -17,16 +21,17 @@
 =cut
 
 
-sub default_prop_milestone { 
-    my $self = shift; 
-    return $self->app_handle->setting(label => 'default_milestone')->get()->[0];
-}
 
 sub default_prop_status { 
     my $self = shift; 
     return $self->app_handle->setting(label => 'default_status')->get()->[0];
 }
 
+sub has_active_status {
+    my $self = shift;
+    return 1 if grep { $_ eq $self->prop('status') } @{$self->app_handle->setting(label => 'active_statuses')->get()};
+}
+
 =head2 default_prop_reported_by
 
 Returns a string of the default value of the C<reported_by> prop.

Modified: sd/trunk/lib/App/SD/Server/Dispatcher.pm
==============================================================================
--- sd/trunk/lib/App/SD/Server/Dispatcher.pm	(original)
+++ sd/trunk/lib/App/SD/Server/Dispatcher.pm	Thu Nov 20 19:07:39 2008
@@ -1,11 +1,18 @@
 package App::SD::Server::Dispatcher;
 use Prophet::Server::Dispatcher -base;
 
-on qr/.*/ => sub {
-    next_rule;
-};
+on qr'^GET/(.*)$' => sub {show_template($1)->(@_)};
 
 redispatch_to 'Prophet::Server::Dispatcher';
 
 
+sub show_template {
+    my $template = shift;
+    return sub {
+        my $self = shift;
+        $self->server->show_template($template);
+    };
+
+}
+
 1;

Modified: sd/trunk/lib/App/SD/Server/View.pm
==============================================================================
--- sd/trunk/lib/App/SD/Server/View.pm	(original)
+++ sd/trunk/lib/App/SD/Server/View.pm	Thu Nov 20 19:07:39 2008
@@ -6,24 +6,23 @@
 use Prophet::Server::ViewHelpers;
 use base 'Prophet::Server::View';
 
-    use App::SD::Model::Ticket;
-    use App::SD::Collection::Ticket;
+use App::SD::Model::Ticket;
+use App::SD::Collection::Ticket;
+
 template head => sub {
     my $self = shift;
     my $args = shift;
     head {
         title { shift @$args };
-show('style');
+        show('style');
     }
 
 };
 
-
-
 template 'style' => sub {
 
-style {
-outs_raw('
+    style {
+        outs_raw( '
     body {
   font-family: sans-serif;
 }
@@ -72,65 +71,69 @@
 
 }
 
-');
-}
+' );
+    }
 };
 
-template '/' => 
-    page    { 'SD' }
-    content {
-         p { 'sd is a P2P bug tracking system.' };
-
+template '/' => page {'SD'}
+content {
+    p {'sd is a P2P bug tracking system.'};
     show('/bugs/open');
 
 };
 
-
 template '/bugs/open' => sub {
     my $self = shift;
-    my $bugs = App::SD::Collection::Ticket->new( app_handle => $self->app_handle, handle     => $self->app_handle->handle);
-    $bugs->matching( sub { my $item = shift; return $item->prop('status') ne 'closed'  ? 1 : 0; } );
-
-
-    h2 { 'Open bugs' };
-
-    div { class is 'buglist'; 
-
-    for my $bug (@$bugs) {
-    ul {
+    my $bugs = App::SD::Collection::Ticket->new(
+        app_handle => $self->app_handle,
+        handle     => $self->app_handle->handle
+    );
+    $bugs->matching( sub { my $item = shift; 
+         
+    return $item->has_active_status ? 1 : 0; 
     
-        li {
+    });
+    h2 {'Open bugs'};
 
+    div {
+        class is 'buglist';
+        
+        for my $bug (@$bugs) {
+            ul {
 
-            bug_link($bug => $bug->luid);
-            span { class is 'status'; $bug->prop('status') };
-            span { class is 'summary'; $bug->prop('summary') };
-            span { class is 'created'; $bug->prop('created') };
+                li {
 
-        }
+                    bug_link( $bug => $bug->luid );
+                    span { class is 'status';  $bug->prop('status') };
+                    span { class is 'summary'; $bug->prop('summary') };
+                    span { class is 'created'; $bug->prop('created') };
 
-    }
+                }
+
+            }
 
         }
     }
 };
 
-
 template '/show_bug' => page {
-    
 
-} content {
-
-
-};
+    } content {
 
+    };
 
 sub bug_link {
-        my $bug = shift;
-        my $label = shift;
-        span { class is 'bug-link'; a {{ class is 'bug';
-            href is '/bug/'.$bug->uuid; };
+    my $bug   = shift;
+    my $label = shift;
+    span {
+        class is 'bug-link';
+        a {
+            {
+                class is 'bug';
+                href is '/bug/' . $bug->uuid;
+            };
             $label;
-        }};
-    } 
+        }
+    };
+}
 1;



More information about the Bps-public-commit mailing list