render posts to html
This commit is contained in:
parent
6aed082015
commit
06515afc50
4
NOTES.md
4
NOTES.md
|
@ -50,6 +50,10 @@ inotify will be used to detect completion of a queued request
|
||||||
if a remote request fails after a reasonable retry interval, it may be aborted and the cache may
|
if a remote request fails after a reasonable retry interval, it may be aborted and the cache may
|
||||||
be filled in with dummy data indicating the resource could not be fetched
|
be filled in with dummy data indicating the resource could not be fetched
|
||||||
|
|
||||||
|
/cache/posts/ stores intermediate HTML-rendered posts generated from markdown. this avoids needing
|
||||||
|
to recompile posts from markdown multiple times because that's super unnecessary. it also contains
|
||||||
|
front matter with the post metadata and parsed hashtags
|
||||||
|
|
||||||
## Task queue
|
## Task queue
|
||||||
|
|
||||||
stores queued outgoing requests
|
stores queued outgoing requests
|
||||||
|
|
|
@ -136,9 +136,35 @@
|
||||||
'href instance-url))))
|
'href instance-url))))
|
||||||
(write-json webfinger out))))
|
(write-json webfinger out))))
|
||||||
|
|
||||||
|
(define (generate-post-render-rules)
|
||||||
|
(define (make-post-cache-rule post-src post-dst)
|
||||||
|
(rule `("src/instance.rktd" ,post-src) post-dst
|
||||||
|
(lambda (in out)
|
||||||
|
(define prefs (prefs-load (hash-ref in "src/instance.rktd")))
|
||||||
|
(define instance-url (prefs-get prefs 'instance-url))
|
||||||
|
(define post-content (port->string (hash-ref in post-src)))
|
||||||
|
(define hashtags (mutable-set))
|
||||||
|
(define post-htmls (map (lambda (b)
|
||||||
|
(process-hashtags! b instance-url hashtags))
|
||||||
|
(parse-markdown post-content)))
|
||||||
|
(write `((is-meow #t)
|
||||||
|
(hashtags ,(set->list hashtags))) out)
|
||||||
|
(for ([item (in-list post-htmls)])
|
||||||
|
(write-string (xexpr->string item) out)))))
|
||||||
|
|
||||||
|
(for/fold ([posts (set)]) ([post-name (in-list (directory-list "src/posts"))]
|
||||||
|
#:when (regexp-match? #px"\\.md$" post-name))
|
||||||
|
(define post-src (build-path "src/posts" post-name))
|
||||||
|
(define cache-dst (build-path "cache/posts"
|
||||||
|
(path-replace-extension (last (explode-path post-src)) ".html")))
|
||||||
|
(set-add posts (make-post-cache-rule post-src cache-dst))))
|
||||||
|
|
||||||
|
|
||||||
(define compiler-rules
|
(define compiler-rules
|
||||||
(set compile-index-json
|
(set-union
|
||||||
compile-webfinger))
|
(generate-post-render-rules)
|
||||||
|
(set compile-index-json
|
||||||
|
compile-webfinger)))
|
||||||
|
|
||||||
(define ops (generate-operations compiler-rules))
|
(define ops (generate-operations compiler-rules))
|
||||||
(for ([op (in-list ops)])
|
(for ([op (in-list ops)])
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
; cache dirs
|
; cache dirs
|
||||||
(make-directory "cache")
|
(make-directory "cache")
|
||||||
(make-directory "cache/actors")
|
(make-directory "cache/actors")
|
||||||
|
(make-directory "cache/posts")
|
||||||
|
|
||||||
; db dirs
|
; db dirs
|
||||||
(make-directory "db")
|
(make-directory "db")
|
||||||
|
|
Loading…
Reference in New Issue