diff options
-rw-r--r-- | Alpha/Core.scm | 2 | ||||
-rw-r--r-- | z.scm | 39 |
2 files changed, 24 insertions, 17 deletions
diff --git a/Alpha/Core.scm b/Alpha/Core.scm index 4ce0bbb..076ad28 100644 --- a/Alpha/Core.scm +++ b/Alpha/Core.scm @@ -6,7 +6,7 @@ #:export (fmt printf pr prn rest last butlast true? false? some? empty? -> ->> fn /. curry comp - repeat for seq + repeat for seq turn inc dec member? contains? comment get-source* get-source source)) @@ -53,7 +53,7 @@ ;; base 36. (define (id->string id) - (number->string id 36)) + (fmt "~36,3'0r" id)) (define (string->id s) (string->number s 36)) @@ -140,17 +140,17 @@ NL < '\n' [_ '()]))) (define (parse-content node-tree) - (-> tree second second)) + (-> node-tree second second)) (define (load-node id) (let* ([node-tree (->> id id->path readlines (match-pattern node) peg:tree)] [meta (parse-meta node-tree)]) (make <node> #:id id - #:title (assoc "title" meta) - #:created (assoc "created" meta) + #:title (assoc-ref meta "title") + #:created (assoc-ref meta "created") #:tags (->> meta - (filter (/. P (equal? car P "tag"))) + (filter (/. P (equal? (car P) "tag"))) (map cdr)) #:content (parse-content node-tree)))) @@ -246,7 +246,8 @@ NL < '\n' (lambda (id) `(li (a (@ (href ,(fmt "/node/~a" id))) ,(fmt "~a: ~a" - id (title (load-node id))))))))))] + (id->string id) + (title (load-node id))))))))))] [("node" id) (let* ([node (load-node (string->id id))] [txt (or (content node) "")]) @@ -266,8 +267,8 @@ NL < '\n' `((ul ,@(turn ids (lambda [id] `(li (a (@ (href ,(fmt "/node/~a" id))) - ,(fmt "~a: ~a" - id + ,(fmt "~a: ~a" + (id->string id) (title (load-node id)))))))))))] [_ (respond "not found")])) @@ -300,21 +301,27 @@ where 'command' is: (exit EXIT_SUCCESS))] [("ls") (turn (list-nodes) - (lambda (id) - (pr id) (pr ": ") - (prn (title (load-node id)))))] + (lambda (id) + (format #t "~a: ~a\n" + (id->string id) + (title (load-node id)))))] [("tagged" tag) (begin (reindex) (turn (tagged tag) - (lambda (id) - (pr id) - (pr ": ") - (pr (title (load-node id))))))] + (lambda (id) + (format #t "~a: ~a\n" + (id->string id) + (title (load-node id))))))] [("tags") (begin (reindex) - (map prn (dict.keys *tags*)))] + (turn (dict.keys *tags*) + (lambda (tag) + (format #t + "(~a) ~a\n" + (count (const #t) (dict.get *tags* tag)) + tag))))] [("web") (serve)] [("web" port) (serve #:port (string->number port))] [_ (usage)])) |