Removed imports.
[microbotany.git] / plant-new.scm
1 ;; Plant new seed
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           (serve-document-header (ext->mime "gmi"))
11           (print "No account specified.")
12           (print "\n=> /microbotany/ Return to μBotany to create one".))
13         (let ((hash (symbol->string (caar query))))
14           (condition-case
15               (let* ((g (with-input-from-file (make-pathname "accounts" hash) read))
16                      (user (garden-prop 'user g)))
17                 (with-output-to-file (make-pathname "accounts" hash)
18                   (lambda ()
19                     (write (make-garden user))))
20                 (redirect-permanent (update-uri uri
21                                                 path: '(/ "microbotany" "view.scm")
22                                                 query: `((,hash . #t)))))
23             (o (exn)
24                (serve-document-header (ext->mime "gmi"))
25                (print "That account does not exist.")
26                (print "\n=> /microbotany/ Return to μBotany to create one".)))))))
27                     
28