r11290: add _final.lml processing
[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$
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 ;;;  final.lml_
26
27 (in-package #:lml2)
28
29 (defmacro std-head (title &body body)
30   `(html
31     (:head 
32      (:title (:princ ,title))
33      (lml-load "header.lml_")
34      ,@body)))
35
36
37 (defun std-footer (file)
38   (html
39    ((:div :class "disclaimsec")
40     (let ((src-file (make-pathname
41                      :defaults *sources-dir*
42                      :type "lml"
43                      :name (pathname-name file))))       
44       (when (probe-file src-file)
45         (html
46          ((:div :class "lastmod")
47           (lml-format  "Last modified: ~A" (date-string (file-write-date src-file)))))))
48     (lml-load "footer.lml_"))))
49
50
51 (defmacro std-body (file &body body)
52   `(html
53     (:body
54      (lml-load "banner.lml_")
55      ((:table :class "stdbodytable" :border "0" :cellpadding "3")
56       (:tbody 
57        ((:tr :valign "top")
58         ((:td :class "stdcontentcell")
59          (lml-load "contents.lml_"))
60         ((:td :valign "top")
61          ,@body
62          (std-footer ,file)))))
63      (lml-load "final.lml_"))))
64   
65
66 (defmacro print-std-page (file title format &body body)
67   `(progn
68      (dtd-prologue ,format)
69      (html
70       ((:html :xmlns "http://www.w3.org/1999/xhtml")
71        (std-head ,title)
72        (std-body ,file ,@body)))))
73
74 (defmacro std-page ((out-file title &key (format :xhtml11))
75                     &body body)
76   `(let ((*indent* 0))
77      (with-open-file (*html-stream* (lml-file-name ',out-file :output)
78                       :direction :output
79                       :if-exists :supersede)
80        (print-std-page (lml-file-name ',out-file :source) ,title ,format ,@body))))
81
82 (defmacro titled-pre-section (title &body body)
83   `(progn
84     (html
85      (:h1 ,title)
86      ((:pre "style" "padding-left:30pt;")
87       ,@body))))
88
89
90