#!/bin/sh string=? ;exec /users/staff/math/sbloch/install/usrlocal/bin/mzscheme -r $0 "$@" (require-library "cgi.ss" "net") (define (html-enclose tag options body) (string-append "<" tag " " options ">" body "")) (define (build-attribute name value) (string-append name "=\"" value "\"")) (define (attribs-append string1 string2) (cond [(string=? string1 "") string2] [(string=? string2 "") string1] [else (string-append string1 " " string2)])) (define (h1-center string) (html-enclose "h1" (build-attribute "align" "center") string)) (define (hot-link href options body) (html-enclose "a" (attribs-append (build-attribute "href" href) options) body)) (require-library "date.ss") (define (today) (date->string (seconds->date (current-seconds)))) (define (my-get-bindings) `((directory . "/usr/users/sbloch/html/class/hs/") (filename . "test.output") (name . "Stephen Bloch"))) (let* ((bindings (get-bindings)) (name (extract-binding/single 'name bindings)) (label (string-append "Thanks, " name)) (directory (extract-binding/single 'directory bindings)) (full-dir (string-append directory "unsafe/")) (filename (extract-binding/single 'filename bindings)) (other-bindings (cons (cons 'date (today)) (cddr bindings))) ; assume directory is first ) (current-directory full-dir) (with-output-to-file filename (lambda () (write other-bindings) (newline)) 'append) (generate-html-output label `(,(h1-center label) "

" "Your data have been saved." ; "
" ; "Current directory: " ,(current-directory) "

" ,@(bindings-as-html other-bindings) "

" ,(hot-link "http://www.adelphi.edu/sbloch/class/hs/survey.scm" "" "View Scheme source code for this CGI script") "

" ,(hot-link "http://www.adelphi.edu/sbloch/class/hs/" "" "Back to the workshop page") ) ) )