Updated 2008-03-11 18:27:20 by LV

Things I've used to muck with the contents of a wikit... JC

(2006-12-31: removed some very old pre-vfs wiki code -jcw)

Script to rename titles and compact the datafile

Here's a little script to manually make changes to wikit titles:
 #! /usr/bin/env tclkit
 # Rename (optional) and compact wikit file -jcw, 20020625

 lassign $argv inf outf page name
 if {$inf == ""} {
   puts stderr "Usage: $argv0 infile outfile ?pagenum newtitle?"
   exit 1

 mk::file open db $inf -readonly
 if {[file exists $outf]} { error "$outf: output file already exists" }

 if {$page != ""} {
   if {$name == ""} { error "no new title specified for page $page" }
   set oname [mk::get db.pages!$page name]
   puts "Changing name of page $page"
   puts "  old: $oname"
   puts "  new: $name"
   mk::set db.pages!$page name $name

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

 puts "Done, old size [file size $inf]b, new size [file size $outf]b."

Note that such title changes do not adjust references to the page, you will have to do that manually. Then again, if the change is just to alter capitalization, or fix a typo, this script does get the job done.

This script will write the resulting datafile to a new one with unused space removed. To finish the conversion, copy the new data over the old (when the datafile is not in use).

    ./renwikit wikit.tkd wikit.new 1 Wikit     # just to change case
    cat wikit.new >wikit.tkd && rm wikit.new   # preserves file mode

Scripts (GUI and non-GUI) to convert Tcl source code to "Wikit compatible" code (i.e. adding a whitespace in front of each line) can be found at WikIndent. I think this is worth mentioning because it is nice to have a cut-and-paste solution ready to paste into wish for a quick conversion without the need to think :P - [gg] - 2006-12-30

How to create and clean up a Wikit .tkd file