22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
;; -------------------------------------------------------------------------
(require pollen/core
pollen/pagetree
pollen/setup
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
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
|
>
>
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
;; -------------------------------------------------------------------------
(require pollen/core
pollen/pagetree
pollen/setup
pollen/file
net/uri-codec
file/sha1
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
maybe-attr ; Return an attribute’s value or a default ("") if not available
here-output-path
here-id
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
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
(define default-authorname "Joel Dueck")
(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 ""])
(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,
|
<
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
(define default-authorname "Joel Dueck")
(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 ""])
(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,
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
[else (or (select-from-metas 'noun-singular series-pnode) "")]))
(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)
|
>
>
>
>
>
>
>
>
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
[else (or (select-from-metas 'noun-singular series-pnode) "")]))
(define (series-title)
(define series-pnode (series-pagenode))
(case series-pnode
['|| ""] ; no series specified
[else (or (select-from-metas 'title series-pnode) "")]))
;; Generates a short ID for the current article
(define (here-id [suffix #f])
(define here-hash
(substring (bytes->hex-string (sha1-bytes (path->bytes (here-output-path)))) 0 8))
(cond [(list? suffix) (apply string-append here-hash suffix)]
[(string? suffix) (string-append here-hash suffix)]
[else here-hash]))
;; “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)
|