Adding images to local mode wikis

The following procedure can be used to add a gif image file to a stand alone wikit database (i.e. .tkd file). Note that images may only be viewed using the Tk interface currently. Support for the web (CGI) interface is in the suggestions box.

Assumptions

  • a directory named dir exist
  • a wikit database named wikit.tkd is in the directory (see [L1 ] for information on how to create a database)
  • a gif image file named image.gif is in the directory

Procedure

  • Open the wikit database using wikit.kit application.
  • Edit the page where the image is to added and add the following text [http://image.gif] where the image is to appear.
  • Save the changes to the page and exit wikit
  • Run the following command in the dir directory.
    % wikit -images scan wikit.tkd
    Scanning 17 wiki pages...
    1 urls added, 0 urls deleted
  • Then run this command in the dir directory.
    % wikit -images local wikit.tkd
    1 local images copied
  • The image is now loaded into the wikit database (so try it out :-)

Just tried it out (2005/04/12) with the latest wikit.kit and it did not work:

 error: invalid command name "export"
     while executing
 "export LocalImages"
     (in namespace eval "::Wikit" script line 2)
     invoked from within
 "namespace eval Wikit {
   export LocalImages

   proc ScanForInlinedImages {{db wdb}} {
     array set inlined {}
     mk::loop c wdb.pages {
       set ..."
     (file "S:/Temp/wikit.kit/lib/wikit/image.tcl" line 8)
     invoked from within
 "source S:/Temp/wikit.kit/lib/wikit/image.tcl"
     ("package ifneeded" script)
     invoked from within
 "package require Wikit::Image"

(2005/06/08)TJC Seems a small typo causes the problem. Extract the wikit.kit and go to wikit.vfs/lib/wikit/image.tcl and edit the line reading:

 namespace eval Wikit {
  export LocalImages

to read like:

 namespace eval Wikit {
  namespace export LocalImages

And things should work right. Good luck.


wikit -image Options

tclkit wikit.kit -images scan wikit.tkd
Scans all pages, updating an "image cache" inside the wikit.tkd datafile (this does not fetch images, it just updates that cache) repeated calls are incremental: adds new / deletes unused items
tclkit wikit.kit -images list wikit.tkd
Lists all entries currently in the image cache, with fetch/file dates
tclkit wikit.kit -images get wikit.tkd
This goes through the image cache and fetches any entries which have not been successfully fetched before (only images <= 100 Kb)
tclkit wikit.kit -images local wikit.tkd
Goes through caches, storing all images it can find in [pwd], i.e. updates and replaces what is in the cache with local file copies (can be used to add/replace, and to store images > 100 Kb)
tclkit wikit.kit -images clear wikit.tkd
Clear the image cache (does not compact the wikit datafile, but space will be re-use

Tom Krehbiel


How would you do it on windows? I got the following error when I tried it on windows.

  couldn't execute "C:\dir\wikit": invalid argument

YekSoon

You could do it in a Tcl-script, I'm working on that myself. If you have access to a *nix system you can do the actual scan and add there and just copy the wikit.tkd file to your windows box. It is a metakit database-file and as such platform independent. - VL

30sep03 jcw - You could also use tclkitsh.exe, the command-line version of tclkit, and type "tclkitsh wikit.kit -images list wikit.tkd", etc.


26nov03 Came across this and thought I'd give it a try. Followed the instructions, added a gif image, and was able to view it in local mode. When I tried running the wikit in httpd mode, however, the image did not display in netscape. An old version of netscape showed a 'broken' image icon; netscape 7.0 didn't display anything. Is it possible to add images in local mode and then use the '.tkd file in server mode, or did I miss something (likely) in adding the image in the first place?

Ah, that'd make the story complete. Unfortunately, no: httpd mode was added more recently (first r/o, now also r/w), and no one has yet coded the logic to serve images from the local data. The first reason to get those images in was for embedded help wiki's. T'would indeed be nice to close that httpd gap... -jcw

Wow! Thanks for the quick reply. I'd love to help, but I'm really not sophisticated enough with TCL and web programming to handle it. I certainly do appreciate all the work you folks have done. As a personal wiki it works great!


only gif ? how about jpeg ?

LV typically what you see is people making use of the features within the core tcl and tk environment. Since jpg, png, etc. are all available via a binary extension that depends on a variety of external libraries, it is less likely to see said support out of the box. However, if someone were to come along and write some conditional code to support a feature they needed, and then were to turn it over to the maintainers, perhaps said code would appear in a future release...


This bothering people very much. Why not use other wiki system, such as TWiki, JSPWiki, or DokuWiki?

Because we want to use this wiki system. If someone is so bothered, they can always start their own wiki using some other software.


I run the script, return the following error message:

% tclkit wikit.kit test.tkd <Enter>

tab stop "-9" is not at a positive distance tab stop "-9" is not at a positive distance

    while executing

".details tag configure hr -tabs expr 1-10"

    (command bound to event)