CGI::Wiki::Simple - A simple wiki application using CGI::Application.
This is an instant wiki.
use strict; use CGI::Wiki::Simple; use CGI::Wiki::Simple::Setup; # currently only for SQLite # Change this to match your setup use CGI::Wiki::Store::SQLite; CGI::Wiki::Simple::Setup::setup_if_needed( dbname => "mywiki.db", dbtype => 'sqlite' ); my $store = CGI::Wiki::Store::SQLite->new( dbname => "mywiki.db" ); my $search = undef; my $wiki = CGI::Wiki::Simple->new( TMPL_PATH => "templates", PARAMS => { store => $store, })->run;
It might be the case that you don't want to use HTML::Template, and in fact, no templates at all. Then you can simple use the following example as your wiki, which does not rely on HTML::Template to prepare the content :
use strict; use CGI::Wiki::Simple::NoTemplates; use CGI::Wiki::Store::MySQL; # Change this to match your setup my $store = CGI::Wiki::Store::MySQL->new( dbname => "test", dbuser => "master", dbpass => "master" ); my $search = undef; my $wiki = CGI::Wiki::Simple::NoTemplates ->new( PARAMS => { store => $store, })->run;
new passes most of the parameters on to the constructor of CGI::Wiki. If HTML::Template is not available, you'll automagically get a non-templated wiki in the subclass CGI::Wiki::Simple::NoTemplates. Note that CGI::Application lists HTML::Template as one of its prerequisites but also works without it.
new
The setup method is called by the CGI::Application framework when the application should initialize itself and load all necessary parameters. The wiki decides here what to do and loads all needed values from the configuration or database respectively. These parameters are passed to the wiki via the PARAMS parameter of CGI::Application, as setup is not called directly. So the general use is like this :
setup
PARAMS
my $wiki = CGI::Wiki::Simple ->new( PARAMS => { header => "<hr /> My custom header <hr />", store => $store, })->run;
setup takes a list of pairs as parameters, one mandatory and some optional :
store => $store
The store entry must be the CGI::Wiki::Store that this wiki resides in.
header => "<hr />My own wiki<hr />"
This is the header that gets printed before every node. The default is some simplicistic table to contain the wiki content. This is only used if you don't use templates, that is, if the wiki isa CGI::Wiki::NoTemplates.
isa
footer => "<hr />This node was presented by me<hr />"
This is the footer that gets printed after every node. Also only used when no (other) templates are in use.
style => "http://www.example.com/style.css",
This is the stylesheet to use with your page. Also, this is only used if you don't use templates. The default is no style sheet.
Most of the parameters to the constructor of CGI::Wiki can also be passed here and will be passed on to the CGI::Wiki object.
The teardown sub is called by CGI::Application when the program ends. Currently, it does nothing in CGI::Wiki::Simple.
teardown
node_link creates a link to a node suitable to use as the href attribute. The arguments are :
node_link
href
node => 'Node title' mode => 'display' # or 'edit' or 'commit'
The default mode is display.
display
inside_link is a convenience function to create a link within the Wiki. The parameters are :
inside_link
title => 'Link title' target => 'Node name' node => 'Node name' # synonymous to target mode => 'display' # or 'edit' or 'commit'
If title is missing, target is used as a default, if mode is missing, display is assumed. Everything is escaped in the right way. This method is mostly intended for plugins. A possible API change might be a move of this function into CGI::Wiki::Simple::Plugin.
title
target
mode
This is the accessor method to the contained CGI::Wiki class.
Renders either the display page or a page indicating that there was a version conflict.
Loads some values for the subsequent rendering.
Many thanks must go to Kate Pugh, for writing CGI::Wiki and for testing and proofreading this module.
Max Maischein (corion@cpan.org)
Copyright (C) 2003 Max Maischein. All Rights Reserved.
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
CGI::Wiki,CGI::Application
To install CGI::Wiki::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Wiki::Simple
CPAN shell
perl -MCPAN -e shell install CGI::Wiki::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.