[Jifty-commit] r6936 - in jifty/trunk: lib/Jifty/Plugin lib/Jifty/Plugin/Config lib/Jifty/Plugin/Config/Action

Jifty commits jifty-commit at lists.jifty.org
Mon May 4 02:50:50 EDT 2009


Author: sunnavy
Date: Mon May  4 02:50:49 2009
New Revision: 6936

Added:
   jifty/trunk/lib/Jifty/Plugin/Config/View.pm
Removed:
   jifty/trunk/share/plugins/Jifty/Plugin/Config/
Modified:
   jifty/trunk/lib/Jifty/Plugin/Config.pm
   jifty/trunk/lib/Jifty/Plugin/Config/Action/Config.pm
   jifty/trunk/lib/Jifty/Plugin/Config/Dispatcher.pm

Log:
replace mason pages with View.pm: so we can make config_url more flexible

Modified: jifty/trunk/lib/Jifty/Plugin/Config.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Config.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Config.pm	Mon May  4 02:50:49 2009
@@ -5,6 +5,9 @@
 use base qw/Jifty::Plugin Class::Data::Inheritable/;
 __PACKAGE__->mk_classdata( after_restart_url => '/' );
 __PACKAGE__->mk_classdata( wait_seconds => 5 );
+__PACKAGE__->mk_classdata( config_url => '/__jifty/config' );
+__PACKAGE__->mk_classdata(
+    restart_url => __PACKAGE__->config_url . '/restart.html' );
 
 =head2 NAME
 
@@ -18,6 +21,7 @@
     - Config:
         after_restart_url: '/'
         wait_seconds: 5
+        config_url: '__jifty/config'
 
 =head2  DESCRIPTION
 
@@ -27,9 +31,11 @@
 
 =head2 init
 
-set after_restart_url and wait_seconds, default is '/' and 5, respectively
-after_restart_url is the url we will redirect to after restart
+set after_restart_url, wait_seconds and config_url, 
+default is '/', 5 and '/__jifty/config', respectively
+after_restart_url is the url where we will redirect to after restart
 wait_seconds are the seconds that we wait for before redirecting
+config_url is the url where we will update the config
 
 =cut
 
@@ -42,6 +48,9 @@
     if ( $opt{wait_seconds} ) {
         __PACKAGE__->wait_seconds( $opt{wait_seconds} );
     }
+    if ( $opt{config_url} ) {
+        __PACKAGE__->config_url( $opt{config_url} );
+    }
 }
 
 1;

Modified: jifty/trunk/lib/Jifty/Plugin/Config/Action/Config.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Config/Action/Config.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Config/Action/Config.pm	Mon May  4 02:50:49 2009
@@ -65,7 +65,6 @@
     $self->report_success;
 
     Jifty->config->load;
-    Jifty->web->tangent( url => '/__jifty/config/restart.html' );
 
     return 1;
 }

Modified: jifty/trunk/lib/Jifty/Plugin/Config/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Config/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Config/Dispatcher.pm	Mon May  4 02:50:49 2009
@@ -29,7 +29,7 @@
     # for now leave check here, but we want Config to be
     # real plugin someday
     $top->child(
-        Configuration => url => "/__jifty/config/",
+        Configuration => url => Jifty::Plugin::Config->config_url,
         label         => _('Configuration'),
         sort_order    => 990,
     );

Added: jifty/trunk/lib/Jifty/Plugin/Config/View.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/Config/View.pm	Mon May  4 02:50:49 2009
@@ -0,0 +1,42 @@
+package Jifty::Plugin::Config::View;
+use strict;
+use warnings;
+
+use Jifty::View::Declare -base;
+
+__PACKAGE__->use_mason_wrapper;
+my $config_url = Jifty::Plugin::Config->config_url;
+my $restart_url = Jifty::Plugin::Config->restart_url;
+template $config_url => sub {
+    my $config = new_action( class => 'Config' );
+    form {
+        render_action( $config );
+        form_next_page( url => '/__jifty/config/restart.html' );
+        form_submit( label => _('Save and Restart') );
+    }
+};
+
+template $restart_url => sub {
+    my $seconds = get('seconds') || Jifty::Plugin::Config->wait_seconds || 5;
+    my $url = get('url') || Jifty::Plugin::Config->after_restart_url;
+    $url =
+        Jifty->config->framework('Web')->{BaseURL} . ':'
+      . Jifty->config->framework('Web')->{Port}
+      . $url
+      unless $url =~ /^https?:/;
+    outs_raw(<<"EOF");
+<html>
+<head>
+<title>restarting</title>
+<meta http-equiv="refresh" content="$seconds;url=$url" />
+</head>
+<body>
+<h1>please wait for $seconds seconds so the server can restart,
+    then we'll redirect to <a href="$url">here</a></h1>
+</body>
+</html>
+EOF
+
+    Jifty->handler->buffer->flush_output();
+    $Jifty::SERVER->restart;
+};


More information about the Jifty-commit mailing list