Fixed water level rendering bug.
[microbotany.git] / water.scm
1 ;; Water garden
2 ;;
3
4 (lambda (uri)
5   (import (chicken io))
6   (for-each eval (with-input-from-file "garden.scm" read-list))
7   (let ((query (uri-query uri)))
8     (if (null? query)
9         (begin
10           (print "=> register.scm Please register first."))
11         (let ((hash (symbol->string (caar query))))
12           (condition-case
13               (let* ((g (with-input-from-file (make-pathname "accounts" hash) read)))
14                 (water-garden! g)
15                 (with-output-to-file (make-pathname "accounts" hash)
16                   (lambda ()
17                     (write g)))
18                 (redirect-permanent (update-uri uri
19                                                 path: '(/ "microbotany" "view.scm")
20                                                 query: `((,hash . #t)))))
21             (o (exn)
22                (print "This garden no longer exists.\n\n"
23                       "=> register.scm Register to create another.")))))))
24