Added garden directory.
[microbotany.git] / directory.gmi
1 # Garden Directory
2
3 ```
4 ,(eval (begin
5          (import (chicken io)
6                  (chicken file)
7                  (chicken string)
8                  (chicken pathname)
9                  (chicken time posix)
10                  srfi-1 srfi-13)
11          (for-each eval (with-input-from-file "garden.scm" read-list))
12          (define (pad-string o max-len)
13            (let* ((s (->string o))
14                   (n (string-length s)))
15              (if (> n max-len)
16                  (string-take s max-len)
17                  (conc s (make-string (- max-len n) #\space)))))
18          (define (print-rule n)
19            (print (make-string n #\-)))
20          (let* ((headers '("Owner" "Created" "Plant Stage"))
21                 (colwidths '(20 30 15))
22                 (total-width (apply + colwidths)))
23            (apply print (map pad-string headers colwidths))
24            (print-rule total-width)
25            (for-each
26             (lambda (garden-file)
27               (let* ((g (with-input-from-file garden-file read))
28                      (fields (list (garden-prop 'user g)
29                                    (seconds->string (garden-prop 'created g))
30                                    (garden-stage g))))
31                 (apply print (map pad-string fields colwidths)))) 
32             (glob "accounts/*"))
33            (print-rule total-width))))
34 ```
35
36 => ./ Return to the μBotany start page