Warning: this is a htmlized version!
The original is across this link. |
####### # # E-scripts on wiki. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at <http://angg.twu.net/a/e/wiki.e> # or at <http://angg.twu.net/e/wiki.e.html>. # See also <http://angg.twu.net/emacs.html>, # <http://angg.twu.net/a/.emacs[.html]>, # <http://angg.twu.net/a/.zshrc[.html]>, # <http://angg.twu.net/escripts.html>, # and <http://angg.twu.net/>. # ####### killall -v boa ~/boa-0.92/src/boa -c ~/wiki/ & ##### # # Extracting pages from a wiki # ##### # (find-es "tcl" "wiki_extracting_pages") cd ~/wiki ./tclkit wiki0_ -scripts ./tclkit wiki0_ -scripts: ./tclkit wiki0_ -scripts/0 ./tclkit wiki0_ -scripts/0: ./tclkit wiki0_ -scripts/0:text ./tclkit wiki0_ -scripts/dump.tcl ./tclkit wiki0_ -scripts/dump.tcl: ./tclkit wiki0_ -scripts/dump.tcl:text ./tclkit wiki0_ dump ./tclkit wiki0_ dump metakit_ ./tclkit wiki0_ -pages ./tclkit wiki0_ -pages: ./tclkit wiki0_ -pages:name ./tclkit wiki0_ -pages/10: ./tclkit wiki0_ -pages/10:name ./tclkit wiki0_ -pages/10:page ./tclkit wiki0_ -pages:date ./tclkit wiki0_ -pages:who ./tclkit wiki0_ -pages:format ./tclkit wiki0_ -pages:refs ./tclkit wiki0_ -pages/0: ./tclkit wiki0_ -pages/1: ./tclkit wiki0_ -pages/2: ./tclkit wiki0_ -pages/3: ./tclkit wiki0_ -pages/4: ./tclkit wiki0_ -pages/5: ./tclkit wiki0_ -pages/6: ./tclkit wiki0_ -pages/0: -pages/0: lynx $WIKI/metakit lynx $WIKI/wikit'?'wikit+command+line lynx $WIKI/wikit'?'wikit+command+line+for+windows95 # (find-es "tcl") cd $ES agrep « tcl.e # (find-es "tcl" "wikit") # (find-es "tcl" "wikit_cgi") # (find-es "tcl" "wiki_extracting_pages") # (find-es "tcl" "metakit_wiki") # (find-es "tcl" "scripdoc") # (find-es "tcl" "wiki_scripts") # (find-es "http") # (find-es "http" "boa_wiki") # (find-fline "~/EXPECT/") # (find-fline "~/TCL/httpwiki") # (find-fline "~/TCL/httpwiki") httpwiki get $WIKI/wiki0 10 | tee /tmp/10 httpwiki eget $WIKI/wiki0 10 | tee /tmp/10 # (find-fline "/tmp/10") httpwiki send $WIKI/wiki0 10 < /tmp/10 ##### # # wikit, running locally (with tclkit) # ##### # «wikit» # Yes, I'm having to run the binaries # without having the source. Urgh. # To get the newest version, with all the current pages: psne http://mini.net/cgi-bin/wikit.gz cd $S/http/mini.net/cgi-bin/ cd /usr/local/bin/ gzip -cd < $S/http/www.equi4.com/tclkit/tclkit-linux.gz > tclkit chmod 755 tclkit gzip -cd < $S/http/mini.net/cgi-bin/wikit.gz > wikit chmod 755 wikit cp wikit wikit2 wikit mkdir /tmp/pages wikit2 -pages: | tee /tmp/pages.titles wikit2 -pages/485: | tee /tmp/pages/485.txt # (find-fline "/tmp/pages/485.txt") # (find-fline "/tmp/pages.titles") wikit2 -pages:page | tee /tmp/pages.bigmess # (find-fline "/tmp/pages.bigmess") # (find-node "(zsh)Complex Commands") mkdir /tmp/pages/ i=0 while [[ $i -le 532 ]] do echo $i wikit2 -pages/$i: > /tmp/pages/$i.txt i=$[$i+1] done ##### # # wikit as a cgi # ##### # «wikit_cgi» # (find-es "tcl" "metakit_wiki") # (find-fline "/tmp/pages/") # (find-fline "/tmp/pages/48.txt") rm -Rv /var/www/wikit/ mkdir /var/www/wikit/ chmod 777 /var/www/wikit cd /var/www/wikit/ gzip -cd < $S/http/mini.net/cgi-bin/wikit.gz > wikit_cgi chmod 666 wikit_cgi cat > wikit.cgi <<'---' #!/bin/sh exec /usr/local/bin/tclkit /var/www/wikit/wikit_cgi wikit --- chmod 755 wikit.cgi lynx $LH/wikit/wikit.cgi ##### # # Using Tcl to retrieve pages from a wikit # ##### # «wiki_extracting_pages» # (find-fline "/usr/lib/tcl8.0/") # (find-fline "/usr/lib/tcl8.0/http1.0/http.tcl") # (find-fline "/usr/lib/tcl8.0/http1.0/http.tcl" "proc http_get") # (find-fline "/var/log/apache/error.log") source /usr/lib/tcl8.0/http1.0/http.tcl puts [http_data [http_get http://localhost/wikit/wikit.cgi]] source /usr/lib/tcl8.0/http1.0/http.tcl puts [http_data [http_get http://localhost/wikit/wikit.cgi/532.html]] source /usr/lib/tcl8.0/http1.0/http.tcl puts [http_data [http_get http://localhost/wikit/wikit.cgi/532.html -query \ {C=Hello, my name is Edrx. I live on dog food. My home page is http://www.mat.puc-rio.br/~edrx/ . 'one' ''two'' '''three''' ''''four''''}]] # (find-fline "/tmp/usecgi.tcl") # (find-fline "/tmp/pages/14.txt") # cp /usr/local/bin/wikit wikit_cgi cd /var/www/wikit/ tclkit wikit_cgi wikit cd /var/www/wikit/ tclkit wikit_cgi -pages: tclkit wikit_cgi -pages/532:page tclkit wikit2 wikit cp /usr/local/bin/wikit /var/www/wikit.cgi cp /usr/local/bin/wikit /usr/lib/cgi-bin/wikit.cgi lynx $LH/wikit.cgi lynx $LH/cgi-bin/wikit.cgi ~/EXPECT/httpc1 80 /wikit.cgi # (find-fline "/var/log/apache/") # (find-fline "/var/log/apache/error.log") ln -s /usr/local/bin/tclkit /usr/bin/tclkit # (find-fline "/var/www/wikit.cgi") # A nice way to find out what code does what is to cause an error: wikit2 -pages/: # (find-fline "/tmp/cli.tcl") lynx -force_html $S/http/www.equi4.com/jcw/wiki/ScriptedDocument cd /usr/local/bin/ wikit dump # (find-fline "$S/http/mini.net/cgi-bin/wikit.gz" "tclkit wikit.tkd dump") laf $S/http/www.equi4.com/tclkit/wikit.tkd cd $S/http/www.equi4.com/tclkit/ tclkit wikit.tkd dump |& l tclkit wikit.tkd --pages: |& l tclkit wikit.tkd --pages/24:page |& l tclkit wikit.tkd --scripts/wikit.tcl:text |& l wikit --pages: |& l wikit --pages:/24:page |& l rm -Rv /tmp/wikit/ mkdir /tmp/wikit/ cd $S/http/www.equi4.com/tclkit/ for i in cgi2.tcl cli.tcl dump.tcl format.tcl Html_library.tcl \ http2.tcl lock.tcl modify.tcl usecgi.tcl usetk.tcl wikit.tcl \ wipeout.tcl; do tclkit wikit.tkd --scripts/${i}:text > /tmp/wikit/$i done # (eeman "3tk text" "^BINDINGS") # (find-vldifile "tkdiff.list") # (find-fline "/usr/X11R6/bin/tkdiff") # (eeman "3tk send") # (find-fline "~/TK/diaglib.013" "proc coords_to_stdout") send temp coords_to_stdout xauth generate :0.0 . lynx $S/http/psg.com/~joem/tcl/faq.html#XServerInsecure ###### # # Extracting the scripts from a wikit # ###### WIKIT=$S/http/www.equi4.com/tclkit/wikit.tkd rm -Rv /tmp/wikit/ mkdir /tmp/wikit/ cd /tmp/wikit/ tclkit $WIKIT -scripts: | awk '{print $3}' | tee .scripts for i in $(<.scripts); do echo $i tclkit $WIKIT --scripts/${i}:text > $i done # (find-fline "/tmp/wikit/") # (find-fline "/tmp/wikit/cli.tcl") # (find-fline "/tmp/wikit/cli.tcl" "ProcessOneArg") # (find-fline "/tmp/wikit/wikit.tcl") # (find-fline "/tmp/wikit/wikit.tcl" "The main code") lynx $S/http/www.equi4.com/jcw/wiki.cgi/18.html ###### # # Editing wiki pages with emacs # ###### # (find-fline "~/TCL/editwikipage") # (find-fline "~/.zshrc" "ewp") ewp 532 ewp 5 lin ###### # # linwikit # ###### # Blank linwikit: # cp -iv $S/http/www.equi4.com/tclkit/wikit.tkd /var/www/wikit/linwikit_cgi cd /var/www/wikit/ chmod 777 linwikit_cgi cat > linwikit.cgi <<'---' #!/bin/sh exec /usr/local/bin/tclkit /var/www/wikit/linwikit_cgi wikit --- chmod 755 linwikit.cgi ###### # # metakit wikit # 99oct12 # ###### # «metakit_wiki» # (find-es "tcl" "wikit_cgi") # (find-fline "$S/http/www.equi4.com/") # (find-fline "$S/http/www.equi4.com/metakit/mk4tcl/") # (find-fline "$S/http/www.equi4.com/metakit/mk4tcl/demo.tcl") # (find-fline "$S/http/www.equi4.com/metakit/mk4tcl/mk4tcl.cpp") # (find-fline "$S/http/www.equi4.com/tclkit/") http://www.equi4.com/metakit/wiki/ edrxnetscape http://www.equi4.com/metakit/wiki/ & psne http://www.equi4.com/metakit/wiki.gz cd /var/www/wikit/ gzip -cd < $S/http/www.equi4.com/metakit/wiki.gz > mkwikit_cgi chmod 666 mkwikit_cgi cat > mkwikit.cgi <<'---' #!/bin/sh exec /usr/local/bin/tclkit /var/www/wikit/mkwikit_cgi --- chmod 755 mkwikit.cgi lynx $LH/wikit/mkwikit.cgi ###### # # Scripted documents (wikit, for example) # 99oct30 # ###### # «scripdoc» rm -Rv /usr/src/scripdoc/ cd /usr/src/ tar -xvzf $S/http/www.equi4.com/tclkit/scripdoc.tar.gz cd /usr/src/scripdoc/ tr -d \\r < README.txt > README # # (eeman "etags" "tcl") etags --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' wikit/*.tcl *.tcl # (find-sdfile "") # (find-sdfile "README") # (find-sdfile "wikit/") # Recreate empty.tkd and compare it with the old one. # Create wikit0.tkd from wikit/*.tcl, # create wikit1.tkd from cli.tcl+wikit/*.tcl, # ereate wikit2.tkd with all that and dotmp.tcl, # which is almost only a "source /tmp/ee". # cd /usr/src/scripdoc/ mv -v empty.tkd empty0.tkd tclkit mkempty.tcl cmp empty.tkd empty0.tkd # cp empty.tkd wikit0.tkd tclkit wikit0.tkd -scripts=wikit/ # cp -v cli.tcl wikit/ cp empty.tkd wikit1.tkd tclkit wikit1.tkd -scripts=wikit/ # cat > wikit/do.tcl <<'---' proc writefile {fname bigstr} { set f [open $fname w]; puts -nonewline $f $bigstr; close $f } if {$argc==1} {source /tmp/ee} else {eval [lindex $argv 1]} --- cp empty.tkd wikit2.tkd tclkit wikit2.tkd -scripts=wikit/ # Demo: # cat > /tmp/ee <<'---' puts "Hello oo oo oorld" --- tclkit /usr/src/scripdoc/wikit2.tkd do tclkit /usr/src/scripdoc/wikit2.tkd do 'puts "aaa aaah"' tclkit /usr/src/scripdoc/wikit2.tkd do ' writefile /tmp/ocoms "[join [lsort [info commands]] "\n"]\n" writefile /tmp/oprocs "[join [lsort [info procs]] "\n"]\n" ' lynx -dump $S/http/www.equi4.com/metakit/mk4tcl/index.html > mk4tcl.txt # (find-sdfile "mk4tcl.txt") tclkit /usr/src/scripdoc/wikit2.tkd do ' puts "A [mk::file open]" puts "B [mk::file views doc]" foreach v [mk::file views doc] { puts [mk::view layout doc.$v] } puts "D [mk::view layout doc]" puts "E [mk::view layout doc.scripts]" puts "E [mk::view layout doc.admin]" ' puts "C [mk::file views doc.scripts]" # (find-fline "/tmp/") # (find-fline "/tmp/ocoms") # (find-fline "/tmp/oprocs") # (find-sdfile "wikit/") # (find-sdfile "wikit/dump.tcl") # (find-fline "$S/http/www.equi4.com/metakit/mk4tcl/") # (find-fline "$S/http/www.equi4.com/metakit/mk4tcl/demo.tcl") # (find-fline "$S/http/www.equi4.com/metakit/mk4tcl/mk4tcl.cpp") lynx $S/http/www.equi4.com/metakit/mk4tcl/index.html lynx $S/http/www.equi4.com/metakit/mk4tcl/index.html#Terminology cd /usr/src/scripdoc/ cp empty.tkd wikit.tkd tclkit wikit.tkd -scripts=wikit/ ./wikit.tkd -config-script=wikit ./wikit.tkd dump ###### # # more on changing wiki scripts # 99nov02 # ###### # «wiki_scripts» cd ~/wiki/ tclkit metakit_ -scripts: tclkit metakit_ -scripts: | awk '{print $3}' tclkit metakit_ -scripts/wipeout.tcl: tclkit metakit_ -scripts/wipeout.tcl:text cd ~/wiki/ rm -Rv scripts mkdir scripts for i in $(tclkit metakit_ -scripts: | awk '{print $3}'); do echo $i tclkit metakit_ -scripts/$i'':text > scripts/$i done laf scripts cd ~/wiki/scripts/ etags --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl # (code-c-d "wiscri" "~/wiki/scripts/") # (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") # How does wikit encode pages for editing? I want to download the raw # text of a page (via cgi, without altering the wiki's scripts) and # edit it on emacs... cd /tmp wget $WIKI/wikit/0@ # (find-fline "/tmp/0@") expect -c ' set s [exec cat /tmp/0@] if [regexp "\n<textarea \[^\n>\]*>\n(.*)\n</textarea>" $s -> text] { # Undo the work of this function: (find-wiscritag "cgi_quote_html") regsub -all {\"} $text {"} text regsub -all {\<} $text {<} text regsub -all {\>} $text {>} text regsub -all {\&} $text {&} text puts -nonewline $text } ' | tee /tmp/0@.txt # «wiki_extracting_pages» ###### # # Editing wikit pages with emacs # ###### # (find-node "(elisp)Modes") # (find-fline "~/.emacs" "auto-mode-alist") # (find-node "(elisp)Auto Major Mode") cd /tmp ~/TCL/wikipage -r 532 ##### # # Using boa to create user-owned wikis # 99oct30 # ##### # «boa_wiki» # Unpack and compile boa # rm -Rv ~/boa-0.92/ cd ~ tar -xvzf $S/http/www.boa.org/boa-0.92q.tar.gz cd ~/boa-0.92/src/ make |& tee om # Create ~/wiki/ , # ~/wiki/tclkit . # rm -Rv ~/wiki/ mkdir ~/wiki/ cd ~/wiki/ gzip -cd < $S/http/www.equi4.com/tclkit/tclkit-linux.gz > tclkit chmod 755 tclkit # Create ~/wiki/wikit_ , # ~/wiki/wikit , # ~/wiki/wikit.gz . # wikit_ (the Tcler's wiki) is a tclkit script, i.e., something that # contains lots of wiki pages and some support scripts in Tcl; it # will rewrite itself (but changing only the pages' text!) every # time that a user modifies a page. # wikit is the cgi that calls tclkit to execute wikit_, and # wikit.gz is a cgi that sends a gzipped copy of wikit_. # gzip -cd < $S/http/mini.net/cgi-bin/wikit.gz > wikit_ cat > wikit <<'---' #!/bin/sh exec ~/wiki/tclkit ~/wiki/wikit_ wikit --- cat > wikit.gz <<'---' #!/bin/sh echo -e "Content-type: text/plain\n" exec gzip -c6 < ~/wiki/wikit_ --- chmod 755 wikit chmod 755 wikit.gz # Create ~/wiki/metakit_ , # ~/wiki/metakit , # ~/wiki/metakit.gz ; # the same as above but for the metakit wiki. # gzip -cd < $S/http/www.equi4.com/metakit/wiki.gz > metakit_ cat > metakit <<'---' #!/bin/sh exec ~/wiki/tclkit ~/wiki/metakit_ wikit --- cat > metakit.gz <<'---' #!/bin/sh echo -e "Content-type: text/plain\n" exec gzip -c6 < ~/wiki/metakit_ --- chmod 755 metakit chmod 755 metakit.gz # Create ~/wiki/wiki0_ , # ~/wiki/wiki0 , # ~/wiki/wiki0.gz ; # the same as above but for a clean wiki. # cat < $S/http/www.equi4.com/tclkit/wikit.tkd > wiki0_ cat > wiki0 <<'---' #!/bin/sh exec ~/wiki/tclkit ~/wiki/wiki0_ wikit --- cat > wiki0.gz <<'---' #!/bin/sh echo -e "Content-type: text/plain\n" exec gzip -c6 < ~/wiki/wiki0_ --- chmod 755 wiki0 chmod 755 wiki0.gz # Create ~/wiki/conf/boa.conf , # ~/wiki/conf/mime.types . # mkdir -p ~/wiki/conf/ cp /etc/mime.types ~/wiki/conf/ cat > ~/wiki/conf/boa.conf <<xxxxxxxx Port 8080 ServerAdmin edrx@mat.puc-rio.br ErrorLog $HOME/wiki/error_log AccessLog $HOME/wiki/access_log DocumentRoot $HOME/wiki DirectoryIndex index.html KeepAliveMax 100 KeepAliveTimeout 10 DefaultType text/plain # AddType application/x-httpd-cgi cgi ScriptAlias /wiki/ $HOME/wiki/ xxxxxxxx # Kill a possible previous server... killall -v boa # # ...and start a new one. ~/boa-0.92/src/boa -c ~/wiki/ & # Do some tests: call each wiki... # (But note that editing "<textarea ...>" fields # is clumsy in lynx!) # lynx http://angg:8080/wiki/wikit lynx http://angg:8080/wiki/metakit lynx http://angg:8080/wiki/wiki0 lynx http://tardis.mat.puc-rio.br:8080/wiki/wikit lynx http://tardis.mat.puc-rio.br:8080/wiki/metakit lynx http://tardis.mat.puc-rio.br:8080/wiki/wiki0 rm -fv wiki* rm -fv metakit* cd /tmp for i in wikit metakit wiki0; do wget http://angg:8080/wiki/$i.gz gzip -dv $i.gz cmp $i ~/wiki/$i''_ done rm -fv wiki* rm -fv metakit* ##### # # Some temporary notes on using the chunk above on my university account # 99oct29 # ##### # (find-fline "$MAIL" "wiki") # (find-es "http" "boa_wiki") psne http://www.boa.org/boa-0.92q.tar.gz psne http://www.equi4.com/tclkit/tclkit-linux.gz psne http://mini.net/cgi-bin/wikit.gz psne http://www.equi4.com/metakit/wiki.gz psne http://www.equi4.com/tclkit/wikit.tkd # # Testa pra ver se os arquivos chegaram bem. # laf $(find $S -type f) ps ax | grep wget for i in $(find $S -type f | grep gz); do echo $i; gzip -cd < $i > /dev/null done cd ~/boa-0.92/src/ make boa_grammar.c y.tab.c y.tab.h anonftp $BOTO 'mput boa_grammar.c y.tab.c y.tab.h' 'quit' # 'cd boa-0.92/src' # (find-es "http" "boa_wiki") # Na PUC: cd ~/boa-0.92/src/ cp ~/boa_grammar.c ~/y.tab.c ~/y.tab.h . touch boa_grammar.c y.tab.c y.tab.h . make |& tee om2 # (find-fline "~/boa-0.92/src/") lynx http://tardis.mat.puc-rio.br:8080/wiki/wikit cd $ES anonftp $MATINTA 'cd public_html/a/e' 'put http.e' 'quit' # (find-es "page") # On tardis, cd ~/public_html/ DOREMOTE=1 make THDIR=a/s -f a/s/Makefile makefile all |& tee ~/o ##### # # httpwiki # 99nov16 # ##### # «httpwiki» # (find-fline "~/TCL/httpwiki") cd /tmp/ ~/TCL/httpwiki ~/TCL/httpwiki eget http://www.mini.net/cgi-bin/wikit 621 | tee 621 ~/TCL/httpwiki eget http://www.mini.net/cgi-bin/wikit 621 | tee 627 ~/TCL/httpwiki eget http://www.mini.net/cgi-bin/wikit 13 | tee 13 ~/TCL/httpwiki eget http://www.mini.net/cgi-bin/wikit 0 | tee 0 # (find-fline "/tmp/13") # (find-fline "/tmp/621") # (find-fline "/tmp/0") # (find-fline "/tmp/627") # 0: top # 13: tclers # 621: eduardo ochs # 627: How to edit Wikit pages with Emacs