Based on the code in [wiki-reaper], I put together a wish interface so that I could run it on my Windows system. I was able to use it to ''reap'' the [TkMapper] code automagically (quite an impressive program by the way). [GPS] - The reaping of the Wiki seems dangerous to me. Perhaps you should add checks for strings like "file delete" (possibly a glob del* pattern if file uses strncmp), and "rm " ''[escargo] 5 Jun 2003'' - If you want to be safe, then you could do any textual analysis on the code before you run it. ''Reaping'' only collects the code; you don't have to execute it if you do not want to. You can always read the code on the Wiki before you reap it, since "As you see, so shall ye reap." - [RS] 2004-03-06: Also, Tcl has [safe] interpreters for exactly this purpose: running untrusted code without danger... ---- ''Many of the applications in [Category Whizzlet] are reapable and entertaining.'' Pages that it can reap successfully include: * [3 Triangles] (8409) * [3D HIlbert Curve] (8723) * [A grep-like utility] (8405) * [A little A/D clock] (2563) * [A Little CIDR Calculator] (8909) * [A little drawing tool] (11198) * [A little font chooser] (3896) * [A little image viewer] (4025) * [A minimal editor explained] (9623) * [A Quick Demo of Enter and Leave Event Bindings] (14573) * [A Simple Fan Animation] (10820) * [A small font chooser] (9173) * [A Toy Piano] (3948, requires [snack]) * [A Very Simple Weather App] (10507) * [Alphabet Wheel] (9277) * [Analog widgets] (9107) * [Animated Vertical Tabs] (6253) * [another Asteroids] (13601) * [Another MDI] (9999) * [Arrow buttons] (8554) * [Atlantis Cafe Illusion] (12797) * [Azimuth Plotting] (11079) * [Bitmap Editor] (6298) * [Bouncing Balls] (8572) * [Buffon's Needle] (8407) * [Bulging Line Illusion] (8340) * [Can You Read This?] (13198) * [Canvas Rotation] (8595) * [Car racing in Tcl] (4364) * [Chart generation support] (9503) * [Collapse] (10287) * [Colliding balls] (8573) * [Colliding Coins] (8709) * [Convolutions] (11503) * [Cubic Splines] (8536) * [Cursor demo] (13165) * [Daily Dilbert] (8899) * [Dot to Dots] (4365) * [Drag-N-Drop Example] (416, the oldest page I know of that's ''reapable'') * [Drawing rounded polygons] (8590) * [Eliminator] (9018) * [Enigma] (8847) * [Falling Marbles] (8825) * [Fern Fractal] (10492) * [font configure] (9947) * [Gem Game] (9052) * [Hack-O-Matic] (9755) * [Harmonic color wheel] (12201) * [Hilbert Curve] (8348) * [Horseracing in Tcl] (3467) * [iConnect4] (8905) * [iMap: an indexed map viewer] (8771, but don't forget to download the map) * [Kaleidoscope] (12385) * [LemonTree] (12751) * [Life in Snit] (4324) * [Lights Out] (12376) * [Lissajous Figures] (8875) * [Mancala] (4297) * [Mandelbrot] (4714) * [Mandelbrot and Julia sets] (9675) * [MasterMind] (4363) * [Minesweeper on Tktable] (8918) * [Morley's Miracle] (8336) * [My House] (14330) * [Named Colors] (8606) * [Once In A Lifetime] (11193) * [Parallel Geturl] (11060) * [Particle System] (3252) * [Pastel Colors] (10330) * [Penney numerals] (10761) * [Pig Latin] (10356) * [Playing 3D] (3190) * [Playing Card Images] (8803) * [Playing UML] (2257) * [Playing WIMP] (12137) * [Polyhedron Nets] (8528) * [pop3] (781, another old page that remarkably works) * [Puzzle Blocks] (8887) * [Rain Storm] (8835) * [Rainbow Tunnel] (12222) * [Regular Polygons 2] (8612) * [Rush Hour] (12376) * [Scat] (8810) * [SkipList Demo] (10430) * [Sliding panel] (14508) * [Snitscope] (9764, but add a call to demo at the end) * [spinbox menubutton] (9648) * [Starfield] (10100) * [Stickies] (13186) * [TclSpringies : A simple mass and spring simulator] (13131) * [Text Widget Example] (928) * [Tic Tac Toe] (12374) * [Tickmassfiler] (11065) * [tkAtaxx] (7666) * [TkBomb] (6201, which needs edits to run in Tk8.4) * [TkBugs] (1720) * [tkGoldberg] (8607) * [TkMapper] (6277) * [TkMines] (7779) * [TkRose] (8295) * [trains3.tcl] (1359) * [Transparent Toplevel] (10515) * [Tree nodes in motion] (10426) * [Triangle Madness] (9318) * [TriPeaks Solitaire] (13092) * [Universal Transverse Mercator] (11109) * [vertical labels] (8429) * [Video Poker] (8987) * [Widget Configure] (10021) * [Wiki History Diff] (10335) * [wish-reaper] (8179, you need to give it a different name, since it does not overwrite files) * [Word Jumble] (10354) * [Word Search] (12430) Pages that it cannot reap successfully include: * [A little file searcher] (3751, two program versions in one page that don't play nice together) * [Click me] (8408, two program versions in one page that don't play nice together) * [cursors] (1425, more than one version on the page that don't play nice together) ''cannot reap successfully'' means that the file resulting from reaping the specified page will not run when started from a Windows file explorer without being edited. The contents of the page will still be collected. ---- [RS]: Hm - the second time you "misreaped" a page of mine.. In the case of [Click me], it's so ridiculously small, that it doesn't deserve splitting up; [a little file searcher] will split off [A little file searcher (iPaq)] ;-) [escargo] 16 Mar 2003 - The code for [a little file searcher] can be reaped, but I can't run it under Windows at least because it assumes a command line interface. - [RS] has a command line interface on Windows, the infamous DOS prompt ;-) ---- This program is certainly able to be improved, but it works for now. #!/usr/bin/env wish # wish-reaper -- # This script replaces the command line interface of wiki-repeater.tcl # with a wish GUI. # Create a user interface to collect the necessary parameters # and control actions. # We need an entry for a number field (the page to reap). # Page 6277 provides TkMapper. # Page 4718 prvides the original wiki-reaper. # We need an entry for a filename field (to write the page to). # We need a button to tell when to do the job. # We need a button to tell when to quit. wm title . "Wish Reaper" set font {Helvetica 14} frame .reaper pack .reaper -expand 1 -fill both -side left label .reaper.banner -font $font -text "Wish Reaper" pack .reaper.banner -expand 1 -fill x -side top frame .reaper.data pack .reaper.data -expand 1 -fill both -pady 5 -side top label .reaper.data.page -anchor w -justify left -text "Page Number" grid .reaper.data.page -column 1 -row 1 -sticky w entry .reaper.data.pageno -textvariable pageno grid .reaper.data.pageno -column 2 -row 1 label .reaper.data.file -anchor w -justify left -text "Output file name" grid .reaper.data.file -column 1 -row 2 -sticky w entry .reaper.data.filename -textvariable filename grid .reaper.data.filename -column 2 -row 2 button .reaper.reap -command reap_now -padx 4 -pady 4 -text Reap pack .reaper.reap -side left button .reaper.quit -command exit -padx 4 -pady 4 -text Quit pack .reaper.quit -side right foreach {pageno filename} $argv break focus .reaper.data.pageno .reaper.data.pageno icursor end if {[catch {package require Tcl 8.3}]} { tk_messageBox -icon error \ -message "Tcl version 8.3 or later is required." \ -type ok -parent .reaper exit } if {![catch { package require nstcl-html }] && ![catch { package require nstcl-http }]} { namespace import nstcl::* } else { # Catch a failure here and pop up a dialog box before exiting. # A more precise statement about which version of http is needed # would be helpful. http::cleanup needs to be provided. if {[catch {package require http}]} { tk_messageBox -icon error \ -message "Package http not found." \ -type ok -parent .reaper exit } proc ns_geturl {url} { set conn [http::geturl $url] set html [http::data $conn] http::cleanup $conn return $html } proc ns_striphtml {-tags_only html} { regsub -all -- {<[^>]+>} $html "" html return $html ;# corrected a typo here } proc ns_urlencode {string} { set allowed_chars {[a-zA-Z0-9]} set encoded_string "" foreach char [split $string ""] { if {[string match $allowed_chars $char]} { append encoded_string $char } else { scan $char %c ascii append encoded_string %[format %02x $ascii] } } return $encoded_string } } proc output {data} { global out # we don't want to throw an error if output channel has been closed catch { puts $out $data } } # Factoring out the postamble for clarity and ease of change. proc postamble { } { output \n output "# EOF" output \n } # Factoring out the preamble for clarity and ease of change. proc preamble {title url now updated} { output "#####" output "#" output "# \"$title\"" output "# [string map [list mini.net/tcl wiki.tcl.tk] $url]" output "#" output "# Tcl code harvested on: $now GMT" output "# Wiki page last updated: $updated" output "#" output "#####" output \n } proc reap {page} { set url http://mini.net/tcl/[ns_urlencode $page] set now [clock format [clock seconds] -format "%e %b %Y, %H:%M" -gmt 1] set html [ns_geturl $url] # can't imagine why these characters would be in here, but just to be safe set html [string map [list \x00 "" \x0d ""] $html] set html [string map [list
 \x00 
\x0d] $html] if {![regexp -nocase {([^<]*)} $html => title]} { set title "(no title!?)" } set re {