2003-01-19 11:57:27 -05:00
|
|
|
(define-structure surflet surflet-interface
|
|
|
|
(open surflets
|
+ Splitting file surflets.scm into several packages
- Removing surflets.scm
+ The surflets package remains and collects the most usual used packages
It does not export any more the outdaters, the access to IDs
(like session-id), callbacks, form-query-list.
(and maybe some other stuff I've forgot to mention here, see list
below).
The new packages are (not included in surflets are marked (*)):
+ surflets/addresses: MAKE-ADDRESS, MAKE-ANNOTATED-ADDRESS
+ surflets/bindings: GET-BINDINGS, EXTRACT-BINDINGS and stuff
+ surflets/ids (*): MY-SESSION-ID, .., INSTANCE-SESSION-ID
+ surflets/input-fields: MAKE-INPUT-FIELD, MAKE-NUMBER-INPUT-FIELD...
+ surflets/outdaters(*): MAKE-OUTDATER, OUTDATER?...
+ surflets/returned-via: RETURNED-VIA, CASE-RETURNED-VIA
+ surflets/send-html: SEND-HTML/SUSPEND...
+ surflets/surflet-sxml: URL-RULE,..., SURLFET-SXML-RULES, ...
+ surflets/sxml: SXML->STRING, DEFAULT-RULE,...
+ surflets/typed-optionals(*): TYPED-OPTIONALS, OPTIONALS
+ surflets/utilities(*): MAKE-CALLBACK, FORM-QUERY-LIST,
GENERATE-UNIQUE-NAME...
2003-03-10 11:29:32 -05:00
|
|
|
surflets/utilities ;form-query-list
|
2003-02-17 05:09:24 -05:00
|
|
|
surflet-requests
|
2003-03-13 06:36:49 -05:00
|
|
|
surflet-handler/primitives
|
2002-10-09 11:22:50 -04:00
|
|
|
httpd-responses
|
2002-09-24 05:03:30 -04:00
|
|
|
url
|
2002-12-08 10:49:27 -05:00
|
|
|
scheme-with-scsh)
|
2002-09-24 05:03:30 -04:00
|
|
|
(begin
|
|
|
|
|
|
|
|
(define (get-number input-text . maybe-title)
|
|
|
|
(let* ((title (if (pair? maybe-title) (car maybe-title) #f))
|
2003-01-17 12:48:20 -05:00
|
|
|
(result
|
|
|
|
(send-html/suspend
|
|
|
|
(lambda (new-url)
|
|
|
|
`(html ,(if title
|
|
|
|
`(title ,title) '())
|
|
|
|
(body
|
|
|
|
,(if title `(h2 ,title) '())
|
|
|
|
(p
|
|
|
|
(form (@ (method "get")
|
|
|
|
(action ,new-url))
|
|
|
|
,input-text " "
|
|
|
|
(input (@ (type "text")
|
|
|
|
(name "number"))
|
|
|
|
(input (@ (type "submit"))))))
|
|
|
|
(hr)
|
2003-03-09 15:15:08 -05:00
|
|
|
(p (url "/" "Return to main menu") (br)
|
|
|
|
(url "add-html.scm" "Start new calculation."))))))))
|
2003-03-09 14:57:56 -05:00
|
|
|
(let* ((bindings (form-query-list
|
2005-04-04 17:13:35 -04:00
|
|
|
(http-url-query (surflet-request-url result))))
|
2002-09-24 05:03:30 -04:00
|
|
|
(number (string->number
|
2002-10-26 11:40:26 -04:00
|
|
|
(extract-single-binding "number" bindings))))
|
2002-09-24 05:03:30 -04:00
|
|
|
(if number
|
|
|
|
number
|
2002-10-09 11:22:50 -04:00
|
|
|
(get-number input-text "Please enter a valid number")))))
|
2002-09-24 05:03:30 -04:00
|
|
|
|
|
|
|
(define (get-number1)
|
2002-10-09 11:22:50 -04:00
|
|
|
(get-number "First number:" "Calculation - Step one"))
|
2002-09-24 05:03:30 -04:00
|
|
|
|
|
|
|
(define (get-number2)
|
2002-10-09 11:22:50 -04:00
|
|
|
(get-number "Second number:" "Calculation - Step two"))
|
2002-09-24 05:03:30 -04:00
|
|
|
|
|
|
|
(define (main req)
|
2002-10-09 11:22:50 -04:00
|
|
|
(let ((req
|
|
|
|
(send-html/suspend
|
|
|
|
(lambda (new-url)
|
|
|
|
`(html (title "Result")
|
2003-01-16 07:09:49 -05:00
|
|
|
(body (h2 "Result")
|
2002-10-09 11:22:50 -04:00
|
|
|
(p ,(number->string (+ (get-number1) (get-number2))))
|
2003-01-16 07:09:49 -05:00
|
|
|
(hr)
|
2003-02-21 04:49:35 -05:00
|
|
|
(a (@ (href "add-html.scm")) "New calculation (new session)")(br)
|
2003-01-19 12:26:56 -05:00
|
|
|
(a (@ (href "javascript:history.go(-2)")) "New calculation (same session)")(br)
|
2003-01-16 07:09:49 -05:00
|
|
|
(a (@ (href ,new-url)) "Close this session")))))))
|
2002-12-07 17:26:40 -05:00
|
|
|
;; How to clear session data and go to another HTML page:
|
2004-08-11 15:06:05 -04:00
|
|
|
(send-error (status-code temp-redirect) req
|
2003-01-25 08:42:50 -05:00
|
|
|
"/" "/")
|
2002-10-09 11:22:50 -04:00
|
|
|
))
|
2002-09-24 05:03:30 -04:00
|
|
|
; ))
|
|
|
|
))
|
|
|
|
|