Version 9 of How to create and clean up a Wikit .tkd file

Updated 2002-12-14 00:41:41

How to create a .tkd database

If there isn't a .tkd file specified when wikit is started then it will automatically create one. Once the wikit application is running you just edit existing pages to create new pages. Besure to read the built in help for a description of how to edit/create pages. If a .tkd file is read-only or is wrapped in a starkit then the edit button will not appear.

Tom Krehbiel


How to add an image to a .tkd database

See [L1 ] for information on how to add an image to a .tkd database.


Reserved pages in the .tkd database

The first 10 pages (0-9) in a .tkd database are reserved. The names of the first 10 pages can be listed using the following script (provided by Jean-Claude Wippler)

 #!/bin/sh
 # the next line restarts this file using a tcl shell \
 exec tclkit "$0" -- ${1+"$@"}
 package require starkit
 starkit::startup
 lappend auto_path [file join $::starkit::topdir app]
 mk::file open db wikit.tkd -readonly
 foreach x {0 1 2 3 4 5 6 7 8 9} {
     puts "$x - [mk::get db.pages!$x name]"
 }

If this script is run on a newly created .tkd it produces the following result.

 0 - My Wiki
 1 - Wikit
 2 - Search
 3 - Help
 4 - Recent Changes
 5 - History
 6 - Formatting Rules
 7 - 7
 8 - 8
 9 - Web Settings

How to clean up a .tkd database

Don't forget that the wikit data files are just Metakit databases, so you can just write a script to delete pages 10 and upwards.

Something like the attached ... use at your own risk :-)

To use, run

    tclkit wikiclear.tcl oldwiki newwiki

Newwiki mustn't exist, and oldwiki will be left intact.

Steve Landers

Script to clean up a .tkd database

The following wikiclear.tcl script was provided by Steve Landers.

 package require Mk4tcl

 lassign $argv inf outf
 if {$inf == "" || $outf == ""} {
     puts stderr "Usage: $argv0 infile outfile"
     exit 1
 }

 mk::file open db $inf -readonly
 if {[file exists $outf]} {
     puts stderr "$argv0: output file \"$outf\" already exists"
     exit 1
 }

 set pages [lrange [lsort -integer [mk::select db.pages]] 10 end]
 puts stderr "pages = $pages"
 foreach pg [lsort -decreasing $pages] {
     mk::row delete db.pages!$pg
 }
 puts stderr "pages = [lsort -integer [mk::select db.pages]]"

 set fd [open $outf w]
 mk::file save db $fd
 close $fd

How to rename the 'History' page

Tom Krehbiel wrote:

 > I am using an imbedded wikit to document my application. I just tried 
 > to create a page titled 'History' and found the it already
 > existed and had a message that read "This page is a place holder - do 
 > not change for now...". I really need to have a page titled
 > 'History' so my question is, what will happen if I edit the 'History' 
 > page?

Whoops - yes, this may cause trouble later on. Pages 0..9 have a special status (some unused but reserved). Better not start using them as normal ones.

My suggestion would be to make the following change to your wikit.tkd datafile, and then open again and you will be able to create a normal page titled "History":

 package require Mk4tcl
 mk::file open db wikit.tkd
 mk::set db.pages!3 name 3
 mk::view size db.refs 0
 mk::file close db

Put the above in a separate script and run it once while wikit is not active.

The "view size" command is there to reset all cross-references, so things will be re-built on next open. That first open make take a few seconds.

Untested code, but I think it should work. After this, page 3 is called "3".

Jean-Claude Wippler


Category WiKit