r5294: *** empty log message ***
[lml2.git] / stdsite.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          stdsite.lisp
6 ;;;; Purpose:       Functions to create my standard style sites
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Aug 2002
9 ;;;;
10 ;;;; $Id: stdsite.lisp,v 1.7 2003/07/12 17:54:05 kevin Exp $
11 ;;;;
12 ;;;; This file, part of LML2, is Copyright (c) 2000-2003 by Kevin Rosenberg.
13 ;;;; Rights of modification and redistribution are in the LICENSE file.
14 ;;;;
15 ;;;; *************************************************************************
16
17
18 ;;; A "standard site" is a format for a certain style of web page.
19 ;;; It is based on the LML2 package.
20 ;;; A stdsite page expects to include the following files:
21 ;;;  header.lml_
22 ;;;  banner.lml_
23 ;;;  content.lml_
24 ;;;  footer.lml_
25
26 (in-package #:lml2)
27
28 (defmacro std-head (title &body body)
29   `(html
30     (:head 
31      (:title (:princ ,title))
32      (lml-load "header.lml_")
33      ,@body)))
34
35
36 (defun std-footer (file)
37   (html
38    ((:div :class "disclaimsec")
39     (let ((src-file (make-pathname
40                      :defaults *sources-dir*
41                      :type "lml"
42                      :name (pathname-name file))))       
43       (when (probe-file src-file)
44         (html
45          ((:div :class "lastmod")
46           (lml-format  "Last modified: ~A" (date-string (file-write-date src-file)))))))
47     (lml-load "footer.lml_"))))
48
49
50 (defmacro std-body (file &body body)
51   `(html
52     (:body
53      (lml-load "banner.lml_")
54      ((:table :class "stdbodytable" :border "0" :cellpadding "3")
55       (:tbody 
56        ((:tr :valign "top")
57         ((:td :class "stdcontentcell")
58          (lml-load "contents.lml_"))
59         ((:td :valign "top")
60          ,@body
61          (std-footer ,file))))))))
62   
63
64 (defmacro print-std-page (file title format &body body)
65   `(progn
66      (dtd-prologue ,format)
67      (html
68       ((:html :xmlns "http://www.w3.org/1999/xhtml")
69        (std-head ,title)
70        (std-body ,file ,@body)))))
71
72 (defmacro std-page ((out-file title &key (format :xhtml11))
73                     &body body)
74   `(let ((*indent* 0))
75      (with-open-file (*html-stream* (lml-file-name ,out-file :output)
76                       :direction :output
77                       :if-exists :supersede)
78        (print-std-page (lml-file-name ,out-file :source) ,title ,format ,@body))))
79
80 (defmacro titled-pre-section (title &body body)
81   `(progn
82     (html
83      (:h1 ,title)
84      ((:pre "style" "padding-left:30pt;")
85       ,@body))))
86
87
88