# 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
- A Wiklet Instruction can occur only as the first non-whitespace line of a block of pre-formatted text.
- A Wiklet Instruction begins with an arbitrary amount of whitespace, followed by '#', followed by a single space and the word 'wiklet'.
- If the first line of the pre-formatted text begins in any other way, it is not a Wiklet Instruction.
- The subsequent characters of a Wiklet Instruction are interpreted as a Tcl list which forms the arguments of the instruction.
- A block of pre-formatted text that begins with a Wiklet Instruction is a "Wiklet Block". A Wiklet Block contains Tcl source code.
- Each Wiklet on a page is identified by an integer. The source code for a Wiklet is the concatenation of all the Wiklet Blocks on that page that are labelled with that Wiklet's integer identifier.
- The first argument of the Wiklet Instruction is the integer identifier of the Wiklet to which the Wiklet Block belongs. Alternatively, this argument can be a list of integers - in this case, further arguments are ignored and the Wiklet Block belongs to each Wiklet whose identifier is in the list. This construct avoids the repetition on a Wiki page of code that is shared between multiple Wiklets.
- The second and third arguments, if present, are respectively the width and height in pixels of the Wiklet area.
- The fourth argument, if present, is 'embed', and indicates that the Wiklet should be embedded in the Wiki page above this Wiklet Block, when such embedding is enabled by the user.
- (1) serves a Wiklet (instead of HTML) when it receives a request for the appropriate URL. The Wiklet is Tcl source and its Content-Type is 'application/x-tcl'.
- (2) adds extra code to the HTML Wiki pages, to enable access to the Wiklets. This code consists of the extra line with hyperlinks inserted at the start of certain Wiklet Blocks (see above), the code to embed Wiklets in the Wiki page, and code to manage a cookie.
- trailing whitespace is removed from each line
- consecutive interior lines that are blank or consist only of whitespace are rendered in HTML as a single blank line
- leading and trailing lines that are blank or consist only of whitespace are not rendered in HTML
- if the pre-formatted block consists entirely of such lines, the block is not rendered in HTML
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.