discourse-legacysite-perl/site/glist/templates/help/GT/Plugins.html
2024-06-17 22:24:05 +10:00

387 lines
9.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GT::Plugins - a plugin interface for Gossamer Threads products.</title>
<link rev="made" href="mailto:root@penguin.office.gossamer-threads.com" />
<style type="text/css">
/* $MVD$:fontset("Untitled Font Set 1","ARIEL","HELVETICA","HELV","SANSERIF") */
/* $MVD$:fontset("Arial","Arial") */
/* $MVD$:fontset("Arial Black","Arial Black") */
/* $MVD$:fontset("Algerian","Algerian") */
body {
background-color: white;
font-family: Verdana, Arial, sans-serif;
font-size: small;
color: black;
}
p {
background-color : white;
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
h1 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : medium;
background-color : white;
color : maroon;
}
h2 {
font-family : Verdana, Arial, sans-serif;
font-size : medium;
font-weight : bold;
color : blue;
background-color : white;
}
h3 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : medium;
color : black;
background-color : white;
}
h4 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : maroon;
background-color : white;
}
h5 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : blue;
background-color : white;
}
h6 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : black;
background-color : white;
}
ul {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
ol {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dl {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
li {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
th {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
td {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dl {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dd {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dt {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
code {
font-family : Courier;
font-size : small;
color : black;
}
pre {
font-family : Courier;
font-size : small;
color : black;
}
.mvd-H1 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : 14.0pt;
background-color : transparent;
background-image : none;
color : maroon;
}
.mvd-H2 {
font-family : Verdana, Arial, sans-serif;
font-size : 12.0pt;
color : blue;
}
p.indent {
font-family : "Verdana, Arial, sans-serif";
list-style-type : circle;
list-style-position : inside;
color : black;
margin-left : 16.0pt;
}
.mvd-P-indent {
font-family : Verdana, Arial, sans-serif;
list-style-type : circle;
list-style-position : inside;
color : black;
margin-left : 16.0pt;
}
pre.programlisting {
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
.mvd-PRE-programlisting {
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
.mvd-PRE {
font-size : 9.0pt;
}
p.note {
margin-left : 28.0pt;
}
.mvd-P-note {
margin-left : 28.0pt;
}
.mvd-H4 {
font-family : Verdana, Arial, sans-serif;
font-weight : normal;
font-size : 9.0pt;
color : black;
margin-left : 6.0pt;
margin-top : -14.0pt;
}
.mvd-P {
font-family : Verdana, Arial, sans-serif;
font-size : 10.0pt;
color : black;
}
.mvd-BODY {
font-family : Verdana, Arial, sans-serif;
background-color : white;
}
p.indentnobullet {
font-family : Verdana, Arial, sans-serif;
list-style-type : none;
}
.mvd-P-indentnobullet {
font-family : Verdana, Arial, sans-serif;
list-style-type : none;
}
</style>
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
<li><a href="#version">VERSION</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>GT::Plugins - a plugin interface for Gossamer Threads products.</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
use GT::Plugins;
$PLUGIN = GT::Plugins-&gt;new('/path/to/plugin/dir');</pre>
<pre>
$PLUGIN-&gt;dispatch(hook_name =&gt; \&amp;code_ref =&gt; @args);
$PLUGIN-&gt;dispatch_method(hook_name =&gt; $self =&gt; method =&gt; @args);</pre>
<p>Old style, now deprecated in favour of the object approach above:</p>
<pre>
use GT::Plugins;</pre>
<pre>
GT::Plugins-&gt;dispatch('/path/to/plugin/dir', hook_name =&gt; \&amp;code_ref =&gt; @args);
GT::Plugins-&gt;dispatch_method('/path/to/plugin/dir', hook_name =&gt; $self =&gt; method =&gt; @args);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The plugin module supports two modes of use. The first mode involves creating
and using a GT::Plugins object upon which plugin dispatch methods may be called
to provide hooks. The second does not use the object, but instead uses class
methods with an extra argument of the plugin path preceding the other
-&gt;<code>dispatch()</code> arguments.</p>
<p>Of the two approaches, the object approach is recommended as it is a) faster,
and b) requires much less value duplication as the plugin directory needs to be
specified only once. The old, class-method-based plugin interface should be
considered deprecated, and all new code should attempt to use the object-based
system.</p>
<p>A dispatch with each of the two interfaces work as follows, with differences in
interfaces as noted:</p>
<ol>
<li></li>
Loads the plugin config file. The actual file access and evaluation will be
cached, but a small amount of extra overhead is required on each dispatch.
This only applies to the deprecated class-method dispatch interface - the
preferred object interface loads the configuration file only once.
<p></p>
<li></li>
Runs any 'PRE' hooks registered in the config file. When using -&gt;dispatch(),
each hook is passed the <code>@args</code> arguments passed into -&gt;dispatch. When using
-&gt;dispatch_method(), both the object ($self) and arguments (@args) are passed
to the hook.
<p>Each plugin hook then has the ability to abort further plugins if desired by
calling <code>$PLUGIN-&gt;action(STOP)</code> (or <code>GT::Plugins-&gt;action(STOP)</code> for
the non-OO interface). STOP is exported by default from the GT::Plugins
module. Performing a STOP will skip both any further 'PRE' hooks and the
original function/method, and will use the hook's return value instead of the
real code's return value.</p>
<p>The current behaviour of 'PRE' hooks ignores the return value of any 'PRE' hook
that does not perform a STOP, however this behaviour <strong>may</strong> change to use the
return value as the arguments to the next PRE hook or actual code called. As
such, it is strongly recommended to return @_ from any 'PRE' hooks.</p>
<p></p>
<li></li>
Assuming <code>-&gt;action(STOP)</code> has not been called, the method
(-&gt;dispatch_method) or code reference (-&gt;dispatch) will be called, and its
return value stored.
<p></p>
<li></li>
Any registered 'POST' hooks registered in the config file will be run. When
using -&gt;dispatch(), the list-context return value of the main code run (or, if
a 'PRE' hook called STOP, the return value of that 'PRE' hook) will be passed
in. When using -&gt;dispatch_method(), the object is additionally passed in as
the first argument.
<p>The list returned by the 'POST' hook will be used as arguments for any
subsequent 'POST' hooks and as the final result returned by the -&gt;<code>dispatch()</code> or
-&gt;<code>dispatch_method()</code> call. There is one exception to this - for
-&gt;<code>dispatch_method()</code> 'POST' hooks, if the first argument of the return value is
the object, it will be removed; this is done to prevent a build-up of excess
objects at the beginning of the 'POST' hook arguments/return values due to
'POST' hooks simply returning @_ unaltered.</p>
<p></p>
<li></li>
The return value of the final 'POST' hook, or, when no post hooks are
configured, of the actual code, is returned as the result of the -&gt;<code>dispatch()</code>
call.
<p></p></ol>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p>Also included as part of the plugin system are some modules for web based tools
to manage plugins:</p>
<p><a href="glist.cgi?do=admin_gtdoc&topic=/GT/Plugins/Manager.html">the GT::Plugins::Manager manpage</a> - Add, remove and edit plugin files.</p>
<p><a href="glist.cgi?do=admin_gtdoc&topic=/GT/Plugins/Wizard.html">the GT::Plugins::Wizard manpage</a> - Create shell plugins.</p>
<p><a href="glist.cgi?do=admin_gtdoc&topic=/GT/Plugins/Installer.html">the GT::Plugins::Installer manpage</a> - Used in installing plugins.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 2005 Gossamer Threads Inc. All Rights Reserved.
<a href="http://www.gossamer-threads.com/">http://www.gossamer-threads.com/</a></p>
<p>
</p>
<hr />
<h1><a name="version">VERSION</a></h1>
<p>Revision: $Id: Plugins.pm,v 1.55 2005/04/01 00:16:51 brewt Exp $</p>
</body>
</html>