[Jifty-commit] r7139 - in jifty/trunk/lib/Jifty/Plugin: .

Jifty commits jifty-commit at lists.jifty.org
Mon Jun 1 18:10:05 EDT 2009


Author: sartak
Date: Mon Jun  1 18:10:04 2009
New Revision: 7139

Modified:
   jifty/trunk/lib/Jifty/Plugin/SetupWizard.pm
   jifty/trunk/lib/Jifty/Plugin/SetupWizard/View.pm

Log:
Allow overriding of steps in the config

Modified: jifty/trunk/lib/Jifty/Plugin/SetupWizard.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/SetupWizard.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/SetupWizard.pm	Mon Jun  1 18:10:04 2009
@@ -3,7 +3,32 @@
 use warnings;
 use base 'Jifty::Plugin';
 
+__PACKAGE__->mk_accessors(qw(steps));
+
 sub prereq_plugins { 'Config' }
 
+sub init {
+    my $self = shift;
+    return if $self->_pre_init;
+
+    my %opt = @_;
+
+    if ($opt{steps}) {
+        $self->steps($opt{steps});
+    }
+    else {
+        $self->steps([
+            {
+                template => 'language',
+                header   => 'Choose a Language',
+            },
+            {
+                template => 'database',
+                header   => 'Database',
+            },
+        ]);
+    }
+}
+
 1;
 

Modified: jifty/trunk/lib/Jifty/Plugin/SetupWizard/View.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/SetupWizard/View.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/SetupWizard/View.pm	Mon Jun  1 18:10:04 2009
@@ -3,17 +3,6 @@
 use warnings;
 use Jifty::View::Declare -base;
 
-my @steps = (
-    {
-        template => 'language',
-        header   => 'Choose a Language',
-    },
-    {
-        template => 'database',
-        header   => 'Database',
-    },
-);
-
 template '/__jifty/admin/setupwizard' => page {
     my $appname = Jifty->config->framework('ApplicationName');
     h1 { "Welcome to $appname!" };
@@ -31,7 +20,8 @@
 
 template '/__jifty/admin/setupwizard/step' => sub {
     my $step = get('step');
-    my $step_info = $steps[$step] or abort(400);
+    my $steps = Jifty->find_plugin('Jifty::Plugin::SetupWizard')->steps;
+    my $step_info = $steps->[$step] or abort(400);
 
     div {
         class is 'setupwizard-step';
@@ -62,9 +52,10 @@
 
     my $index = $args{index};
 
-    return unless $index >= 0 && $index < @steps;
+    my $steps = Jifty->find_plugin('Jifty::Plugin::SetupWizard')->steps;
+    return unless $index >= 0 && $index < @$steps;
 
-    my $info = $steps[$index];
+    my $info = $steps->[$index];
     my $name = $info->{link} || $info->{header} || $info->{template};
 
     hyperlink(


More information about the Jifty-commit mailing list