[Bps-public-commit] r16270 - in Pushmi/trunk: Pushmi-Admin/lib/Pushmi/Admin Pushmi-Admin/lib/Pushmi/Admin/View Pushmi-Admin/share/web/static/css

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Oct 10 16:09:42 EDT 2008


Author: alexmv
Date: Fri Oct 10 16:09:42 2008
New Revision: 16270

Added:
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View/
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View/Errors.pm
Modified:
   Pushmi/trunk/   (props changed)
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
   Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css

Log:
 r38097 at kohr-ah:  chmrr | 2008-10-10 16:09:24 -0400
  * Move errors into a subview
  * Refactor navigation
  * Start of a 'firstrun' page for configuration


Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm	Fri Oct 10 16:09:42 2008
@@ -4,13 +4,21 @@
 package Pushmi::Admin::Dispatcher;
 use Jifty::Dispatcher -base;
 
-# Check that we have a running memcached, or things get sad
-before qr{^/(?!static|errors|__jifty|favicon.ico)} => run {
+before qr{^/(?!static|errors|__jifty|=|favicon.ico|firstrun)(/|$)} => run {
+    # Check that we have a running memcached, or things get sad
     my $memcached = $Jifty::DBI::Record::Memcached::MEMCACHED;
-    return if $memcached->get_sock("");
-    redirect '/errors/memcached';
+    redirect '/errors/memcached' unless $memcached->get_sock("");
+
+    # Check that we have a hostname and password
+    my $root = URI->new(Jifty->config->app('apache')->{root});
+    redirect "/firstrun" if $root->host eq "localhost";
 };
 
+# Navigation
+before '**' => set 'navigation' => ['home'];
+before qr{/(index.html|firstrun)?$} => set 'navigation' => [];
+
+# Redirect to the created replica
 on '/created' => run {
     if (    Jifty->web->response->result("create")
         and Jifty->web->response->result("create")->success )
@@ -23,27 +31,26 @@
     }
 };
 
-on qr{^/replica/(.*?)(-\d{4}-\d{2}-\d{2})?\.gz$} => run {
+
+# Replica configuration
+on ['/replica/*', '/advanced/*'] => run {
+    my $name = $1;
+    $name =~ s/(-\d{4}-\d{2}-\d{2})?\.gz$//;
     my $replica = Pushmi::Admin::Model::Replica->new;
-    $replica->load_by_cols( clean_name => $1 );
+    $replica->load_by_cols( clean_name => $name );
     show '/errors/404' unless $replica->id;
     set replica => $replica;
-    show '/dump';
 };
 
-under '/replica/*' => run {
-    my $replica = Pushmi::Admin::Model::Replica->new;
-    $replica->load_by_cols( clean_name => $1 );
-    show '/errors/404' unless $replica->id;
-    set replica => $replica;
-    show '/replica';
+# Dump URLs -- the date doesn't actually matter, but provides a good filename
+on '/replica/*.gz' => run {
+    show '/dump';
 };
 
-under '/advanced/*' => run {
-    my $replica = Pushmi::Admin::Model::Replica->new;
-    $replica->load_by_cols( clean_name => $1 );
-    show '/errors/404' unless $replica->id;
-    set replica => $replica;
+# Replica display pages
+under '/replica' => show '/replica';
+under '/advanced' => run {
+    set 'navigation' => ['home', get 'replica'];
     show '/advanced';
 };
 

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	Fri Oct 10 16:09:42 2008
@@ -10,14 +10,22 @@
 use SVN::Client;
 use Jifty::Event::Log;
 
+require Pushmi::Admin::View::Errors;
+alias Pushmi::Admin::View::Errors under 'errors/';
 
-sub navigation {
-    my (@tokens) = @_;
-    if (@tokens) {
+# No salutation
+template '/salutation' => sub {};
+
+# Set up our own nav
+template '/menu' => sub {
+    my $tokens = get 'navigation';
+    return unless $tokens and @$tokens;
+    div {
+        { id is "pushmi-navigation" };
         div {
-            { id is "pushmi-navigation" };
+            { id is "centered-navigation" };
             my $seen;
-            for my $t (@tokens) {
+            for my $t (@$tokens) {
                 outs( " \x{27a4} " ) if $seen++;
                 if ($t eq "home") {
                     hyperlink( url => "/", label => "Replica list" );
@@ -25,34 +33,31 @@
                     hyperlink( url => "/replica/" . $t->clean_name, label => $t->name );
                 }
             }
-        };
-    } else {
-        div {
-            { id is "pushmi-navigation", class is "empty" };
         }
-    }
-}
+    };
+};
 
 template 'index.html' => page { title => "Pushmi Administration" } content {
     my $replicas = Pushmi::Admin::Model::ReplicaCollection->new;
     $replicas->unlimit;
-    navigation();
-    div {
-        { id is 'replica-list', class is 'roundbox' };
-        h2 {"Current replicas"};
-        while ( my $replica = $replicas->next ) {
-            div {
-                { class is 'replica-element' };
-                render_region(
-                    name         => "replica-" . $replica->id,
-                    path         => "/fragments/replica-element",
-                    arguments    => { id => $replica->id },
-                    lazy         => 1,
-                    loading_path => "/fragments/replica-loading",
-                );
-            };
-        }
-    };
+    if ($replicas->count) {
+        div {
+            { id is 'replica-list', class is 'roundbox' };
+            h2 {"Current replicas"};
+            while ( my $replica = $replicas->next ) {
+                div {
+                    { class is 'replica-element' };
+                    render_region(
+                        name         => "replica-" . $replica->id,
+                        path         => "/fragments/replica-element",
+                        arguments    => { id => $replica->id },
+                        lazy         => 1,
+                        loading_path => "/fragments/replica-loading",
+                    );
+                };
+            }
+        };
+    }
 
     div {
         { id is 'new_replica', class is 'roundbox' };
@@ -78,6 +83,14 @@
             }
         }
     };
+
+    div {
+        { id is 'configuration' }
+        hyperlink(
+            url   => "/configuration",
+            label => "Configuration.."
+        );
+    }
 };
 
 
@@ -126,7 +139,6 @@
 
     my $url = $new->argument_value('url'); $url =~ s{/+$}{};
     my $data = Pushmi::Admin->svn_info_for( $url, $new->argument_value("user"), $new->argument_value("password") );
-    navigation("home");
     div {
         { class is 'roundbox' };
         h2 {"Add a new replica"};
@@ -353,7 +365,6 @@
 
 template 'replica' => page { title => "About " . get("replica")->name } content {
     my $replica = get 'replica';
-    navigation("home");
     div {
         { class is 'roundbox' };
         h2 {"Replica status"};
@@ -402,7 +413,6 @@
 
 template 'advanced' => page { title => "Advanced configuration for " . get("replica")->name } content {
     my $replica = get 'replica';
-    navigation("home",$replica);
     div {
         { class is 'roundbox advanced_options' };
         h2 { "Advanced options for " . $replica->name . " replica" };
@@ -515,24 +525,11 @@
     $replica->dump;
 };
 
-template 'errors/memcached' => page { title => "Memcached is not running" } content {
-    my %config = Jifty::DBI::Record::Memcached->memcached_config;
-    div { { class is "pageerror"};
-        h2 { outs "The "; tt { "memcached"}; outs " server is not running"};
-        p {
-            outs "Pushmi uses the ";
-            tt { "memcached" };
-            outs " server to control locks, caching, and other needed services.  "
-                . "However, we cannot find a server running on @{$config{servers}}.";
-        };
-        p {
-            outs "Check that the ";
-            tt { "memcached" };
-            outs " server is running, then ";
-            hyperlink( url => "/", label => "try again" );
-            outs ".";
-        }
-    };
+template 'firstrun' => page { title => "Welcome to your Pushmi appliance!" } content {
+    div {
+        { class is "roundbox" };
+        h2 { "Pushmi configuration!" };
+    }
 };
 
 1;

Added: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View/Errors.pm
==============================================================================
--- (empty file)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View/Errors.pm	Fri Oct 10 16:09:42 2008
@@ -0,0 +1,44 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+BTDT::View::Reports
+
+=cut
+
+package Pushmi::Admin::View::Errors;
+use Jifty::View::Declare -base;
+
+template 'memcached' => page { title => "Memcached is not running" } content {
+    my %config = Jifty::DBI::Record::Memcached->memcached_config;
+    div { { class is "pageerror"};
+        h2 { outs "The "; tt { "memcached"}; outs " server is not running"};
+        p {
+            outs "Pushmi uses the ";
+            tt { "memcached" };
+            outs " server to control locks, caching, and other needed services.  "
+                . "However, we cannot find a server running on @{$config{servers}}.";
+        };
+        p {
+            outs "Check that the ";
+            tt { "memcached" };
+            outs " server is running, then ";
+            hyperlink( url => "/", label => "try again" );
+            outs ".";
+        }
+    };
+};
+
+template '404' => page { title => "File not found" } content {
+    my %config = Jifty::DBI::Record::Memcached->memcached_config;
+    div { { class is "pageerror"};
+        h2 { "File not found" };
+        p {
+            "We're sorry -- we can't find the file you're looking for.  "
+                . "The replica may no longer exist, for instance.";
+        };
+    };
+};
+
+1;

Modified: Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css	(original)
+++ Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css	Fri Oct 10 16:09:42 2008
@@ -5,7 +5,7 @@
   color:      #000;
 }
 
-#content {
+#content, #centered-navigation {
   margin-left: auto;
   margin-right: auto;
   background: #112;
@@ -13,11 +13,17 @@
   max-width: 500px;
 }
 
-#salutation, #navigation {
-  display: none;
+#content {
+  margin-top: 6em;
 }
 
 #pushmi-navigation {
+  position: absolute;
+  top: 0;
+  width: 100%;
+}
+
+#centered-navigation {
   border: 1px solid #334;
   background: #223;
   -moz-border-radius-bottomleft: 20px;  -webkit-border-bottom-left-radius: 20px;
@@ -27,11 +33,6 @@
   height: 1.5em;
 }
 
-#pushmi-navigation.empty {
-  border: 1px solid #112;
-  background: #112;
-}
-
 #pushmi-navigation a {
   margin: 0 0.5em;
 }
@@ -363,3 +364,13 @@
 #svn div.file{
   background: #223;
 }
+
+/* Configuration page and button */
+
+#configuration {
+  margin: 1em 0;
+  padding: 1em;
+  float: right;
+  background: #223;
+  -moz-border-radius: 5px; -webkit-border-radius: 5px;
+}



More information about the Bps-public-commit mailing list