[Bese-devel] small patch for XHTML strict
Friedrich Dominicus
frido at q-software-solutions.de
Tue Jul 26 16:23:02 UTC 2005
"Marco Baringer" <mb at bese.it> writes:
>
>> Another thing I've changed is extending the window-component to be
>> even more paremetrized. If anyone is intersted, just drop me a note.
>
> i'm interested.
Please be aware: It's very much influx. I'm tying to wrap around my
brain for "UCW" programming. This is a first protyp which works for me
but won't for you because you are lacking a few of the writer
functions.
If I will go to the point where the applicaton I try to implement will
run here, I may think about more parametrization of all the things,
that others will be able to use it.
I'm thinking that one should use a separate "write-header"
function, but I did not do it yet.
I think the documentation in window.lisp is outdated. I cite:
"Subclass of simple-window-component should implement the
render-body method, not render-on."))"
There's no where a render method to find.
(in-package :qss.web.ucw)
(defclass qss-window (window-component)
((title :accessor title
:initarg :title
:initform "Q Software Solutions" )
(html-version :accessor html-version
:initarg :html-version
:initform +xhtml1.0-strict+)
(meta-tags :accessor meta-tags
:initarg :meta-tags
:initform nil)
(menu-index :accessor menu-index
:initarg :menu-index)
(write-header :initform nil)
(write-menu-fun :accessor write-menu-fun
:initarg :write-menu-fun
:initform #'(lambda (stream index)
(write-main-menu :stream stream
:active index)))
(write-footer-fun :accessor write-footer-fun
:initarg :write-footer-fun
:initform #'(lambda (stream)
(write-footer :stream stream)))
(stylesheet :accessor stylesheet
:initarg :stylesheet
:initform "/css/qss.css"
:documentation "The URL of the css file to use as a stylesheet for this window.")
(content-type :accessor content-type
:initarg :content-type
:initform "text/html"
:documentation "The Content-Type header for the
http response (also used in the meta tag)"))
(:metaclass standard-component-class)
(:documentation "The QSS standard page class"))
(defmethod render-on :wrapping ((res response) (window qss-window))
"This convience method assumes: 1) the stylesheet is
external (as opposed to inlined) or is not used; 2) no JavaScript at all."
(let ((stream (content-stream res)))
(<:as-is (html-version window))
(<:html
(<:head
(dolist (meta-tag (meta-tags window))
(<:as-is (format nil "<meta ~a=\"~a\" content=\"~a\" />~%"
(first meta-tag) (second meta-tag) (third meta-tag))))
(<:title (<:as-is (title window)))
(when (stylesheet window)
(<:link :rel "stylesheet"
:href (stylesheet window)
:type "text/css")))
(<:body
(funcall (write-menu-fun window) stream (menu-index window))
(call-next-method)
(funcall (write-footer-fun window) stream)))))
;; test page
#|
(defclass simple-qss-window (qss-window)
((menu-index :initform +home-index+)
(meta-tags :initform +no-cache+)
(title :initform "Simple page"))
(:metaclass standard-component-class))
(defmethod render-on ((res response) (window simple-qss-window))
(declare (ignore res window))
(<:h1 "Just one header in the body"))
(defentry-point "qss-window.ucw" (:application *shop*) ()
(call 'simple-qss-window))
|#
I'm using this code like this at the moment:
(defcomponent customer-input-page (qss-window)
((menu-index :initform +store-index+)
(customer-data :initarg :customer-data :accessor customer-data)
(address :initarg :address :accessor address))
(:metaclass standard-component-class)
(:default-initargs :title "You personal data"))
(defmethod render-on ((res response) (address qss.db::shipping-address))
(<:table
(<:tr
(<:td "Street")
(<:td (<:as-is (slot-value address 'street))))
(<:tr
(<:td "ZIP")
(<:td (<:as-is (slot-value address 'zip))))))
The output is like this:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ucw-snapshot1.png
Type: image/png
Size: 65565 bytes
Desc: Snapshot of the modified standard page
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20050726/fe82e27c/attachment.png>
-------------- next part --------------
Regards
Friedrich
More information about the bese-devel
mailing list