Roxen.git/
server/
modules/
examples/
fnord.pike
Branch:
Tag:
Non-build tags
All tags
No tags
1999-12-14
1999-12-14 01:47:21 by Martin Nilsson <mani@lysator.liu.se>
327252fd80ed52375cd4fbf2b1ac14a1909d507f (
80
lines) (+
44
/-
36
)
[
Show
|
Annotate
]
Branch:
5.2
Updated to new styles and APIs
Rev: server/modules/examples/fnord.pike:1.6
1:
// This is a small sample module. It is intended to show a simple example // of a container.
-
// This variable is shown in the configinterface as the
varion
of the module.
-
string cvs_version = "$Id: fnord.pike,v 1.
5
1998
/
03
/
08
13
:
48
:
48
per
Exp $";
+
// This variable is shown in the configinterface as the
version
of the module.
+
string cvs_version = "$Id: fnord.pike,v 1.
6
1999
/
12
/
14
01
:
47
:
21
nilsson
Exp $";
// Tell Roxen that this module is threadsafe. That is there is no // request specific data in global variables. int thread_safe=1;
-
+
// Include and inherit code that is needed in every module.
#include <module.h> inherit "module";
57:
// Michael A. Patton <map@bbn.com>
+
// This is the code for the actual container. By naming it "container_"
+
// it is automatically recognized by Roxen as the code for a container
+
// tag and is registered in its list of container tags.
-
array register_module();
-
-
+
// First, check the 'request_id->prestate' multiset for the presence // of 'fnord'. If it is there, show the contents, otherwise, if there // is an 'alt' text, display it, if not, simply return an empty string
-
string
tag
_fnord(string tag, mapping
m
, string
q
,
object
request_
id )
+
string
container
_fnord(string tag
_name
, mapping
arguments
, string
contents
,
+
RequestID
id )
{
-
if
(m->help)
// This is a standard argument.
-
return register_module
(
)[2];
-
if (request_
id->prestate->fnord)
-
return
"<SAMP>"+q+"</SAMP>"
;
-
else
if (
m
->alt)
-
return
m
->alt;
-
else
+
if (id->prestate->fnord)
+
return
contents
;
+
if (
arguments
->alt)
+
return
arguments
->alt;
return ""; }
90:
{ return ({ MODULE_PARSER, "Fnord!",
-
("Adds an extra container tag,
'
fnord
'
that's supposed to make "
+
("Adds an extra container tag,
<
fnord
>
that's supposed to make "
"things invisible unless the \"fnord\" prestate is present." "<p>This module is here as an example of how to write a "
-
"very simple RXML-parsing module."),
+
"very simple RXML-parsing module.
</p>
"),
0, 1 }); }
-
// This is nessesary functions for all MODULE_PARSER modules.
-
mapping query_container_callers() { return (["fnord":tag_fnord,]); }
+
-
+
// Last, but not least, we want a documentation that can be integrated in the
+
// online manual. The mapping tagdoc maps from container names to it's description.
+
+
TAGDOCUMENTATION;
+
#ifdef manual
+
constant tagdoc=(["fnord":#"<desc cont>The fnord container tag hides its "
+
"contents for the user, unless the fnord prestate is used.</desc>"
+
"<attr name=alt value=string>An alternate text that should be written "
+
"in place of the hidden text.</attr>"]);
+
#endif