#!/usr/bin/tclsh # # (find-fline "/usr/lib/tcl8.0/") # (find-fline "/usr/lib/tcl8.0/http1.0/") # (find-fline "/usr/lib/tcl8.0/http1.0/http.tcl" "proc http_formatQuery") # (find-fline "/usr/lib/tcl8.0/http1.0/http.tcl" "proc http_get") # (find-es "tcl" "wiki_scripts") # (find-es "tcl" "wiki_extracting_pages") # (find-wiscritag "cgi_quote_html") # (find-wiscrifile "") # (find-wiscrifile "usecgi.tcl") # (find-wiscrifile "usecgi.tcl" "generate an edit page") # (find-wiscrifile "wikit.tcl" "GetPage") # (find-wiscritag "cgi_textarea") # (find-wiscritag "cgi_quote_html") package require http 1.0 proc getpage {wikiurl N} { set s [http_data [http_get $wikiurl/${N}@]] if {[regexp "\n" $s -> text]} { regsub -all {\"} $text {"} text regsub -all {\<} $text {<} text regsub -all {\>} $text {>} text regsub -all {\&} $text {&} text } else { error "Bad edit page" } return $text } proc sendpage {wikiurl N text} { set answer [http_data [http_get $wikiurl/$N.html \ -query [http_formatQuery C $text]]] } proc emacsheader {argv0 wikiurl N} { return \ "; To send back the edited version, place the cursor at the beginning ; of the first non-void line after the S-expression and do a C-x C-e. ; (shell-command-on-region (point) (point-max) \"$argv0 send $wikiurl $N\")\n\n\n" } if {$argc!=3} { puts stderr "Usage: $argv0 get|eget|send wikiurl pagenumber" puts stderr "Example: $argv0 eget http://www.mini.net/cgi-bin/wikit 33 | tee 33" puts stderr " then edit the file \"33\" with Emacs and follow the instructions there." exit 1 } foreach {action wikiurl N} $argv {} switch $action { get { puts -nonewline [getpage $wikiurl $N] } eget { puts -nonewline "[emacsheader $argv0 $wikiurl $N][getpage $wikiurl $N]" } send { sendpage $wikiurl $N [read stdin] } default { puts stderr "Bad action!" exit 1 } }