19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
+
|
;; Author contact information:
;; joel@jdueck.net
;; https://joeldueck.com
;; -------------------------------------------------------------------------
(require pollen/core
pollen/pagetree
pollen/setup
net/uri-codec
gregor
txexpr
racket/list
racket/string)
;; Provides common helper functions used throughout the project
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
|
;; 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 (format "~a/~a.html" series-path maybe-series))]
[else '||]))
(define (series-noun)
(define series-pnode (series-pagenode))
(case series-pnode
['|| ""] ; no series specified
[else (or (select-from-metas 'noun-singular series-pnode) "")]))
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
-
+
+
-
+
-
+
|
;; ~~~ 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)))
(define folder-path (build-path (current-project-root) folder))
(define file-strs (map path->string (directory-list folder-path)))
(map file->output-pagenode (filter matching-file? file-strs)))
(define articles-pagetree
(define (articles-pagetree)
`(root ,@(include-in-pagetree articles-path ".poly.pm")))
(define series-pagetree
(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))))
|