File: stdsite.lisp

package info (click to toggle)
cl-lml2 1.6.6-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 184 kB
  • sloc: lisp: 1,316; makefile: 39
file content (91 lines) | stat: -rw-r--r-- 2,723 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name:          stdsite.lisp
;;;; Purpose:       Functions to create my standard style sites
;;;; Programmer:    Kevin M. Rosenberg
;;;; Date Started:  Aug 2002
;;;;
;;;; $Id$
;;;;
;;;; This file, part of LML2, is Copyright (c) 2000-2003 by Kevin Rosenberg.
;;;; Rights of modification and redistribution are in the LICENSE file.
;;;;
;;;; *************************************************************************


;;; A "standard site" is a format for a certain style of web page.
;;; It is based on the LML2 package.
;;; A stdsite page expects to include the following files:
;;;  header.lml_
;;;  banner.lml_
;;;  content.lml_
;;;  footer.lml_
;;; These files are optional
;;;  final.lml_
;;;  rightcol.lml_

(in-package #:lml2)

(defmacro std-head (title &body body)
  `(html
    (:head
     (:title (:princ ,title))
     (lml-load "header.lml_")
     ,@body)))


(defun std-footer (file)
  (html
   ((:div :class "disclaimsec")
    (let ((src-file (make-pathname
                     :defaults *sources-dir*
                     :type "lml"
                     :name (pathname-name file))))
      (when (probe-file src-file)
        (html
         ((:div :class "lastmod")
          (lml-format  "Last modified: ~A" (date-string (file-write-date src-file)))))))
    (lml-load "footer.lml_"))))


(defmacro std-body (file &body body)
  `(html
    (:body
     (lml-load "banner.lml_")
     ((:table :class "stdbodytable" :border "0" :cellpadding "3")
      (:tbody
       ((:tr :valign "top")
        ((:td :class "stdcontentcell")
         (lml-load "contents.lml_"))
        ((:td :valign "top")
         ,@body
         (std-footer ,file))
        ((:td :valign "top")
         (lml-load "rightcol.lml_" :optional t)))))
     (lml-load "final.lml_" :optional t))))


(defmacro print-std-page (file title format encoding &body body)
  `(progn
     (dtd-prologue ,format ,encoding)
     (html
      ((:html :xmlns "http://www.w3.org/1999/xhtml")
       (std-head ,title)
       (std-body ,file ,@body)))))

(defmacro std-page ((out-file title &key (format :xhtml10-strict) (encoding :utf-8))
                    &body body)
  `(let ((*indent* 0))
     (with-open-file (*html-stream* (lml-file-name ',out-file :output)
                      :direction :output
                      :if-exists :supersede)
       (print-std-page (lml-file-name ',out-file :source) ,title ,format ,encoding ,@body))))

(defmacro titled-pre-section (title &body body)
  `(progn
    (html
     (:h1 ,title)
     ((:pre "style" "padding-left:30pt;")
      ,@body))))