r3071: *** 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.5 2002/10/16 17:37:18 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 Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
18
19 (in-package :kmrcl)
20 (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
21
22
23 ;;; HTML/XML constants
24
25 (defvar *std-xml-header* 
26   (format nil 
27   "<?xml version=\"1.0\" ?>~%<?xml-stylesheet type=\"text/css\" href=\"http://b9.com/umls.css\" ?>~%~%"))
28
29 (defun std-xml-header ()
30   *std-xml-header*)
31
32 ;;; URL Functions
33
34 (defvar *base-url* "")
35 (defun base-url! (url)
36   (setq *base-url* url))
37
38 (defun make-url (page-name &key (base-dir *base-url*) (vars nil))
39   (concatenate 'string base-dir page-name
40                (if vars
41                    (string-trim-last-character
42                     (concatenate 'string "?"
43                                  (mapcar-append-string 
44                                   #'(lambda (var) 
45                                       (when (and (car var) (cadr var))
46                                           (concatenate 'string 
47                                             (car var) "=" (cadr var) "&")))
48                                   vars)))
49                  "")))
50