Several months ago, I wrote about how I was using pluggable mini applications with CGI::App in an application I was developing. Since then i have decided to write, if for no one besides myself, a module to handle this. I welcome any comments and suggestions.
There is one glaring issue that I need to figure out an elegant solution for and that is how to get a form to the main application from a plugin. At the moment I am using a terribly ugly hack (see 'plugin_button' below) to demonstrate the module. Any comments on this are certainly welcome.
Here is a quick overview of the module and how it is used. If the formatting of this email is garbled, go to http://hydo.hellyeah.org/?CGIAppPluginAnnounce . I will copy this email there.
In Ye Olde 'MyApp.pm'
package 'CGI::Application::Plugin';
sub setup {
my $self = shift;
$self->start_mode( 'menu' );
$self->plugin_init( '/www/plugins/for/this/app' );
$self->run_modes( { menu => 'main' } );
}
A plugin for MyApp:
package Plugin1;
sub new {
my $class = shift;
bless {
_run_modes => {
'plugin1_menu' => 'Plugin1::menu(\$self)',
}, $class;
}
sub get_modes {
return $_[0]->{_run_modes};
}
sub plugin_button {
my $self = shift;
return <<'';
<form method="POST" action="app.cgi">
<input type="hidden" name="rm" value="plugin1_menu">
<input type="submit" value="load plugin">
</form>
}
sub menu {
return <<'';
<h1>This method is inside Plugin.pm
}
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.