r4926: Auto commit for Debian build
[hyperobject.git] / views.lisp
index caf7ad3747831cc5a4ef2808e04abeef1408d040..27c4af8227c9b0a8d7a07f5d9c2b0bfc17dc5281 100644 (file)
@@ -7,10 +7,9 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: views.lisp,v 1.34 2003/05/14 04:38:36 kevin Exp $
-;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; $Id: views.lisp,v 1.38 2003/05/14 06:38:24 kevin Exp $
 ;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
 ;;;; *************************************************************************
  
 (in-package :hyperobject)
       (when (and (view-has-links-p view) (esd-hyperlink slot))
        (push (slot-definition-name slot) links)))
 
-    (setf (obj-data-print-code view) `(lambda (x s links)
-                                      (declare (ignorable links))
-                                      ,@(map 'list #'identity print-func)))
-    
-    (setf (obj-data-func view)
-         (when print-func (compile nil (eval (obj-data-print-code view)))))
+    (when (plusp (length print-func))
+      (setf (obj-data-print-code view) `(lambda (x s links)
+                                        (declare (ignorable links))
+                                        ,@(map 'list #'identity print-func)))
+      (setf (obj-data-func view)
+           (compile nil (eval (obj-data-print-code view)))))
     
     (setf (link-slots view) (nreverse links)))
 
 
 (defvar +newline-string+ (format nil "~%"))
 
+(defun write-user-name-maybe-plural (obj nitems strm)
+  (write-string
+   (if (> nitems 1)
+       (hyperobject-class-user-name-plural obj)
+       (hyperobject-class-user-name obj))
+   strm))
+
 (defun initialize-text-view (view)
   (setf (list-start-str-or-func view)
        (compile nil
                 (eval '(lambda (obj nitems strm)
-                    (format strm "~a~P:~%"
-                            (hyperobject-class-user-name obj) nitems)))))
+                        (write-user-name-maybe-plural obj nitems strm)
+                        (write-char #\: strm)
+                        (write-char #\Newline strm)))))
   (setf (list-start-indent view) t)
   (setf (obj-data-indent view) t)
   (setf (obj-data-end-str view) +newline-string+))
 
 (defun html-list-start-func (obj nitems strm)
-  (format strm "<p><b>~a~p:</b></p><div class=\""
-         (hyperobject-class-user-name obj) nitems)
+  (write-string "<p><b>" strm)
+  (write-user-name-maybe-plural obj nitems strm)
+  (write-string ":</b></p><div class=\"" strm)
   (write-string (class-name-of obj) strm)
   (write-string "\"><ul>" strm)
   (write-char #\newline strm))
   (write-char #\< strm)
   (write-string (class-name-of x) strm)
   (write-string "list><title>" strm)
-  (format strm "~A~P:</title> ~%"
-         (hyperobject-class-user-name x) nitems))
+  (write-user-name-maybe-plural x nitems strm)
+  (write-string ":</title>" strm)
+  (write-char #\newline strm))
 
 (defun initialize-xml-view (view)
   (initialize-text-view view)
                (dolist (var refvars)
                  (string-append
                   varstr (link-ampersand view)
-                  (format nil "~a=~a" (car var) (cadr var))))
+                  (format nil "~a=~a" (car var) (cdr var))))
                varstr)
              "")))