1 package Maypole::Application;
5 use UNIVERSAL::require;
8 # funny little gimmick ;)
11 | \/ | __ _ _ _ _ __ ___ | | ___
12 | |\/| |/ _` | | | | '_ \ / _ \| |/ _ \
13 | | | | (_| | |_| | |_) | (_) | | __/
14 |_| |_|\__,_|\__, | .__/ \___/|_|\___|
15 |___/|_| -= VERSION =-
17 $banner =~ s/VERSION/$Maypole::VERSION/;
23 my ( $self, @plugins ) = @_;
24 my $caller = caller(0);
26 push @{"${caller}::ISA"}, $self;
28 if (/^\-Setup$/) { $caller->setup }
30 *{"$caller\::debug"} = sub { 1 };
31 warn "Debugging enabled";
33 elsif (/^-.*$/) { warn "Unknown flag: $_" }
36 # The plugin caller should be our application class
37 eval "package $caller; require Maypole::Plugin::$_";
38 if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" failed: $@) }
40 warn "Loaded plugin: Maypole::Plugin::$_" if $caller->debug;
41 unshift @ISA, "Maypole::Plugin::$_";
47 if ( $ENV{MOD_PERL} ) {
48 Apache::MVC->require or die "Loading Apache frontend failed: $@";
49 push @ISA, 'Apache::MVC';
52 CGI::Maypole->require or die "Loading CGI frontend failed: $@";
53 push @ISA, 'CGI::Maypole';
60 Maypole::Application - Maypole Universal Frontend
64 use Maypole::Application;
66 use Maypole::Application qw(Config::YAML);
68 use Maypole::Application qw(-Debug Config::YAML -Setup);
70 use Maypole::Application qw(Config::YAML Loader -Setup -Debug);
74 This is a universal frontend for mod_perl1, mod_perl2 and CGI.
76 You can omit the Maypole::Plugin:: prefix from plugins.
77 So Maypole::Plugin::Config::YAML becomes Config::YAML.
79 use Maypole::Application qw(Config::YAML);
81 You can also set special flags like -Setup and -Debug.
83 use Maypole::Application qw(-Debug Config::YAML -Setup);
85 The position of plugins and flags in the chain is important,
86 because they are loaded/executed in the same order they appear.
90 use Maypole::Application qw(-Setup);
94 use Maypole::Application;
99 use Maypole::Application qw(-Debug);
103 use Maypole::Application;
108 Sebastian Riedel, C<sri@oook.de>
109 Idea by Marcus Ramberg, C<marcus@thefeed.no>
113 You may distribute this code under the same terms as Perl itself.