+Calculator and code looks
[lineal.git] / src / webui / webvars.lisp
bloba37d2b26c25a218f9cef24ff7031650e5e643884
2 ; note: for parenscript, may need to use #'escape-string
3 ; http://www.groupsrv.com/computers/about410678.html
4 (defpackage :lineal.webui
5 (:use :cl :cl-who :hunchentoot :parenscript
6 :lineal.devvars :lineal :lineal.overload)
7 (:export :start-server :with-html))
9 (in-package :lineal.webui)
11 ;V URL: /COPYING
12 ;V Apparently Huncehntoot's handle-static-file and V
13 ;V create-static-file-dispatcher-and-handler don't V
14 ;V handle content-type correctly... so here, V
15 ;V just embed the COPYING file in a web page. V
16 (defun show-license ()
17 (with-html-output-to-string
18 (ostrm nil :prologue t)
19 (:html
20 (:head (:title "COPYING"))
21 (:body
22 (:pre
23 (with-open-file
24 (istrm
25 (make-pathname :name "COPYING")
26 :direction :input)
27 (loop :for line = (read-line istrm nil nil)
28 :while line :do
29 (write-line line ostrm))))))))
31 (setf
32 *dispatch-table*
33 `(; index.lisp
34 ,(create-regex-dispatcher "^/$" 'front-page)
35 ,(create-prefix-dispatcher
36 "/recall_vrbl" 'web-recall-vrbl)
37 ; matrixui.lisp
38 ,(create-prefix-dispatcher
39 "/post_matrix_input" 'get-matrix-input)
40 ,(create-prefix-dispatcher
41 "/matrix_request" 'matrix-request)
42 ,(create-prefix-dispatcher
43 "/input_matrix" 'matrix-input-code)
44 ,(create-prefix-dispatcher
45 "/matrix_select_contents" 'matrix-select-contents)
46 ; calcupage.lisp
47 ,(create-prefix-dispatcher
48 "/calcupage" 'calcupage)
49 ,(create-prefix-dispatcher
50 "/process" 'receive-and-process)
51 ; save-restore.lisp
52 ,@(unless (boundp 'lineal.devvars::no-save-restore)
53 (format t "Save/restore enabled!~%")
54 (list
55 (create-prefix-dispatcher
56 "/save_restore" 'save-restore-page)
57 (create-prefix-dispatcher
58 "/capture_session" 'capture-session)
59 (create-prefix-dispatcher
60 "/restore_from_upload" 'restore-from-upload)))
61 ; reload.lisp
62 ,@(when (boundp 'lineal.devvars::reload-page)
63 (format t "Reload page enabled!~%")
64 (list (create-prefix-dispatcher "/reload" 'reload)))
65 ;V defined in this file V
66 ,(create-prefix-dispatcher "/COPYING" 'show-license)
67 ;V literal content V
68 ,(create-folder-dispatcher-and-handler
69 "/" (make-pathname
70 :directory '(:relative "http_root")))))