2007-12-31: Minor release with feature enhancements. More...
2007-09-08: Small bug fix release. More...
2007-06-29: Some bug fixes and one small feature enhancement. More...
This part of the homepage is out of date and will be updated soon!
There is a logging mechanism available for informational and debugging purposes. Four different log levels are available:
The methods are named after the log levels and can be invoked by using
logger.{debug|info|warn|error}
. You need to provide a string as argument or a block which returns
a string.
As webgen is plugin-based, it can be extended very easily. A simple example is shown in the tutorial.
If you want more sophisticated examples of plugins, have a look at webgen itself and the plugins
that get shipped with it. They can be found in the directory lib/webgen/plugins/
!
For this you need to write a new command class and put its file into the plugin
folder of the
website. Have a look at the cmdparse API reference
for information about how to write a command class.
There are basically two ways for a command plugin:
CmdParse::Command
and include the
Webgen::CommandPlugin
module. After you have included this module, you can use all standard
plugin directives, like summary
or add_param
. Also, this command gets automatically added to
the main CommandParser
class. Thus, the initialize
method must not take any arguments!
class SimpleCommand < CmdParse::Command include Webgen::CommandPlugin summary “Describe simple command” add_param ‘firstParam’, 45, ‘Description of firstParam’ def initialize super( ‘simple’, false ) self.short_desc = “This is a sample for a simple command.” end def usage; “Usage: #{@options.program_name} [global options] simple”; end def execute( args )end
- do something useful end
initialize
method of your command class needs to
arguments!!
Like before, you declare your new command class. This time however, you need include the
Webgen::PluginDefs
module and set the constant VIRTUAL
to true. This prevents the plugin
system from automatically instantiating an object. You then need to instantiate an object and add
it to the main CommandParser
class. This can be done by calling the add_cmdparser_command
of
the configuration plugin.
class OtherCommand < CmdParse::Command include Webgen::PluginDefs VIRTUAL = true summary “Describe other simple command” def initialize( arg ) super( ‘otherSimple’, false ) @arg = arg self.short_desc = “This is a second sample for a simple command.” end def usage; “Usage: #{@options.program_name} [global options] otherSimple”; end def execute( args )end Webgen::Plugin[‘Configuration’].add_cmdparser_command( OtherCommand.new( 5 ) )
- do something useful end