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