r3074: *** empty log message ***
[kmrcl.git] / web-utils-aserve.lisp
index 92a89bdaa702d6cb72ee6f170b06c7dca06aa5d7..19ed28c5d92997bce5ada3f8d9df283a42e740d2 100644 (file)
@@ -1,3 +1,4 @@
+
 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
@@ -7,18 +8,18 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: web-utils-aserve.lisp,v 1.1 2002/10/06 13:21:47 kevin Exp $
+;;;; $Id: web-utils-aserve.lisp,v 1.7 2002/10/16 22:56:07 kevin Exp $
 ;;;;
-;;;; This file, part of Webutils, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
-;;;; Webutils users are granted the rights to distribute and use this software
-;;;; as governed by the terms of the GNU General Public License.
+;;;; KMRCL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; *************************************************************************
 
 
-
-(in-package :webutils)
-(declaim (optimize (speed 3) (safety 1)))
+(in-package :kmrcl)
+(declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
 
 
 ;;; AllegroServe interaction functions
     (princ-http "Browser Home"))
   (princ-http "</font><p></p>"))
 
-(defun head (title-str)
+(defun head (title-str &key css)
+  (unless css
+    (setq css "http://b9.com/main.css"))
   (net.html.generator:html 
-   (:head 
-    "<LINK rel=\"stylesheet\" href=\"http://www.med-info.com/main.css\" type=\"text/css\">"
+   (:head
+    (princ-http (format nil "<link rel=\"stylesheet\" href=\"~A\" type=\"text/css\"></link>" css))
     (:title (:princ-safe title-str)))))
 
 
 
 ;;; Page wrappers
 
-(defmacro with-xml-page (title &rest body)
-  `(prog1
-       (progn
-        (net.html.generator:html
-         (princ-http (std-xml-header))
-         (princ-http "<pagedata xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">"))
-        (with-tag "pagetitle" (princ-http ,title))
-        ,@body)
-     (princ-http "</pagedata>")))
-
-(defmacro with-trans-page (title &rest body)
-  `(prog1
-       (progn
-         (print-http "<?xml version=\"1.0\" standalone=\"yes\"?>")
-         (print-http "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"")
-         (print-http " \"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
-         (print-http "")
-         (print-http "<html xmlns=\"http://www.w3.org/1999/xhtml\">")
-         (head ,title)
-         (print-http "<body bgcolor=\"#FFFFFF\">")
-         (prog1 
-             ,@body
-           (print-http "</body>")))
-     (print-http "</html>")))
+(defmacro with-page ((title &key css (format :xhtml)) &rest body)
+  (case format
+    (:xhtml
+     `(prog1
+         (progn
+           (net.html.generator:html
+            (print-http *standard-xhtml-header*)
+            (print-http "<html xmlns=\"http://www.w3.org/1999/xhtml\">")
+            (head ,title :css ,css)
+            (print-http "<body>")
+            (prog1 
+                ,@body
+              (print-http "</body></html>"))))))
+    (:html
+     `(prog1
+         (progn
+           (net.html.generator:html
+            (print-http *standard-html-header*)
+            (head ,title :css ,css)
+            (print-http "<body>")
+            (prog1 
+                ,@body
+              (print-http "</body></html>"))))))
+    (:xml
+     `(prog1
+         (progn
+           (net.html.generator:html
+            (princ-http *standard-xml-header*
+            (princ-http "<pagedata xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">"))
+           (with-tag "pagetitle" (princ-http ,title))
+           ,@body)
+       (princ-http "</pagedata>")))))
 
 
 ;;; URL Encoding