;;;-*- Mode: Lisp; Package: HTTP-DEMO -*- (in-package :http-user) ; ; Bulletin board form example ; (defmacro with-page ((url stream title) &body body) "Provides the response function to emit a page body." `(with-successful-response (,stream :html) (with-html-document (:stream ,stream) (with-document-preamble (:stream ,stream) (declare-title ,title :stream ,stream)) (with-document-body (:stream ,stream) (with-section-heading (,title :stream ,stream) ,@body))))) (defparameter *board* nil) (defun display-bulletin-board (url stream) "Routine to display a bulletin board and a form." (with-page (url stream "Feedback") (dolist (topic (reverse *board*)) (with-paragraph (:stream stream) (write-string-quoting-specials topic stream))) (with-fillout-form (:post url :stream stream) (accept-input 'string "text" :stream stream) (accept-input 'submit-button "Submit" :stream stream)))) (defun update-bulletin-board (url stream alist) "Response function to add an entry to the bulletin board." (bind-query-values (text) (url alist) (atomic-push text *board*) (display-bulletin-board url stream))) (export-url "http://localhost:8000/board.html" :html-computed-form :form-function 'display-bulletin-board :response-function 'update-bulletin-board)