NAME
SoggyOnion::Plugin - how to extend SoggyOnion
SYNOPSIS
# sample plugin that uses a file as its resource.
# needs a 'filename' key in the item hash in the config
package SoggyOnion::Plugin::File;
sub init {
my $self = shift;
die "I have no filename"
unless exists $self->{filename};
}
sub mod_time {
my $self = shift;
return [ stat $self->{filename} ]->[9];
}
sub content {
open( FH, "<$self->{filename}" ) or die $!
my $data = join('', <FH>);
close FH;
return $data;
}
DESCRIPTION
This is the base class for all SoggyOnion plugins.
METHODS
new( $hashref )
Constructor that SoggyOnion gives a hash of information. Can be used for the plugin's own stash.
init()
This is called before we call mod_time and/or content. I use it to set the useragent in LWP::Simple in a few modules.
id()
Return the ID is used for <DIV> tags and internal caching stuff. This is a simple accessor that makes the code cleaner.
mod_time()
The default mod_time method ensures that the resource is always refreshed (cache is never used).
content()
Return XHTML content.
SEE ALSO
AUTHOR
Ian Langworth, <ian@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Ian Langworth
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.