d4e974 | // This is a roxen module. Copyright © 1996 - 2000, Roxen IS. | |||
9c20b9 | // This is a small sample module. It is intended to show a simple example // of a container. | |||
327252 | // This variable is shown in the configinterface as the version of the module. | |||
d4e974 | string cvs_version = "$Id: fnord.pike,v 1.8 2000/02/24 05:39:03 nilsson Exp $"; | |||
6682b9 | // Tell Roxen that this module is threadsafe. That is there is no // request specific data in global variables. int thread_safe=1; | |||
327252 | // Include and inherit code that is needed in every module. | |||
9c20b9 | #include <module.h> inherit "module"; | |||
327252 | ||||
9c20b9 | // Documentation: | |||
327252 | ||||
9c20b9 | // The purpose of this module is to allow comments in the SPML source // that are invisible to average viewers, but can be seen with the // right magic incantation. Fnord! The special text is rendered in // the "sample" font, if available, which makes it possible for // someone looking at the mixed output to distinguish text that is for // public consumption from that which is restricted. | |||
327252 | ||||
9c20b9 | // See also <COMMENT> which is similar, but always removes the // enclosed text. | |||
327252 | ||||
9c20b9 | // If you have a section of text (with markup, if desired) that you // may be planning on adding later, but don't want to generally // activate (the pointers may not have all been done, yet) you can use // this. It has other uses, too. | |||
327252 | ||||
9c20b9 | // This is not a secure way to hide text, I would like to see a // version that requires authentication to turn on the "hidden" text, // but this simple version does not do that. | |||
327252 | ||||
9c20b9 | // To use this in your SPML, enter the "hidden" text between a <FNORD> // and </FNORD>, you can include any additional markup you desire. // You may want to have a <P> or two to set it off, or use // <BLOCKQUOTE> inside. Here's a simple example: | |||
327252 | ||||
9c20b9 | // The text that everyone sees. <FNORD>With some they // don't.</FNORD> And then some they do. | |||
327252 | ||||
9c20b9 | // Since the excised text may be part of a sentence flow, its removal // may disrupt the readability. In this case an ALT attribute can be // used on the FNORD to give text for the mundanes to see. This text // should not have markup (some kinds might work, but others might // not). Here's an example of how that might be used: | |||
327252 | ||||
9c20b9 | // This server <FNORD ALT="provides">will provide, when we // actually get to it,</FNORD> complete source for the ... | |||
327252 | ||||
9c20b9 | // The way the normally hidden text is made visible is by including // "fnord" in the prestates (i.e. add "/(fnord)" before the "filename" // part of the URL). // Michael A. Patton <map@bbn.com> | |||
327252 | // 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. | |||
9c20b9 | // 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 | |||
327252 | string container_fnord(string tag_name, mapping arguments, string contents, RequestID id ) { if (id->prestate->fnord) return contents; if (arguments->alt) return arguments->alt; return ""; | |||
9c20b9 | } | |||
a8124d | // Some constants that are needed to register the module in the RXML parser. | |||
9c20b9 | ||||
a8124d | constant module_type = MODULE_PARSER; constant module_name = "Fnord!"; constant module_doc = "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.</p>"; | |||
327252 | // 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 |