+Trace function, +Constants
[lineal.git] / src / webui / save-restore.lisp
blobd950cd5fa6cffe193748f6ccc54768959616528f
2 ;V URL: capture_session
3 ;V Return a file for the user to download V
4 ;V containing all session variables. V
5 (defun capture-session ()
6 (setf (content-type) "application/octet-stream")
7 (with-output-to-string (strm)
8 (save-to-stream strm)))
10 ;V URL: /save_restore
11 ;V The main save and restore page which allows V
12 ;V the user to save and restore session variables.V
13 (defun save-restore-page (&optional (message ""))
14 (with-html-output-to-string
15 (strm nil :prologue t)
16 (:html
17 (:head
18 (:title "Save/Restore Variables"))
19 (:body
20 (:div
21 (:a :href "/input_matrix" "Create and edit")
22 " vectors and matrices" :br
23 (calcupage-link strm) :br
24 (:a :href "/" "Main") " Page")
25 :hr
26 (:div (:a :href "/capture_session" "Get file")
27 " containing current session's variables.")
28 :hr
29 (:div
30 (:form :action "/restore_from_upload"
31 :enctype "multipart/form-data" :method "post"
32 "Add variables from session-restore file: " :br
33 (:input :type "file" :name "restorefile" :size "40") :br
34 (:input :type "submit" :value "Send")))
35 :hr (:pre (princ message strm))))))
37 ;V URL: /restore_from_upload
38 ;V Add variables described in the uploaded file, V
39 ;V overwriting any whose name already exists. V
40 (defun restore-from-upload
41 (&aux (file (car (post-parameter "restorefile"))))
42 (with-open-file (strm file :direction :input)
43 (save-restore-page
44 (restore-from-stream strm))))