@@ -27,10 +27,11 @@ pollen/file net/uri-codec gregor txexpr racket/list + racket/system racket/string) ;; Provides common helper functions used throughout the project (provide maybe-meta ; Select from (current-metas) or default value ("") if not available @@ -37,10 +38,11 @@ maybe-attr ; Return an attribute’s value or a default ("") if not available here-output-path series-noun ; Retrieve noun-singular from current 'series meta, or "" series-title ; Retrieve title of series in current 'series meta, or "" series-pagenode + invalidate-series make-tag-predicate tx-strs ymd->english ymd->dateformat default-authorname @@ -59,13 +61,15 @@ (define series-folder "series") (define articles-folder "articles") (define (default-title body-txprs) (format "“~a…”" (first-words body-txprs 5))) + (define (maybe-meta m [missing ""]) - (or (select-from-metas m (current-metas)) missing)) + (cond [(current-metas) (or (select-from-metas m (current-metas)) missing)] + [else missing])) ;; Return the current output path, relative to (current-project-root) ;; Similar to the variable 'here' which is only accessible in Pollen templates, ;; except this is an actual path, not a string. (define (here-output-path) @@ -94,10 +98,23 @@ (define (series-title) (define series-pnode (series-pagenode)) (case series-pnode ['|| ""] ; no series specified [else (or (select-from-metas 'title series-pnode) "")])) + +;; “Touches” the last-modified date on the current article’s series, if there is one + +(define (invalidate-series) + (define series-name (maybe-meta 'series #f)) + (when series-name + (define series-file (build-path (current-project-root) + series-folder + (format "~a.poly.pm" series-name))) + (when (file-exists? series-file) + (case (system-type 'os) + ['windows (system (format "type nul >> ~a" series-file))] + [else (system (format "touch ~a" series-file))])))) ;; ~~~ Project-wide Pagetrees ~~~ (define (include-in-pagetree folder extension) (define (matching-file? f)