A Tclet (Tcl Applet) is a Tcl script that is loaded by HTTP and executed in a safe Tcl interpreter in the Tcl Browser Plugin.
A Wiklet is a Tclet whose source code and means of execution are provided on a Wiki page. A Wiki page may have any number of independent Wiklets. This is a generalisation of the term 'Wiklet' as first used on the wiklets page by Brian Theado.
To see Wiklets in action, visit http://www.kerlin.net/22 which has the same Wiki-markup source as Wiklet Test Page
The Wiklet source is carried on a Wiki page as "pre-formatted" text. Wiklet source code is distinguished from other "pre-formatted" text by an initial line that is a Tcl comment, but that also contains an instruction to the server: a "Wiklet Instruction". Example Wiklet Instructions are:
# For one of these lines to have effect as a Wiklet Instruction, it must be the first line of a pre-formatted block. # wiklet 1 200 300 embed # wiklet 1 200 300 embed # wiklet 2 150 150 embed # wiklet 2 150 150 # wiklet 2 # wiklet {1 3}
Rules for Wiklet Instructions
Any Wiklet Block whose Wiklet Instruction includes the arguments for width and height will be displayed with an extra line inserted at the top, which is a Tcl comment with instructions and hyperlinks for using the Wiklet.
Embedding of Wiklets may be switched on or off by the user: it is off by default. The setting applies to the entire domain of the Wiki, and is controlled by a persistent cookie stored in the user's browser. The cookie is set and read by Javascript embedded in each Wiki page; its value is changed when the user clicks on an appropriate hyperlink. Although the cookie is sent to the server, the server neither uses, sets, nor stores its value.
If the page http://www.kerlin.net/22 has Wiklets with integer identifiers 1, 2, then these Wiklets have URLs http://www.kerlin.net/22.1.tcl , http://www.kerlin.net/22.2.tcl respectively.
The Wikit web server must be modified so that it
An alpha version of Wikit with the necessary modifications is available from [L1 ]. The patch (against the starkit and CVS of Wikit at 2006-06-25 17:00 UTC, which at that time were identical) is at [L2 ]. The patch has been submitted to JCW to be considered for a future official release of Wikit.
Remarks on pre-formatted text
In HTML, "pre-formatted" text is surrounded by <pre> ... </pre> tags, and is displayed in this Wiki with a grey background.
In Wiki markup, lines that begin with three spaces, a marker, and another space are rendered in HTML as bulleted, numbered, or tagged lists, for markers '*', '1.' and 'tagname:' respectively. Any other line that begins with a space is rendered in HTML as pre-formatted, and the text displayed in a browser is identical to its Wiki markup (including the leading space), with these exceptions:
This mangling of whitespace might occasionally be significant in Tcl source code, e.g. if it occurs inside a quoted string. The whitespace is accurately preserved in the Wiki markup.
Initial design by KJN.
Please add suggestions for improvements here, particularly any changes needed to "Wiklet Instructions" for any cases that are not yet handled...
Brian Theado 26Jun2006 - Nice work! I like that multiple wiklets can be embedded into each page. I like the way the embedding can be dynamically enabled and disabled.
It would be fun to also have this functionality available in local mode wikit. The wiki-runner page contains a sandbox function that can be used to run a chunk of code in a safe interpreter environment very similar to the tclplugin environment.
It would be a little easier to read the code for a given wiklet if there were a link that when clicked displays all the code for that wiklet. Otherwise you have to search through the page and mentally figure out which code is involved. But maybe that adds too much clutter and maybe it should be up to the wiklet author to arrange things in a readable fashion.