summaryrefslogtreecommitdiff
path: root/z.scm
diff options
context:
space:
mode:
Diffstat (limited to 'z.scm')
-rw-r--r--z.scm43
1 files changed, 21 insertions, 22 deletions
diff --git a/z.scm b/z.scm
index dd091c6..8d86472 100644
--- a/z.scm
+++ b/z.scm
@@ -98,7 +98,7 @@
(created #:getter created
#:init-form (date->string (current-date) "~Y.~m.~d..~H.~M"))
(tags #:accessor tags #:init-keyword #:tags)
- (content #:accessor content #:init-keyword #:content)
+ (content #:accessor get-content #:init-keyword #:content)
(path #:getter path
#:allocation #:virtual
#:slot-set! (lambda (_) #f)
@@ -114,7 +114,7 @@
(format file "created: ~a\n" (created node))
(format file "tags: ~{~a ~}" (tags node))
(display "---\n" file)
- (format file "~a" (content node)))))
+ (format file "~a" (get-content node)))))
(define-generic render-li)
(define-generic render-full)
@@ -243,39 +243,38 @@ NL < '\n'
(respond
`((ul
,@(turn (list-nodes)
- (lambda (id)
- `(li (a (@ (href ,(fmt "/node/~a" id)))
- ,(fmt "~a: ~a"
- (id->string id)
- (title (load-node id))))))))))]
+ (lambda (id)
+ `(li (a (@ (href ,(fmt "/node/~a" (id->string id))))
+ ,(fmt "~a: ~a"
+ (id->string id)
+ (title (load-node id))))))))))]
[("node" id)
(let* ([node (load-node (string->id id))]
- [txt (or (content node) "")])
+ [txt (or (get-content node) "")])
(respond `((pre ,txt))
#:title (fmt "z - ~a" (title node))))]
[("tag")
- (let ((tags (dict.keys *tags*)))
+ (begin
(reindex)
(respond
- `((ul ,@(turn tags
- (lambda [tag]
- `(li (a (@ (href ,(fmt "/tag/~a" tag)))
- ,(fmt "~a" tag)))))))))]
+ `((ul ,@(turn (dict.keys *tags*)
+ (lambda [tag]
+ `(li (a (@ (href ,(fmt "/tag/~a" tag)))
+ ,(fmt "~a" tag)))))))))]
[("tag" tag)
- (let ([ids (tagged tag)])
- (respond
- `((ul ,@(turn ids
- (lambda [id]
- `(li (a (@ (href ,(fmt "/node/~a" id)))
- ,(fmt "~a: ~a"
- (id->string id)
- (title (load-node id)))))))))))]
+ (respond
+ `((ul ,@(turn (tagged tag)
+ (lambda [id]
+ `(li (a (@ (href ,(fmt "/node/~a" id)))
+ ,(fmt "~a: ~a"
+ (id->string id)
+ (title (load-node id))))))))))]
[_ (respond "not found")]))
(define* (serve #:key (port 8080))
(prn "z")
(prn (fmt "port ~a" port))
- (http.run-server routes 'http `(#:port ,port)))
+ (http.run-server routes 'http `(#:port ,port #:host "0.0.0.0")))
;; CLI