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