Added garden directory.
authorTim Vaughan <plugd@thelambdalab.xyz>
Fri, 29 May 2020 16:07:06 +0000 (18:07 +0200)
committerTim Vaughan <plugd@thelambdalab.xyz>
Fri, 29 May 2020 16:07:06 +0000 (18:07 +0200)
directory.gmi [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 56a8259..9c84035
@@ -1,5 +1,36 @@
-# Garden directory
+# Garden Directory
 
-The μBotany garden directory isn't yet implemented.
+```
+,(eval (begin
+         (import (chicken io)
+                 (chicken file)
+                 (chicken string)
+                 (chicken pathname)
+                 (chicken time posix)
+                 srfi-1 srfi-13)
+         (for-each eval (with-input-from-file "garden.scm" read-list))
+         (define (pad-string o max-len)
+           (let* ((s (->string o))
+                  (n (string-length s)))
+             (if (> n max-len)
+                 (string-take s max-len)
+                 (conc s (make-string (- max-len n) #\space)))))
+         (define (print-rule n)
+           (print (make-string n #\-)))
+         (let* ((headers '("Owner" "Created" "Plant Stage"))
+                (colwidths '(20 30 15))
+                (total-width (apply + colwidths)))
+           (apply print (map pad-string headers colwidths))
+           (print-rule total-width)
+           (for-each
+            (lambda (garden-file)
+              (let* ((g (with-input-from-file garden-file read))
+                     (fields (list (garden-prop 'user g)
+                                   (seconds->string (garden-prop 'created g))
+                                   (garden-stage g))))
+                (apply print (map pad-string fields colwidths)))) 
+            (glob "accounts/*"))
+           (print-rule total-width))))
+```
 
-=> ./ Return to start page
\ No newline at end of file
+=> ./ Return to the μBotany start page