summaryrefslogtreecommitdiff
path: root/z.scm
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-05-12 12:32:57 -0700
committerBen Sima <ben@bsima.me>2020-05-12 12:33:37 -0700
commit0bbb74b7b0d8130cfcb71aedd7971e2906362a08 (patch)
tree17c8a542fa3061f81e21d2ad4540d4f0099780f6 /z.scm
parent22b95c42c5b096a3206f80e38b71aac3565ab6b7 (diff)
for -> turn
Inspired by hoon
Diffstat (limited to 'z.scm')
-rw-r--r--z.scm24
1 files changed, 10 insertions, 14 deletions
diff --git a/z.scm b/z.scm
index e379066..46e6fcf 100644
--- a/z.scm
+++ b/z.scm
@@ -155,7 +155,7 @@
(define (index-node id)
(let ([node (load-node id)])
(dict.set *titles* (title node) id)
- (for (tags node)
+ (turn (tags node)
(/. tag
(if tag
(dict.update
@@ -177,14 +177,6 @@
(define (get-by-title title)
(dict.get *titles* title))
- ;; Printing
-
-(define (print-titles)
- (for (list-nodes)
- (lambda (id)
- (pr id) (pr ": ")
- (prn (title (load-node id))))))
-
;; webserver
(define *css* "body{max-width:650px;margin:40px auto;padding:0 10px;font:18px/1.5 -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";color:#444}h1,h2,h3{line-height:1.2}@media (prefers-color-scheme: dark){body{color:white;background:#444}a:link{color:#5bf}a:visited{color:#ccf}}")
@@ -240,7 +232,7 @@
['()
(respond
`((ul
- ,@(for (list-nodes)
+ ,@(turn (list-nodes)
(lambda (id)
`(li (a (@ (href ,(fmt "/node/~a" id)))
,(fmt "~a: ~a"
@@ -254,14 +246,14 @@
(let ((tags (dict.keys *tags*)))
(reindex)
(respond
- `((ul ,@(for tags
+ `((ul ,@(turn tags
(lambda [tag]
`(li (a (@ (href ,(fmt "/tag/~a" tag)))
,(fmt "~a" tag)))))))))]
[("tag" tag)
(let ([ids (tagged tag)])
(respond
- `((ul ,@(for ids
+ `((ul ,@(turn ids
(lambda [id]
`(li (a (@ (href ,(fmt "/node/~a" id)))
,(fmt "~a: ~a"
@@ -292,11 +284,15 @@ where 'command' is:
[editor (os.getenv "EDITOR")])
(subprocess.call (list editor (path node)))
(exit EXIT_SUCCESS))]
- [("ls") (print-titles)]
+ [("ls")
+ (turn (list-nodes)
+ (lambda (id)
+ (pr id) (pr ": ")
+ (prn (title (load-node id)))))]
[("tagged" tag)
(begin
(reindex)
- (for (tagged tag)
+ (turn (tagged tag)
(lambda (id)
(pr id)
(pr ": ")