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