+ 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
|
|
|
;;; Copyright 2002, 2003 Andreas Bernauer
|
|
|
|
|
|
|
|
;;; adapted from Oleg's SXML-tree-trans.scm SRV:send-reply
|
|
|
|
;;; extended by port argument
|
|
|
|
;;; #t: current-output-port
|
|
|
|
;;; #f: string
|
|
|
|
;;; port: port
|
|
|
|
;;; else: error
|
|
|
|
;; Displays low-level-sxml on the port. Low-level-sxml contains only
|
|
|
|
;; strings, characters and thunks. '() and #f are ignored.
|
|
|
|
(define (display-low-level-sxml fragments port)
|
|
|
|
(let loop ((fragments fragments) (result #f))
|
|
|
|
(cond
|
|
|
|
((null? fragments) result)
|
|
|
|
((not (car fragments)) (loop (cdr fragments) result))
|
|
|
|
((null? (car fragments)) (loop (cdr fragments) result))
|
|
|
|
((pair? (car fragments))
|
|
|
|
(loop (cdr fragments) (loop (car fragments) result)))
|
|
|
|
((procedure? (car fragments))
|
|
|
|
((car fragments))
|
|
|
|
(loop (cdr fragments) #t))
|
|
|
|
(else
|
|
|
|
(display (car fragments) port)
|
|
|
|
(loop (cdr fragments) #t)))))
|
|
|
|
|
2003-05-04 10:04:54 -04:00
|
|
|
(define sxml->low-level-sxml pre-post-order)
|
|
|
|
|
+ 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
|
|
|
;; Gives you a string representing the HTML of the already reformatted
|
|
|
|
;; SXML-TREE.
|
|
|
|
(define (sxml->string sxml-tree rules)
|
|
|
|
(call-with-string-output-port
|
|
|
|
(lambda (port)
|
|
|
|
(display-low-level-sxml
|
|
|
|
(pre-post-order sxml-tree rules)
|
|
|
|
port))))
|
|
|
|
|
2003-03-13 06:32:16 -05:00
|
|
|
(define (sxml->string/internal sxml-tree rules)
|
|
|
|
(list (sxml->string sxml-tree rules)))
|
|
|
|
|
+ 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
|
|
|
;; Predicate for attributes in sxml.
|
|
|
|
(define (sxml-attribute? thing)
|
|
|
|
(and (pair? thing)
|
|
|
|
(eq? '@ (car thing))))
|
|
|
|
|
2003-04-15 05:33:32 -04:00
|
|
|
;; Returns the attribute list after the initial '@. For our
|
|
|
|
;; convenience, it ignores values that are not sxml-attributes.
|
|
|
|
(define (sxml-attribute-attributes thing)
|
2003-04-16 08:20:57 -04:00
|
|
|
(if (sxml-attribute? thing)
|
|
|
|
(cdr thing)
|
|
|
|
'()))
|
+ 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
|
|
|
|
|
|
|
;; Default rule: Creates leading and trailing tag and encloses the
|
|
|
|
;; attributes.
|
|
|
|
(define default-rule
|
|
|
|
`(*default*
|
|
|
|
. ,(lambda (tag . elems) (apply (entag tag) elems))))
|
|
|
|
|
|
|
|
;; Just displays the string, except that some characters are escaped.
|
|
|
|
(define text-rule
|
|
|
|
`(*text*
|
|
|
|
. ,(lambda (trigger str)
|
|
|
|
(if (string? str) (string->goodHTML str) str))))
|
|
|
|
|
|
|
|
;; Rule for attribution: creates an attribute like "selected" or
|
|
|
|
;; "color="red""
|
|
|
|
(define attribute-rule
|
|
|
|
`(@ ; local override for attributes
|
|
|
|
((*default*
|
|
|
|
. ,(lambda (attr-key . value) (enattr attr-key value))))
|
|
|
|
. ,(lambda (trigger . value) (list '@ value))))
|
|
|
|
|
|
|
|
;; Create attribution-value pair for inside of tags
|
|
|
|
;; If the attribute has no value, value must be '()
|
|
|
|
(define (enattr attr-key attr-value)
|
|
|
|
(if (null? attr-value)
|
|
|
|
(list #\space attr-key)
|
|
|
|
(list #\space attr-key "=\"" attr-value #\")))
|