Introduction edit
Wikitool is a script to get information from the wikit metakit data file from the command line. It's special because it is coded in pure Tcl.The script can be downloaded from http://www.equi4.com/pub/sk/wikitool.tcl .To use this tool, cd into the directory where you have a wikit.tkd file - that's the data portion of the wikit. Then, executewikitool.tcl -lBe certain that you get the most current copy - as mentioned elsewhere, previous versions are not likely to work.The results you should expect to see, on stdout, consist of lines such as:
10: 2002/06/19 06:45:26 80.126.24.9 Jean-Claude WipplerThe format is:
Field: 1 2 3 4 5 page-number: last-update-date last-update-time last-updater's-IP page-title14apr03 jcw - There's another far more sophisticated "wikitool" by Tom Krehbiel; it's on sdarchive. Might be an idea to rename this thing to "wikiutil" or some such, just to avoid confusion...LV 2008-Jan-11 I am seeing, today, some peculiar results using Tom K's wikitool.kit against the .tkd from the latest incarnation's wikit.tkd file. Specifically, I run
wikitool.kit wikit.tkd xref page@pageand part of what I get out seems to indicate that some of the pages don't have references when they in fact do have references.Anyone else out there doing anything with this type of data?
Using Tom Krehbiel's wikitool.kit as CGI in tclhttpd edit
7 October 2003: I'd like to use the wikitool from Tom Krehbiel as a CGI, to maintain my own wiki which runs as a CGI inside my local tclhttpd.To do this, you have to adapt the "wikitool.kit" (found on http://www.tcl.tk/starkits/wikitool.kit), to avoid a "package require Tk". So do an:sdx unwrap wikitool.kitand then
- in "main.tcl" surround "wm withdraw ." with a catch
- and in "lib/wikit.vfs/lib/wikit/wikit.tcl" surround "package require Tk" with a catch and remove or uncomment the "exit .." in case of a failure of "package require Wikit::Gui"
sdx wrap wikitool.kitFurthermore you can use the following "wikitool_admin.cgi"-script and place it into your cgi-bin.
#!/bin/sh # \ exec tclsh84 "$0" ${1+"$@"} source cgilib.tcl # available commands set cmds { pages,report pages,out pages,html pages,index pages,add pages,update pages,fix images,report images,add images,update images,out xref,refs xref,page@page xref,page2image xref,image2page sweep,report sweep,mark sweep,unmark sweep,clean defrag } # little "Vignette"-like wrapper ... ugh proc SHOW {var} { upvar $var _var return [expr {[info exists _var] ? "$_var" : ""}] } # build up a select-box for all commands proc showCommands {cmds selected} { set result {} foreach cmd $cmds { append result "<option value=\"$cmd\"[expr {$selected == $cmd ? " selected" : ""}]>[split $cmd ,]</option>" } return $result } # initialize query-parameters to variable values foreach {key value} [Cgi_List] { set $key $value } if {![info exists commands]} { set commands [lindex $cmds 0] } puts "Content-Type: text/html" puts "" puts [subst {<html> <body> <form action="$env(SCRIPT_NAME)" method="get"> <table> <tr><th>Database</th><th>Commands</th><th>args</th></tr> <tr><td><input type="text" name="database" value="[SHOW database]"></td> <td><select name="commands">[showCommands $cmds [SHOW commands]]</select></td> <td><input type="text" name="arguments" value="[SHOW arguments]"></td></tr> </table> <input type="submit"> </form> <hr> <b>Result:</b><br> }] # call the wikitool with given parameters # set cmd "| tclkitsh.exe wikitool.kit wikit.tkd pages report" if {[info exists database]} { foreach {command subcommand} [split [SHOW commands] ,] {break} set cmd "| tclkitsh wikitool.kit $database $command $subcommand [SHOW arguments]" # for the defragmention we pass "y" the query "really defrag (y/n)" if {$command == "defrag"} { append cmd " << y" } puts "Executing: $cmd" if {[catch {open $cmd} fh] } { puts "Error: Can't open pipe. $fh" } set PIPE $fh fconfigure $PIPE -buffering none set OUTPUT "" puts "<pre>" while { [gets $PIPE DATA] >= 0 } { puts $DATA } puts "</pre>" catch {close $PIPE} msg } puts "<br>[SHOW cmd] finished.</body></html>" exit 0
- Place this script into the cgi-bin of your tclhttpd and place the "wikitool.kit" there as well.
- Furthermore you need the tclkitsh-program lying around somewhere in your path.
- Now take your wiki-data file (I assume "wikit.tkd") and place it into the cgi-bin-directory as well.
- go to http://<yourserver:andport>/cgi-bin/wikitool_admin.cgi
- Enter "wikit.tkd" as the "Database", choose "pages report" and GO
%..cgi-bin> tclkitsh wikitool.kit wikit.tkd pages reportputs something on the console? ...yes, it gives the correct output, but ... you were astute in asking me to check whether I had made the changes to wikitool. I had made the changes, but accidently copied the original wikitool.kit into cgi-bin instead of the modified version. I have it working now, just as you described it. Thanks again for your help!
'How do you use Tom Krehbiel's wikitool.kit ? Are there any explanatory notes for wikitool.kit commands/parameters? Yes...' Run wikitool.kit in TK GUI mode and see the command descriptions. If you are running wikitool.kit with the catch {tk} mods, wikitool_admin.cgi by Stefan Vogel (see above), through CGI, you won't see the command help! [31Aug04 CvK]
LV 2008-Apr-18 The latest .tkd data from the tcler's wiki, available from wiki database for offline use apparently is incompatible with the Krehbiel tool; at least, wikitool no longer extracts pages or generates reports.