35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
@section{Constants}
@defthing[default-authorname string? #:value "Joel Dueck"]
Used as the default author name for @code{note}s, and (possibly in the future) for articles
generally.
@deftogether[(@defthing[articles-path path-string? #:value "articles"]
@defthing[series-path path-string? #:value "series"])]
The path of the folder that contains the Pollen source documents for Articles and Series
respectively, relative to the project’s document root.
@deftogether[(@defproc[(articles-pagetree) pagetree?]
@defproc[(series-pagetree) pagetree?])]
These are project-wide pagetrees: @racket[articles-pagetree] contains a pagenode for every Pollen
document contained in @racket[articles-path], and @racket[series-pagetree] contains a pagenode for
every Pollen document in @racket[series-path]. The pagenodes themselves point to the rendered
@tt{.html} targets of the source documents.
@section{Metas and @code{txexpr}s}
@defproc[(attr-present? [name symbol?] [attrs (listof pair?)]) boolean?]
Shortsightedly redundant to @code{attrs-have-key?}. Returns @code{#t} if @racket[_name] is one of
the attributes present in @racket[_attrs], otherwise returns @code{#f}.
@defproc[(maybe-attr [key symbol?] [attrs txexpr-attrs?] [missing-expr any/c ""]) any/c]
Find the value of @racket[_key] in the supplied list of attributes, returning the value of
@racket[_missing-expr] if it’s not there.
I had to write this because @racket[attr-ref] wants a whole tagged X-expression (not just the
|
|
|
|
|
|
>
|
>
>
>
|
>
>
>
|
>
>
>
>
>
|
>
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
@section{Constants}
@defthing[default-authorname string? #:value "Joel Dueck"]
Used as the default author name for @code{note}s, and (possibly in the future) for articles
generally.
@deftogether[(@defthing[articles-folder path-string? #:value "articles"]
@defthing[series-folder path-string? #:value "series"])]
The names of the folders that contain the Pollen source documents for Articles and Series
respectively, relative to the project’s document root.
@deftogether[(@defproc[(articles-pagetree) pagetree?]
@defproc[(series-pagetree) pagetree?])]
These are project-wide pagetrees: @racket[articles-pagetree] contains a pagenode for every Pollen
document contained in @racket[articles-folder], and @racket[series-pagetree] contains a pagenode for
every Pollen document in @racket[series-folder]. The pagenodes themselves point to the rendered
@tt{.html} targets of the source documents.
@defproc[(here-output-path) path?]
Returns the path to the current output file, relative to @racket[current-project-root]. If no metas
are available, raises an error. This is like what you can get from the @tt{here} variable that Pollen
provides, except it is available outside templates.
@defproc[(here-id [suffix (or/c (listof string?) string? #f) #f]) string?]
Returns the 8-character prefix of the SHA1 hash of the current document’s output path. If no metas
are available, raises an error. If @racket[_suffix] evaluates to a string or a list of strings, they
are appended verbatim to the end of the hash.
This ID is used when creating URL fragment links within an article, such as for footnotes and index
entries. As long as the web version of the article is not moved to a new URL, the ID will remain the
same, which ensures deep links using the ID don’t break. The ID also ensures each article’s internal
links will be unique, so that links do not collide when multiple articles are being shown on
a single HTML page.
@section{Metas and @code{txexpr}s}
@defproc[(maybe-attr [key symbol?] [attrs txexpr-attrs?] [missing-expr any/c ""]) any/c]
Find the value of @racket[_key] in the supplied list of attributes, returning the value of
@racket[_missing-expr] if it’s not there.
I had to write this because @racket[attr-ref] wants a whole tagged X-expression (not just the
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
If @code{(current-metas)} has the key @racket['series], and if the corresponding series defines a meta
value for @racket['noun-singular], then return it, otherwise return @racket[""].
@defproc[(series-title) string?]
If @code{(current-metas)} has the key @racket['series], and if the corresponding series defines a meta
value for @racket['title], then return it, otherwise return @racket[""].
@defproc[(disposition-values [str string?]) any]
Given a string @racket[_str], returns two values: the portion of the string coming before the first
space, and the rest of the string.
@examples[#:eval dust-eval
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
If @code{(current-metas)} has the key @racket['series], and if the corresponding series defines a meta
value for @racket['noun-singular], then return it, otherwise return @racket[""].
@defproc[(series-title) string?]
If @code{(current-metas)} has the key @racket['series], and if the corresponding series defines a meta
value for @racket['title], then return it, otherwise return @racket[""].
@defproc[(invalidate-series) (or/c void? boolean?)]
If the current article specifies a @racket['series] meta, and if a corresponding @filepath{.poly.pm}
file exists in @racket[series-folder], attempts to “touch” the last-modified timestamp on that file,
returning @racket[#t] on success or @racket[#f] on failure. If either precondition is not true,
returns @|void-const|.
When an article is being rendered, that means the article has changed, and if the article has
changed, its series page (if any) should be updated as well. Touching the @filepath{.poly.pm} file
for a series page triggers a re-render of that page when running @tt{make web} to rebuild the web
content (see @repo-file{makefile}).
Only used in one place, @repo-file{tags-html.rkt}.
@defproc[(disposition-values [str string?]) any]
Given a string @racket[_str], returns two values: the portion of the string coming before the first
space, and the rest of the string.
@examples[#:eval dust-eval
|