Jifty::Plugin::SetupWizard - make it easy for end-users to set up your app


Jifty documentation Contained in the Jifty distribution.

Index


Code Index:

NAME

Top

Jifty::Plugin::SetupWizard - make it easy for end-users to set up your app

DESCRIPTION

Top

    http://your.app/__jifty/admin/setupwizard

USAGE

Top

Add the following to your site_config.yml

 framework:
   Plugins:
     - SetupWizard: {}

METHODS

Top

init

Sets up a post_init hook.

add_step(%params)

Adds another step to the setup wizard. It will go at the end, but before the "finalize" step if it exists.

prereq_plugins

This plugin depends on Jifty::Plugin::Config.

COPYRIGHT AND LICENSE

Top


Jifty documentation Contained in the Jifty distribution.

package Jifty::Plugin::SetupWizard;
use strict;
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    => 'welcome',
                header      => 'Welcome',
                hide_button => 1,
            },
            # Not sure this is worth doing quite yet.
#            {
#                template => 'language',
#                header   => 'Choose a Language',
#            },
            {
                template => 'database',
                header   => 'Database',
            },
            {
                template => 'web',
                header   => 'Web',
            },
            {
                template    => 'finalize',
                header      => 'Finalize',
                hide_button => 1,
            },
        ]);
    }

    for my $step (@{ $opt{add_steps} || [] }) {
        $self->add_step(%$step);
    }
}

sub add_step {
    my $self = shift;
    my %step = @_;

    # Keep finalize at the end
    if ($self->steps->[-1]->{template} eq 'finalize') {
        splice @{ $self->steps }, -1, 0, \%step;
    }
    else {
        push @{ $self->steps }, \%step;
    }
}

1;

__END__