From 52e0a557e2a1defe0734b9f8143435a6cba33f71 Mon Sep 17 00:00:00 2001 From: interp Date: Fri, 21 Nov 2003 19:09:12 +0000 Subject: [PATCH] Some example files mentioned in the howto. --- .../root/surflets/howto/annotate.scm | 29 +++++++++++++++++++ .../root/surflets/howto/hello-date.scm | 12 ++++++++ .../root/surflets/howto/hello-twice.scm | 15 ++++++++++ .../web-server/root/surflets/howto/hello.scm | 10 +++++++ .../web-server/root/surflets/howto/user1.scm | 23 +++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 scheme/httpd/surflets/web-server/root/surflets/howto/annotate.scm create mode 100644 scheme/httpd/surflets/web-server/root/surflets/howto/hello-date.scm create mode 100644 scheme/httpd/surflets/web-server/root/surflets/howto/hello-twice.scm create mode 100644 scheme/httpd/surflets/web-server/root/surflets/howto/hello.scm create mode 100644 scheme/httpd/surflets/web-server/root/surflets/howto/user1.scm diff --git a/scheme/httpd/surflets/web-server/root/surflets/howto/annotate.scm b/scheme/httpd/surflets/web-server/root/surflets/howto/annotate.scm new file mode 100644 index 0000000..51eb35a --- /dev/null +++ b/scheme/httpd/surflets/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/scheme/httpd/surflets/web-server/root/surflets/howto/hello-date.scm b/scheme/httpd/surflets/web-server/root/surflets/howto/hello-date.scm new file mode 100644 index 0000000..9b21df3 --- /dev/null +++ b/scheme/httpd/surflets/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/scheme/httpd/surflets/web-server/root/surflets/howto/hello-twice.scm b/scheme/httpd/surflets/web-server/root/surflets/howto/hello-twice.scm new file mode 100644 index 0000000..8b1896d --- /dev/null +++ b/scheme/httpd/surflets/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/scheme/httpd/surflets/web-server/root/surflets/howto/hello.scm b/scheme/httpd/surflets/web-server/root/surflets/howto/hello.scm new file mode 100644 index 0000000..35c3d83 --- /dev/null +++ b/scheme/httpd/surflets/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/scheme/httpd/surflets/web-server/root/surflets/howto/user1.scm b/scheme/httpd/surflets/web-server/root/surflets/howto/user1.scm new file mode 100644 index 0000000..6d27e30 --- /dev/null +++ b/scheme/httpd/surflets/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 "'.")))))) +))