View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Max Maischein > CGI-Wiki-Simple-0.12 > CGI::Wiki::Simple::Plugin



Annotate this POD


New  3
Open  0
View/Report Bugs
Module Version: 0.09   Source  


CGI::Wiki::Simple::Plugin - Base class for CGI::Wiki::Simple plugins.


This is the base class for special interactive Wiki nodes where the content is produced programmatically, like the LatestChanges page and the AllNodes page. A plugin subclass implements more or less the same methods as a CGI::Wiki::Store - a later refactoring might convert all Plugin-subclasses to CGI::Wiki::Store subclasses or vice-versa.


  package CGI::Wiki::Simple::Plugin::MyPlugin;
  use strict;
  use Carp qw(croak);
  use CGI::Wiki::Simple::Plugin( name => 'MyPlugin' );

  sub retrieve_node_data {
    my ($wiki) = shift;

    my %args = scalar @_ == 1 ? ( name => $_[0] ) : @_;
    croak "No valid node name supplied"
      unless $args{name};

    # $args{name} is the node name
    # $args{version} is the node version, if no version is passed, means current
    # ... now actually retrieve the content ...
    my @results = ("Hello world",0,"");

    my %data;
    @data{ qw( content version last_modified ) } = @results;
    $data{checksum} = md5_hex($data{content});
    return wantarray ? %data : $data{content};

  # Alternatively, if your plugin can handle more than one node :
  package CGI::Wiki::Simple::Plugin::MyMultiNodePlugin;
  use strict;
  use CGI::Wiki::Simple::Plugin (); # No automatic import

  sub import {
    my ($module,@nodenames) = @_;
    CGI::Wiki::Simple::Plugin::register_nodes(module => $module, names => [@nodenames]);
syntax highlighting: