Question
Hello all,
Bit hesitant about asking this but have decided to confront my fear of looking foolish and just ask. Also the answer may be 'you wouldn't do that via a plugin' so the query may be misleading.
I discovered twiki about six weeks ago and at first simply didn't get it. Now I do and I love it. I've had several 'oh I get it moments' usually because I'm used to the windows way of doing things whereas twiki, perl and unix just do things in really easy, straightforward ways. My company is completely M$ and I'm advocating twiki instead of sharepoint. Good so far.
Now I want to add specific functionality that my boss is asking for - in this instance it's almost trivial in that he wants a folder's contents displaying nicely in a table rather than via the default dir listing that most browsers default to. The code for opening and reading the directory and adding it to an array is, as I've said above, trivial but here's where I hit a small brick wall.
After reading the plugin how-to, writing a plugin seems a bit overkill for a prettified directory listing but can you write perl directly into a template. This would be preferable as it maintains easy style sheet integration (which company requested) and sidesteps the issue of writing my first plugin ;-).
Not looking for someone to write anything, as I said the perl code is trivial, simply looking for pointers as to where to hook this in, doing it will be another learning experience.
Environment
--
SteveMayes - 21 Mar 2005
Answer
A folder's contents? What sort of folder? A TWiki web? Another non-TWiki folder on the server? Any folder, or just selected folders? Have you considered using WebDAV to give access to folders via Explorer (
not WebDAVPlugin, but
mod_dav)?
No, you can't write perl into a template (this would be a huge security hole) but a plugin would probably be trivial to do this, assuming you can answer the questions above. Just take EmptyPlugin.pm, rename it, follow the instructions and carve it to your requirements; you should only need to implement
commonTagsHandler.
--
CrawfordCurrie - 23 Mar 2005
Thanks for the response Crawford, I know that many of my questions are sometimes a bit basic but I appreciate the pointers.
I didn't specify where the folder was because, from my viewpoint as a sys admin, it is irrelevant; rsync means that I can place the folder on the Webserver anywhere I want regardless of the source directory, if a TWiki folder is easier I'll just rsync the contents there.
Regarding mod_dav (I assume you referred to Apache's implementation of RFC 2518), hmm, the description in RFC 2518 is:
This document describes an extension to the HTTP/1.1 protocol that allows clients to perform remote web content authoring operations. This extension provides a coherent set of methods, headers, request entity body formats, and response entity body formats that provide operations for:
Properties: The ability to create, remove, and query information about Web pages, such as their authors, creation dates, etc. Also, the ability to link pages of any media type to related pages.
Collections: The ability to create sets of documents and to retrieve a hierarchical membership listing (like a directory listing in a file system).
Doesn't this in some ways replicate TWiki functionality? Am quite interested in it especially as it utilises XML for data storage. The prettified display of folder contents is only the first step. Next I want to parse the files in the directory converting them from PDF to XML then I can use an XSL:FO file to re-serve them up as either PDF or HTML (did look at apache cocoon for this functionality but not got too far yet as that is a couple of steps along). But if I add mod_dav and Apache-cocoon to the Apache installation why would I continue with TWiki?
The bit that's got me slightly confused I suppose, especially as a neophyte perl scripter, is that I'd read the Plugin how to and other documentation but when I looked at either EmptyPlugin.pm or any other plugin all they contain is nothing but 'sub' declarations and I'm left looking for 'main' but I think I've just worked out that TWiki::Plugins calls these, itself being called by TWiki.pm (or simply TWiki to use the correct plugin nomenclature).
Is this correct?
Another oh! moment occured this morning when I worked out that the line "use TWiki::UI::Preview" means use TwikiLibDirectory(or PerlLibDirectory)\TWiki\UI\Preview.pm and I'm starting to get a better understanding of the structure and the logic of the application (now if only perl was so easy to obfuscate;-) ).
--
SteveMayes - 23 Mar 2005