@@ -34,36 +34,42 @@ (provide maybe-meta ; Select from (current-metas) or default value ("") if not available maybe-attr ; Return an attribute’s value or a default ("") if not available series-noun ; Retrieve noun-singular from current 'series meta, or "" series-title ; Retrieve title of series in current 'series meta, or "" attr-present? ; Test if an attribute is present - disposition-values + tx-strs ymd->english ymd->dateformat default-authorname - series-path/ default-title - tx-strs + articles-path + series-path + articles-pagetree + series-pagetree first-words build-note-id notes->last-disposition-values + disposition-values ) (define default-authorname "Joel Dueck") -(define series-path/ "series/") +(define series-path "series") +(define articles-path "articles") (define (default-title date) (format "Entry of ~a" (ymd->dateformat date "d MMM YYYY"))) (define (maybe-meta m [missing ""]) (or (select-from-metas m (current-metas)) missing)) +;; Checks current-metas for a 'series meta and returns the pagenode of that series, +;; or '|| if no series is specified. (define (series-pagenode) (define maybe-series (or (select-from-metas 'series (current-metas)) "")) (cond [(non-empty-string? maybe-series) - (->pagenode (string-append series-path/ maybe-series ".html"))] + (->pagenode (string-append series-path "/" maybe-series ".html"))] [else '||])) (define (series-noun) (define series-pnode (series-pagenode)) (case series-pnode @@ -74,10 +80,29 @@ (define series-pnode (series-pagenode)) (case series-pnode ['|| ""] ; no series specified [else (or (select-from-metas 'title series-pnode) "")])) +;; ~~~ Project-wide Pagetrees ~~~ + +(define (include-in-pagetree folder extension) + (define (matching-file? f) + (string-suffix? f extension)) + (define (file->output-pagenode f) + (string->symbol (format "~a/~a" folder (string-replace f extension ".html")))) + + (define file-strs (map path->string (directory-list folder))) + (map file->output-pagenode (filter matching-file? file-strs))) + +(define articles-pagetree + `(root ,@(include-in-pagetree articles-path ".poly.pm"))) + +(define series-pagetree + `(root ,@(include-in-pagetree series-path ".poly.pm"))) + +;; ~~~ Convenience functions for tagged x-expressions ~~~ + (define (attr-present? name attrs) (for/or ([attr-pair (in-list attrs)]) (equal? name (car attr-pair)))) (define (maybe-attr name attrs [missing ""])