1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: downloads.cl
6 ;;;; Purpose: Generate downloads page
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Aug 2002
10 ;;;; $Id: downloads.cl,v 1.1 2002/09/16 01:13:49 kevin Exp $
12 ;;;; This file, part of LML, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; LML 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 ;;;; *************************************************************************
19 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
26 (defvar *section-indent* 0)
29 (defun list-files (files)
30 "List files in a directory for downloading"
32 (mapcar #'print-file files))
34 (defun strip-ftp-base (file)
35 (let ((fdir (pathname-directory file))
36 (bdir (pathname-directory *ftp-base*)))
38 :name (pathname-name file)
39 :type (pathname-type file)
41 (when (> (length bdir) (length fdir))
43 (subseq (length bdir) (length fdir) fdir))))))
45 (defun print-file (file)
46 (let ((size (round (/ (file-length file) 1024)))
47 (modtime (date-string (file-write-date file)))
49 (make-pathname :name (pathname-name file)
50 :type (pathname-type file))))
51 (ftp-name (strip-ftp-base file))
53 (make-pathname :defaults file
56 (pathname-type file) ".asc"))))
57 (lml-print "<a href=\"~A~A\">~A</a>" *ftp-url* ftp-name basename)
58 (lml-print "<span class=\"modtime\">")
59 (lml-print " (~A, <b>~:D <span style=\"font-size:90%;\">KB</span></b>)</span>" modtime size)
60 (when (probe-file sig-path)
62 (lml-print " [<a href=\"~A~A.asc\">Signature</a>]" *ftp-url* ftp-name))
65 (defun display-header (name url)
66 (lml-print "<h1>Download</h1>")
67 (lml-print "<div class=\"mainbody\">")
68 (lml-print "<h3>Browse ~A FTP Site</h3>" name)
69 (lml-print "<a style=\"padding-left:20pt;\" href=\"~A\">~A</a>" url url))
71 (defun display-footer ()
73 (lml-print "<h3>GPG Public Key</h3>")
74 (lml-print "Use this <a href=\"https://www.b9.com/key.asc\">key</a> to verify file signtatures"))
77 (defun print-sect-title (title)
78 (lml-print "<h~D>~A</h~D>" *section-indent* title *section-indent*))
80 (defun filter-against-base (files)
83 (let ((name (pathname-name f)))
86 (dotimes (i (length *base-name*))
88 (unless (char= (char *base-name* i)
90 (return-from search nil)))
93 (sort filtered #'(lambda (a b) (string<
97 (defun display-one-section (title pat)
98 (let ((files (filter-against-base (directory pat))))
100 (print-sect-title title)
101 (lml-print "<div style=\"padding-left: 20pt;\">")
103 (lml-print"</div>"))))
106 (defun display-sections (sects)
108 (let ((title (car sects))
109 (value (cadr sects)))
111 (mapcar #'display-sections sects)
114 (print-sect-title title)
115 (incf *section-indent*)
116 (display-sections value)
117 (decf *section-indent*))
118 (display-one-section title value))))))
120 (defun display-page (pkg-name pkg-base ftp-base ftp-url sects)
121 (let ((*section-indent* 3)
122 (*ftp-base* ftp-base)
124 (*base-name* pkg-base)
126 (display-header pkg-name ftp-url)
127 (mapcar #'display-sections sects)
130 (defun std-dl-page (pkg-name pkg-base ftp-base ftp-url)
131 (let ((base (parse-namestring ftp-base)))
132 (let ((tgz-path (make-pathname :defaults base :type "gz" :name :wild))
133 (zip-path (make-pathname :defaults base :type "zip" :name :wild))
134 (doc-path (make-pathname :defaults base :type "pdf" :name :wild)))
135 (display-page pkg-name pkg-base ftp-base ftp-url
136 `(("Manual" ,doc-path)
138 (("Unix (.tar.gz)" ,tgz-path)
139 ("Windows (.zip)" ,zip-path))))))))
141 (defun full-dl-page (pkg-name pkg-base ftp-base ftp-url)
142 (let ((base (parse-namestring ftp-base)))
143 (let ((tgz-path (make-pathname :defaults base :type "gz" :name :wild))
144 (zip-path (make-pathname :defaults base :type "zip" :name :wild))
145 (doc-path (make-pathname :defaults base :type "pdf" :name :wild))
146 (deb-path (merge-pathnames
147 (make-pathname :directory '(:relative "linux-debian")
148 :type :wild :name :wild)
150 (rpm-path (merge-pathnames
151 (make-pathname :directory '(:relative "linux-rpm")
152 :type :wild :name :wild)
154 (w32-path (merge-pathnames
155 (make-pathname :directory '(:relative "w32")
156 :type :wild :name :wild)
158 (display-page pkg-name pkg-base ftp-base ftp-url
159 `(("Manual" ,doc-path)
161 (("Unix (.tar.gz)" ,tgz-path)
162 ("Windows (.zip)" ,zip-path)))
165 (("Debian Linux" ,deb-path)
166 ("RedHat Linux" ,rpm-path)))
167 ("Windows Binaries" ,w32-path))))))))