1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: ASDF definition file for Lisp Markup Language Version 2
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Aug 2002
10 ;;;; $Id: lml2.asd 7061 2003-09-07 06:34:45Z kevin $
12 ;;;; This file, part of LML2, is Copyright (c) 2002 by Kevin M. Rosenberg
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 ;;;; *************************************************************************
21 (defparameter *apache-name-width* 24)
23 (defun write-name-trailing-spaces (stream name)
24 (let* ((spaces (- *apache-name-width* (length name))))
26 (print-n-chars #\space spaces stream))))
28 (defun write-name-link (stream link name)
31 ((:a :href link) (:princ (string-maybe-shorten name *apache-name-width*))))
32 (write-name-trailing-spaces stream name))
34 (defun sort-dir-entries (entries sort-field direct)
39 (funcall (if (eq direct :asc) #'string-lessp #'string-greaterp)
41 (aif (third b) it "")))))
45 (funcall (if (eq direct :asc) #'< #'>)
47 (aif (fourth b) it 0)))))
51 (funcall (if (eq direct :asc) #'< #'>)
53 (aif (fifth b) it 0)))))
57 (funcall (if (eq direct :asc) #'string-lessp #'string-greaterp)
59 (aif (sixth b) it "")))))
63 (defun write-html-apache-directory (stream title entries this-url &key parent address query-string
65 (let* ((query (when query-string (split-uri-query-string query-string)))
68 ((string-equal (caar query) "N") :name)
69 ((string-equal (caar query) "M") :modified)
70 ((string-equal (caar query) "S") :size)
71 ((string-equal (caar query) "D") :description)
75 ((and query (string-equal (cdr (first query)) "D") :desc))
77 (setq entries (sort-dir-entries entries sort-field dir))
81 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">"
87 (:title (:princ title)))
89 ((:body :bgcolor "#FFFFFF" :text "#000000")
93 ((:td :bgcolor "#FFFFFF" :class "title")
94 ((:font :size "+3" :face "Hevetica,Arial,sans-serif")
95 (:b (:princ title))))))
102 :src (format nil "~Ablank.png" icon-base)
105 ((:a :href (format nil "~A?N=~A" this-url
106 (if (and (eq sort-field :name) (eq dir :asc))
109 (:princ (format nil "~20A" ""))
111 ((:a :href (format nil "~A?M=~A" this-url
112 (if (and (eq sort-field :modified) (eq dir :asc))
116 ((:a :href (format nil "~A?S=~A" this-url
117 (if (and (eq sort-field :size) (eq dir :asc))
121 ((:a :href (format nil "~A?D=~A" this-url
122 (if (and (eq sort-field :description) (eq dir :asc))
126 (:princ "<hr noshade align=\"left\" width=\"80%\">")
135 :src (format nil "~Aback.png" icon-base
138 (write-name-link stream (first parent) (second parent))
140 (print-n-chars #\space 17 stream)
143 (dolist (entry entries)
152 (:dir (format nil "~Afolder.png" icon-base))
153 (:text (format nil "~Atext.png" icon-base))
154 (t (format nil "~Af.png" icon-base))]
161 (write-name-link stream (second entry) (third entry))
163 (:princ (universal-time-to-apache-date (fourth entry)))
166 ((or (eq :dir (first entry))
167 (null (fifth entry)))
169 ((< (fifth entry) (* 1024 1024))
170 (format nil "~5,' Dk" (round (fifth entry) 1024)))
171 ((< (fifth entry) (* 1024 1024 1024))
172 (format nil "~5,' Dm" (round (fifth entry) (* 1024 1024))))
174 (format nil "~5,' Dg" (round (fifth entry) (* 1024 1024 1024))))
182 (:princ "<hr noshade align=\"left\" width=\"80%\">")
187 (:address address))))))))