Updated 2009-10-28 16:33:11 by LV

How to create a .tkd database edit

If there isn't a .tkd file specified on the command line when wikit is started, then wikit will look in the current directory for a file named wikit.tkd. If it isn't found, wikit will automatically create one, filling it with a minimal set of pages. Once the wikit application is running, you just edit existing pages to create new pages. Be sure to read the built-in help for a description of how to edit/create pages. If a .tkd file has read-only file permissions, wikit is invoked with the -readonly command line argument, or the wikit.tkd is wrapped in a starkit, then the edit button will not appear.

Tom Krehbiel

How to add an image to a .tkd database edit

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

Reserved pages in the .tkd database edit

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)
 # the next line restarts this file using a tcl shell \
 exec tclkit "$0" -- ${1+"$@"}
 package require starkit
 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

When using wubwikit (also see [2]) in Tk mode, page 8 contains the table of contents.

How to delete pages from a .tkd database edit

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 delete pages from a .tkd database edit

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 edit

Tom Krehbiel wrote:
 > I am using an embedded 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

Two other tools useful for manipulating parts of the wikit are wikitool, which can list titles of pages or extract specific pages, and sdx, which is more for manipulating the wikit code itself.

I don't think I have seen a tool for manipulating the contents of a specific wikit page yet. If one were to exist, then one might, for instance, be able to create pages within a wikit (loading it with dynamic data, or whatever).

Stefan Vogel: An integration to use Tom Krehbiel's wikitool in a tclhttpd-cgi is in wikitool.

Questions edit

mfi: Why not add a button to the wiki GUI to delete a page?

LV The problem with deleting a page is to figure out what to do about all the references to the page. Certainly one solution is to just ignore the problem. That doesnt' seem all that helpful though; for one thing, once a page has a page title reference inserted, that assigns that title to the page. So just "deleting the page" isn't going to be able to do much more than deleting the contents... the title and page number are in the database.

Another solution would be to track down every reference to the page, and force the user to deal with it. Then, once there were no references to the page anywhere, deleting the page might be possible. This solution works well for a desktop application version of the wiki. However, for a web based wiki, there is no way to track down what bookmarks and other references might exist to the page.

LV - 2009-10-28 12:33:11

Hopefully, once the dust settles, someone who knows the current state of the wub wikit software will be able to craft comments/code changes/etc. to this page so that things work with the new sqlite based wikit.