r5165: *** 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.2 2003/06/20 04:46:54 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 ;;;  head.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 "head.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     (when (probe-file "footer.lml_")
49       (lml-load "footer.lml_")))))
50
51
52 (defmacro std-body (file &body body)
53   `(html
54     (:body
55      (lml-load "banner.lml_")
56      ((:table :class "stdbodytable" :border "0" :cellpadding "3")
57       (:tbody 
58        ((:tr :valign "top")
59         ((:td :class "stdcontentcell")
60          (lml-load "contents.lml_"))
61         ((:td :valign "top")
62          ,@body
63          (std-footer ,file))))))))
64   
65
66 (defmacro print-std-page (file title &body body)
67   `(progn
68     (xhtml-prologue)
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 &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 ,@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