r5182: *** 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.6 2003/06/23 23:58:29 kevin Exp $
11 ;;;;
12 ;;;; This file, part of LML2, is Copyright (c) 2002 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; LML2 users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the GNU General Public License v2
16 ;;;; (http://www.gnu.org/licenses/gpl.html)
17 ;;;; *************************************************************************
18
19 ;;; A "standard site" is a format for a certain style of web page.
20 ;;; It is based on the LML2 package.
21 ;;; A stdsite page expects to include the following files:
22 ;;;  header.lml_
23 ;;;  banner.lml_
24 ;;;  content.lml_
25 ;;;  footer.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   
64
65 (defmacro print-std-page (file title format &body body)
66   `(progn
67      (dtd-prologue ,format)
68      (html
69       ((:html :xmlns "http://www.w3.org/1999/xhtml")
70        (std-head ,title)
71        (std-body ,file ,@body)))))
72
73 (defmacro std-page ((out-file title &key (format :xhtml11))
74                     &body body)
75   `(let ((*indent* 0))
76      (with-open-file (*html-stream* (lml-file-name ,out-file :output)
77                       :direction :output
78                       :if-exists :supersede)
79        (print-std-page (lml-file-name ,out-file :source) ,title ,format ,@body))))
80
81 (defmacro titled-pre-section (title &body body)
82   `(progn
83     (html
84      (:h1 ,title)
85      ((:pre "style" "padding-left:30pt;")
86       ,@body))))
87
88
89