r2958: *** empty log message ***
[kmrcl.git] / web-utils.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          web-utils.lisp
6 ;;;; Purpose:       Basic web utility functions
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Apr 2000
9 ;;;;
10 ;;;; $Id: web-utils.lisp,v 1.3 2002/10/09 14:24:47 kevin Exp $
11 ;;;;
12 ;;;; This file, part of Kmrcl, is Copyright (c) 2002 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; Kmrcl users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the GNU General Public License.
16 ;;;; *************************************************************************
17
18 (in-package :kmrcl)
19 (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
20
21
22 ;;; HTML/XML constants
23
24 (defvar *std-xml-header* 
25   (format nil 
26   "<?xml version=\"1.0\" ?>~%<?xml-stylesheet type=\"text/css\" href=\"/umlsclass.css\" ?>~%~%"))
27
28 (defun std-xml-header ()
29   *std-xml-header*)
30
31 ;;; URL Functions
32
33 (defvar *base-url* "")
34 (defun base-url! (url)
35   (setq *base-url* url))
36
37 (defun make-url (page-name &key (base-dir *base-url*) (vars nil))
38   (concatenate 'string base-dir page-name
39                (if vars
40                    (string-trim-last-character
41                     (concatenate 'string "?"
42                                  (mapcar-append-string 
43                                   #'(lambda (var) 
44                                       (when (and (car var) (cadr var))
45                                           (concatenate 'string 
46                                             (car var) "=" (cadr var) "&")))
47                                   vars)))
48                  "")))
49