diff --git a/doc/latex/surflethowto.tex b/doc/latex/surflethowto.tex index 52e55a0..78fa622 100644 --- a/doc/latex/surflethowto.tex +++ b/doc/latex/surflethowto.tex @@ -87,7 +87,7 @@ surflets: does this for you: \begin{itemize} - \item \typew{cd \$sunet/httpd/surflets} + \item \typew{cd \$sunet} \item \typew{SSAX=\$SSAX ./start-surflet-server} \end{itemize} @@ -96,15 +96,15 @@ Please be patient, scsh has to load a lot of libraries. If the loading succeeds you will see something like this: \begin{alltt} -[andreas@hgt surflets]\$ ssax=/home/andreas/sw/SSAX ./start-surflet-server +[andreas@hgt sunet]\$ SSAX=/home/andreas/sw/SSAX ./start-surflet-server Loading... reading options: () Going to run SUrflet server with: - htdocs-dir: /home/andreas/sw/sunet/httpd/surflets/web-server/root/htdocs - surflet-dir: /home/andreas/sw/sunet/httpd/surflets/web-server/root/surflets - images-dir: /home/andreas/sw/sunet/httpd/surflets/web-server/root/img + htdocs-dir: /home/andreas/sw/sunet/web-server/root/htdocs + surflet-dir: /home/andreas/sw/sunet/web-server/root/surflets + images-dir: /home/andreas/sw/sunet/web-server/root/img port: 8008 - log-file-name: /home/andreas/sw/sunet/httpd/surflets/web-server/httpd.log + log-file-name: /home/andreas/sw/sunet/web-server/httpd.log a maximum of 5 simultaneous requests, syslogging activated, and home-dir-handler (public_html) activated. @@ -113,7 +113,8 @@ Going to run SUrflet server with: This means the server is up and running. Try to connect to \url{http://localhost:8008} with your browser and you will see the -welcome page of the \surflets. You can also already try out some of +welcome page of the SUnet server. There's a link to the +\surflets homepage. You can also already try out some of the \surflets that come with the distribution. You will probably notice a long response time the first time you load diff --git a/scheme/httpd/surflets/load-surflet-server.scm b/scheme/httpd/surflets/load-surflet-server.scm index dc78fe0..c89c22a 100644 --- a/scheme/httpd/surflets/load-surflet-server.scm +++ b/scheme/httpd/surflets/load-surflet-server.scm @@ -10,22 +10,22 @@ (in 'scsh `(run (string-append (or (getenv "SUNETHOME") ,*ASSUMED-SUNET-HOME*) - "/packages.scm")))) + "/scheme/packages.scm")))) (define *SSAX-PACKAGE* (in 'scsh `(run (string-append (or (getenv "SSAXPATH") - (string-append ,*ASSUMED-SUNET-HOME* "/SSAX")) + (string-append ,*ASSUMED-SUNET-HOME* "/../SSAX")) "/lib/packages.scm")))) (define *SURFLET-PACKAGE* (in 'scsh `(run (string-append (or (getenv "SUNETHOME") ,*ASSUMED-SUNET-HOME*) - "/httpd/surflets/packages.scm")))) + "/scheme/httpd/surflets/packages.scm")))) (define *SURFLET-SERVER* (in 'scsh `(run (string-append (or (getenv "SUNETHOME") ,*ASSUMED-SUNET-HOME*) - "/httpd/surflets/start-surflet-server")))) + "/start-surflet-server")))) (config `(load ,*SUNET-PACKAGE*)) (config `(load ,*SSAX-PACKAGE*)) (config `(load ,*SURFLET-PACKAGE*)) diff --git a/scheme/httpd/surflets/start-surflet-server b/start-surflet-server similarity index 95% rename from scheme/httpd/surflets/start-surflet-server rename to start-surflet-server index 4f4471a..25ccca2 100755 --- a/scheme/httpd/surflets/start-surflet-server +++ b/start-surflet-server @@ -1,13 +1,12 @@ #!/bin/sh echo "Loading..." -fullpath=`which $0` -# $sunet is either $SUNET or created out of fullpath +# $sunetscheme is either $SUNET/scheme or $PWD/scheme # Kind of a hack, I know. We're still waiting for this library #installing system. -sunethome=${SUNET:-`dirname $fullpath`/../..} -ssaxhome=${SSAX:-`dirname $fullpath`/../../../SSAX} # path to SSAX +sunetscheme=${SUNET:-$PWD}/scheme +ssaxhome=${SSAX:-../SSAX} # path to SSAX -exec scsh -lm $sunethome/packages.scm -lm $ssaxhome/lib/packages.scm -lm $sunethome/httpd/surflets/packages.scm -dm -o surflet-server -e main -s "$0" "$@" +exec scsh -lm $sunetscheme/packages.scm -lm $ssaxhome/lib/packages.scm -lm $sunetscheme/httpd/surflets/packages.scm -dm -o surflet-server -e main -s "$0" "$@" !# (define-structure surflet-server diff --git a/scheme/httpd/surflets/web-server/root/htdocs/index.html b/web-server/root/htdocs/index-surflet.html similarity index 92% rename from scheme/httpd/surflets/web-server/root/htdocs/index.html rename to web-server/root/htdocs/index-surflet.html index 378bea0..3009b13 100644 --- a/scheme/httpd/surflets/web-server/root/htdocs/index.html +++ b/web-server/root/htdocs/index-surflet.html @@ -4,7 +4,7 @@

Hello Untergrund!

-

Main Menu

+

SUrflets Main Menu

Following files are available from here:
- And nothing else... -
-Last modified: Sun Jul 13 18:23:23 CEST 2003 +Last modified: Mon Feb 2 11:33:08 EST 2004 diff --git a/web-server/root/htdocs/index.html b/web-server/root/htdocs/index.html index 3ddb87b..d438c91 100644 --- a/web-server/root/htdocs/index.html +++ b/web-server/root/htdocs/index.html @@ -1,8 +1,31 @@ + -Home - -

-Hello world! (more...) + Scheme Unterground + +

+

Hello Unterground!

+ + Following files are available: + +
+
+ + +Last modified: Wed Apr 23 09:25:58 MST 2003 + + + +

diff --git a/web-server/root/htdocs/index2.html b/web-server/root/htdocs/index2.html deleted file mode 100644 index dd605bc..0000000 --- a/web-server/root/htdocs/index2.html +++ /dev/null @@ -1,33 +0,0 @@ - - - Scheme Unterground - -

-

Hello Unterground!

- - Following files are available: - -
- And nothing else... - -
- - -Last modified: Wed Apr 23 09:25:58 MST 2003 - - - - -

- - diff --git a/web-server/root/img/221.gif b/web-server/root/img/221.gif new file mode 100644 index 0000000..a183e4f Binary files /dev/null and b/web-server/root/img/221.gif differ diff --git a/scheme/httpd/surflets/web-server/root/surflets/add-html.scm b/web-server/root/surflets/add-html.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/add-html.scm rename to web-server/root/surflets/add-html.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/add-raw.scm b/web-server/root/surflets/add-raw.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/add-raw.scm rename to web-server/root/surflets/add-raw.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/add-simple.scm b/web-server/root/surflets/add-simple.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/add-simple.scm rename to web-server/root/surflets/add-simple.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/add-surflet.scm b/web-server/root/surflets/add-surflet.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/add-surflet.scm rename to web-server/root/surflets/add-surflet.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-handler.scm b/web-server/root/surflets/admin-handler.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/admin-handler.scm rename to web-server/root/surflets/admin-handler.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-profiling.scm b/web-server/root/surflets/admin-profiling.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/admin-profiling.scm rename to web-server/root/surflets/admin-profiling.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-surflets-cb.scm b/web-server/root/surflets/admin-surflets-cb.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/admin-surflets-cb.scm rename to web-server/root/surflets/admin-surflets-cb.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-surflets.scm b/web-server/root/surflets/admin-surflets.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/admin-surflets.scm rename to web-server/root/surflets/admin-surflets.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin.scm b/web-server/root/surflets/admin.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/admin.scm rename to web-server/root/surflets/admin.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/byte-input.scm b/web-server/root/surflets/byte-input.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/byte-input.scm rename to web-server/root/surflets/byte-input.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/calculate-cb.scm b/web-server/root/surflets/calculate-cb.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/calculate-cb.scm rename to web-server/root/surflets/calculate-cb.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/calculate.scm b/web-server/root/surflets/calculate.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/calculate.scm rename to web-server/root/surflets/calculate.scm diff --git a/web-server/root/surflets/howto/annotate-error.scm b/web-server/root/surflets/howto/annotate-error.scm new file mode 100755 index 0000000..ae8b9d0 --- /dev/null +++ b/web-server/root/surflets/howto/annotate-error.scm @@ -0,0 +1,37 @@ +(define-structure surflet surflet-interface + (open surflets + handle-fatal-error + surflets/error + scheme-with-scsh) + (begin + (define (main req) + (let* ((select-input-field + (make-select + (map make-annotated-select-option + '("Icecream" "Chocolate" "Candy") + '(1.5 2.0 0.5)))) + (req (send-html/suspend + (lambda (k-url) + `(html + (head (title "Sweet Store")) + (body + (h1 "Your choice") + (surflet-form + ,k-url + (p "Select the sweet you want:" + ,select-input-field) + ,(make-submit-button))))))) + (bindings (get-bindings req)) + (cost (with-fatal-error-handler + (lambda (condition decline) + (send-error (status-code bad-request) + req + "No such option or internal error. + Please try again.") ) + (raw-input-field-value select-input-field bindings)))) + (send-html/finish + `(html (head (title "Receipt")) + (body + (h2 "Your receipt:") + (p "This costs you $" ,cost ".")))))) +)) diff --git a/web-server/root/surflets/howto/annotate.scm b/web-server/root/surflets/howto/annotate.scm new file mode 100644 index 0000000..51eb35a --- /dev/null +++ b/web-server/root/surflets/howto/annotate.scm @@ -0,0 +1,29 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + (define (main req) + (let* ((select-input-field + (make-select + (map make-annotated-select-option + '("Icecream" "Chocolate" "Candy") + '(1.5 2.0 0.5)))) + (req (send-html/suspend + (lambda (k-url) + `(html + (head (title "Sweet Store")) + (body + (h1 "Your choice") + (surflet-form + ,k-url + (p "Select the sweet you want:" + ,select-input-field) + ,(make-submit-button))))))) + (bindings (get-bindings req)) + (cost (input-field-value select-input-field bindings))) + (send-html/finish + `(html (head (title "Receipt")) + (body + (h2 "Your receipt:") + (p "This costs you $" ,cost ".")))))) +)) diff --git a/web-server/root/surflets/howto/callback.scm b/web-server/root/surflets/howto/callback.scm new file mode 100755 index 0000000..e3de709 --- /dev/null +++ b/web-server/root/surflets/howto/callback.scm @@ -0,0 +1,28 @@ +(define-structure surflet surflet-interface + (open surflets + surflets/callbacks + scheme-with-scsh) + (begin + + (define (main req) + (let ((language (make-annotated-callback result-page))) + (send-html + `(html + (head (title "Multi-lingual")) + (body + (h2 "Select your language:") + (ul + (li (url ,(language "Hello, how are you?") + "English") + (li (url ,(language "Hallo, wie geht es Ihnen?") + "Deutsch"))))))))) + + (define (result-page req text) + (send-html/finish + `(html + (head (title "Greeting")) + (body + (h2 ,text))))) + + )) + diff --git a/web-server/root/surflets/howto/dispatch-annotated.scm b/web-server/root/surflets/howto/dispatch-annotated.scm new file mode 100755 index 0000000..272b5e7 --- /dev/null +++ b/web-server/root/surflets/howto/dispatch-annotated.scm @@ -0,0 +1,31 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + + (define (main req) + (let* ((language (make-annotated-address)) + (req (send-html/suspend + (lambda (k-url) + `(html + (head (title "Multi-lingual")) + (body + (h2 "Select your language:") + (ul + (li (url ,(language k-url "Hello, how are you?") + "English") + (li (url ,(language k-url "Hallo, wie geht es Ihnen?") + "Deutsch"))))))))) + (bindings (get-bindings req))) + (case-returned-via bindings + ((language) => result-page)))) + + (define (result-page text) + (send-html/finish + `(html + (head (title "Greeting")) + (body + (h2 ,text))))) + + )) + diff --git a/web-server/root/surflets/howto/dispatch.scm b/web-server/root/surflets/howto/dispatch.scm new file mode 100755 index 0000000..d21b35b --- /dev/null +++ b/web-server/root/surflets/howto/dispatch.scm @@ -0,0 +1,31 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + + (define (main req) + (let* ((english (make-address)) + (german (make-address)) + (req (send-html/suspend + (lambda (k-url) + `(html + (head (title "Multi-lingual")) + (body + (h2 "Select your language:") + (ul + (li (url ,(english k-url) "English") + (li (url ,(german k-url) "Deutsch"))))))))) + (bindings (get-bindings req))) + (case-returned-via bindings + ((english) (result-page "Hello, how are you?")) + ((german) (result-page "Hallo, wie geht es Ihnen?"))))) + + (define (result-page text) + (send-html/finish + `(html + (head (title "Greeting")) + (body + (h2 ,text))))) + + )) + diff --git a/web-server/root/surflets/howto/hello-date.scm b/web-server/root/surflets/howto/hello-date.scm new file mode 100644 index 0000000..9b21df3 --- /dev/null +++ b/web-server/root/surflets/howto/hello-date.scm @@ -0,0 +1,12 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + + (define (main req) + (send-html/finish + `(html (body (h1 "Hello, world!") + (p "The current date and time is " + ,(format-date "~H:~M:~S ~p ~m/~d/~Y" (date))))))) + )) + diff --git a/web-server/root/surflets/howto/hello-twice.scm b/web-server/root/surflets/howto/hello-twice.scm new file mode 100644 index 0000000..8b1896d --- /dev/null +++ b/web-server/root/surflets/howto/hello-twice.scm @@ -0,0 +1,15 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + + (define (main req) + (send-html/suspend + (lambda (k-url) + `(html (body (h1 "Hello, world!") + (p (a (@ (href ,k-url)) "Next page -->")))))) + + (send-html/finish + '(html (body (h1 "Hello, again!"))))) + )) + diff --git a/web-server/root/surflets/howto/hello.scm b/web-server/root/surflets/howto/hello.scm new file mode 100644 index 0000000..35c3d83 --- /dev/null +++ b/web-server/root/surflets/howto/hello.scm @@ -0,0 +1,10 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + + (define (main req) + (send-html/finish + '(html (body (h1 "Hello, world!"))))) + )) + diff --git a/web-server/root/surflets/howto/nibble-input.scm b/web-server/root/surflets/howto/nibble-input.scm new file mode 100755 index 0000000..4f13fab --- /dev/null +++ b/web-server/root/surflets/howto/nibble-input.scm @@ -0,0 +1,46 @@ +(define-structure surflet surflet-interface + (open surflets + surflets/my-input-fields + scheme-with-scsh) + (begin + + (define (make-nibble-input-fields) + (let ((checkboxes (list (make-annotated-checkbox 8) + (make-annotated-checkbox 4) + (make-annotated-checkbox 2) + (make-annotated-checkbox 1)))) + (make-multi-input-field + #f "nibble-input" + (lambda (input-field bindings) + (let loop ((sum 0) + (checkboxes checkboxes)) + (if (null? checkboxes) + sum + (loop (+ sum (or (input-field-value (car checkboxes) + bindings) + 0)) + (cdr checkboxes))))) + '() + (lambda (ignore) + checkboxes)))) + + (define nibble-input-field (make-nibble-input-fields)) + + (define (main req) + (let* ((req (send-html/suspend + (lambda (new-url) + `(html (title "Nibble Input Widget") + (body + (h1 "Nibble Input Widget") + (p "Enter your nibble (msb left):") + (surflet-form ,new-url + ,nibble-input-field + ,(make-submit-button))))))) + (bindings (get-bindings req)) + (number (input-field-value nibble-input-field bindings))) + (send-html + `(html (title "Result") + (body + (h2 "Result") + (p "You've entered " ,number ".")))))) + )) diff --git a/web-server/root/surflets/howto/user1.scm b/web-server/root/surflets/howto/user1.scm new file mode 100644 index 0000000..6d27e30 --- /dev/null +++ b/web-server/root/surflets/howto/user1.scm @@ -0,0 +1,23 @@ +(define-structure surflet surflet-interface + (open surflets + scheme-with-scsh) + (begin + (define (main req) + (let* ((text-input (make-text-field)) + (submit-button (make-submit-button)) + (req (send-html/suspend + (lambda (k-url) + `(html + (body + (h1 "Echo") + (surflet-form ,k-url + (p "Please enter something:" + ,text-input + ,submit-button))))))) + (bindings (get-bindings req)) + (user-input (input-field-value text-input bindings))) + (send-html/finish + `(html (body + (h1 "Echo result") + (p "You've entered: '" ,user-input "'.")))))) +)) diff --git a/scheme/httpd/surflets/web-server/root/surflets/news.scm b/web-server/root/surflets/news.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/news.scm rename to web-server/root/surflets/news.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/news.txt b/web-server/root/surflets/news.txt similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/news.txt rename to web-server/root/surflets/news.txt diff --git a/scheme/httpd/surflets/web-server/root/surflets/simple-surflet.scm b/web-server/root/surflets/simple-surflet.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/simple-surflet.scm rename to web-server/root/surflets/simple-surflet.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/spaceship.scm b/web-server/root/surflets/spaceship.scm similarity index 100% rename from scheme/httpd/surflets/web-server/root/surflets/spaceship.scm rename to web-server/root/surflets/spaceship.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/test.scm b/web-server/root/surflets/test.scm similarity index 99% rename from scheme/httpd/surflets/web-server/root/surflets/test.scm rename to web-server/root/surflets/test.scm index c66260e..2a0d9e1 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/test.scm +++ b/web-server/root/surflets/test.scm @@ -74,7 +74,7 @@ test")) (p "called " ,global " times") (p "Choose an annotated address:") (ul - (li (url ,(addr new-url "Zoe") "ab=ba")) + (li (url ,(addr new-url 13) "ab=ba")) (li (url ,(addr new-url "be"))) (p "Or choose an annotated callback")