;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: downloads.lisp ;;;; Purpose: Generate downloads page ;;;; 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. ;;;; ;;;; ************************************************************************* (in-package #:lml2) (defstruct dl-data base url name indent signed) (defun list-files (files dl-data) "List files in a directory for downloading" ;;files.sort() (mapcar (lambda (f) (print-file f dl-data)) files)) (defun strip-dl-base (file base) (let ((fdir (pathname-directory file)) (bdir (pathname-directory base))) (make-pathname :name (pathname-name file) :type (pathname-type file) :directory (when (> (length fdir) (length bdir)) (append '(:absolute) (subseq fdir (length bdir) (length fdir))))))) (defun print-file (file dl-data) (let ((size 0) (modtime (date-string (file-write-date file))) (basename (namestring (make-pathname :name (pathname-name file) :type (pathname-type file)))) (dl-name (strip-dl-base file (dl-data-base dl-data))) (sig-path (concatenate 'string (namestring file) ".asc"))) (when (plusp (length basename)) (with-open-file (strm file :direction :input) (setq size (round (/ (file-length strm) 1024)))) (lml-format "~A" (dl-data-url dl-data) dl-name basename) (lml-princ "") (lml-format " (~A, ~:D KB)" modtime size) (when (probe-file sig-path) (setf (dl-data-signed dl-data) t) (lml-format " [Signature]" (dl-data-url dl-data) dl-name)) (html :br)))) (defun display-header (name url) (lml-princ "