[Richard Suchenwirth] 2008-06-24 - The following is a rather small program, which may not fulfil all expectations people might have from a [Wiki]. It is * a stand-alone app, designed for use on [PDA]s for managing structured notes * presenting a set of pages which are connected by links (blue and underlined) * editable directly in the rendered page The markup language consists only of [[brackets]] around link names. Pages are created if they don't exist, when a link to them is clicked. [http://tclerswiki.googlegroups.com/pwiki.jpg] When a page is left, it is saved to the backing store. When the app exits, the contents of the backing store are saved to the file it was started with (or, if no name was given, ''pwiki.txt''). No warranty as usual, but enjoy :^) package require Tk set thisdir [info script]/.. proc main argv { global p history if {[llength $argv]==0} {set ::argv [list $::thisdir/pwiki.txt]} source [lindex $::argv 0] pack [scrollbar .y -command ".t yview"] -fill y -side right pack [text .t -wrap word -yscrollcommand ".y set" -font {Helvetica 10}] \ -fill both -expand 1 -side left .t tag configure head -font {Helvetica 16} .t tag configure link -foreground blue -underline 1 .t tag bind link <1> "click %W %x %y" bind .t {render %W [lindex $history end]} bind .t \] {after 10 [list render %W [lindex $history end]]} set history "" render .t "" bind . {save [lindex $::argv 0]} update idletasks catch {bind . {::etcl::autofit %W}} } proc render {w page} { if {$page eq "Back"} {set page [do_back $w]} if {$page eq "Index"} {do_index $w} global p history if {[lindex $history end] ne $page} {lappend history $page} set title [lindex [split [$w get 1.0 1.end] \t] 0] if {$title ne ""} { set p($title) [string trim [$w get 2.0 end] \n] ;# save previous page } $w delete 1.0 end if ![info exists p($page)] {set p($page) ""} $w insert end $page head \t "" Back link " - " "" Index link \n\n foreach line [split $p($page) \n] { foreach {nonlink link} [split $line {[]}] { $w insert end $nonlink if {$link ne ""} {$w insert end \[ "" $link link \] ""} } $w insert end \n } } proc click {w x y} { set range [$w tag prevrange link [$w index @$x,$y]] if [llength $range] {render $w [eval $w get $range]} } proc do_back w { global history set history [lrange $history 0 end-1] lindex $history end } proc do_index w { global p set p(Index) "" foreach i [lsort -dict [array names p]] { if {$i ne "Index"} {append p(Index) \[$i\]\n} } } proc save filename { global p set f [open $filename w] foreach i [lsort -dict [array names p]] { puts $f [list set p($i) $p($i)] } close $f } main $argv ---- !!!!!! %| [Category Example] |% !!!!!!