Creates and initializes the SQLite database cache file (named @filepath{vitreous.sqlite} and located
in the project root folder) by running queries to create tables in the database if they do not
exist.
}
@defproc[(preheat-series!) void?]{Save info about each series in @racket[series-folder] to the cache.}@section{Retrieving cached data}
Some of this looks a little wacky, but it’s a case of putting a little extra complextity into the
back end to make things simple on the front end. These functions are most commonly used inside the
@emph{body} of a Pollen document (i.e., series pages).
@filebox["series/my-series.poly.pm"
The contents of the style tags are left intact.
Use this in templates with strings returned from @racket[->html] when called on docs that use the
@racket[fenced-listing] tag function.
}
@defproc[(series-grouped-list) (listof (listof cache:series?))]{Return a list of lists of all @racket[cache:series] in the cache database. The series are grouped sothat series using the same value in the @tt{noun_plural} column appear together.}@section{Deleting records}
@deftogether[(@defproc[(delete-article! [page stringish?]) void?]
@defproc[(delete-notes! [page stringish?]) void?])]{
Delete a particular article, or all notes for a particular article, respectively.
and saved to the SQLite cache and saved using @racket[make-cache:article]. If the article specifies
a @racket['series] meta, information about that series is fetched and used in the rendering of the
article. If there are @racket[note]s or @racket[index] tags in the doc, they are parsed and saved
individually to the SQLite cache (using @racket[make-cache:note] and
@racket[make-cache:index-entry]). If any of the notes use the @code{#:disposition} attribute,
information about the disposition is parsed out and used in the rendering of the article.
}
@defproc[(cache-series!) void?]{Attempts to look up certain values in @racket[current-metas] which we expect to be defined ona typical series page, and saves them to the cache using @racket[make-cache:series]. If @tt{title}is not defined in the current metas, you’ll get an error. If any of the others are missing, an emptystring is used.}
#lang scribble/manual
@; SPDX-License-Identifier: BlueOak-1.0.0
@; This file is licensed under the Blue Oak Model License 1.0.0.
@(require "scribble-helpers.rkt"
scribble/example)
@(require (for-label "../pollen.rkt"
"../dust.rkt"
"../cache.rkt"
"../series-list.rkt"
racket/base
racket/contract
txexpr
sugar/coerce
pollen/tag
pollen/setup
pollen/pagetree
(define doc
'(root (p "If I had been astonished at first catching a glimpse of so outlandish an "
"individual as Queequeg circulating among the polite society of a civilized "
"town, that astonishment soon departed upon taking my first daylight "
"stroll through the streets of New Bedford…")))
(default-title (get-elements doc))]
@defproc[(metas-series-pagenode) pagenode?]
@defproc[(current-series-pagenode) pagenode?]
If @code{(current-metas)} has the key @racket['series], converts its value to the pagenode pointing to
that series, otherwise returns @racket['||].
@examples[#:eval dust-eval
(require pollen/core)
(parameterize ([current-metas (hash 'series "marquee-fiction")])
(current-series-pagenode))]
@defproc[(series-metas-noun) string?]
@defproc[(current-series-noun) string?]
If @code{(current-metas)} has the key @racket['series], and if the corresponding series defines a metavalue for @racket['noun-singular], then return it, otherwise return @racket[""].
If @code{(current-metas)} has the key @racket['series] and if there is a corresponding
@racket[series] in the @racket[series-list], return its @racket[series-noun-singular] value;
otherwise return @racket[""].
@defproc[(series-metas-title) string?]
@defproc[(current-series-title) string?]
If @code{(current-metas)} has the key @racket['series], and if the corresponding series defines a metavalue for @racket['title], then return it, otherwise return @racket[""].
If @code{(current-metas)} has the key @racket['series] and if there is a corresponding
@racket[series] in the @racket[series-list], return its @racket[series-title] value;
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|.
cached metas of every article looking for matching articles.
@local-table-of-contents[]
@include-section["tour.scrbl"]
@include-section["design.scrbl"]
@include-section["pollen.scrbl"] @; pollen.rkt
@include-section["series.scrbl"]
@include-section["dust.scrbl"] @; dust.rkt
@include-section["snippets-html.scrbl"] @; you get the idea
@include-section["cache.scrbl"]
@include-section["crystalize.scrbl"]
@include-section["other-files.scrbl"]
#lang scribble/manual
@; SPDX-License-Identifier: BlueOak-1.0.0
@; This file is licensed under the Blue Oak Model License 1.0.0.
@(require "scribble-helpers.rkt"
scribble/example)
@(require (for-label "../pollen.rkt"
"../series-list.rkt"
"../dust.rkt"
"../cache.rkt"
pollen/core
racket/base
racket/contract))
@title{Defining Series}
To create a new series:
@itemlist[#:style 'ordered
@item{Create a file @filepath{my-key.poly.pm} inside @racket[series-folder] and include a call
to @racket[fenced-listing] to list all the articles and notes that will be included in the series:
@codeblock|{
#lang pollen
◊(define-meta title "My New Series")
◊block{Here’s what we call a bunch of similar articles:
◊(fenced-listing (articles 'short))
}
}|
}
@item{Add an entry for @racket[_my-key] to @racket[series-list] in @filepath{series-list.rkt}}
@item{Use @racket[(define-meta series "my-key")] in articles to add them to the series.}
@item{If @racket[series-ptree-ordered?] is @racket[#t], create a @seclink["Pagetree" #:doc '(lib
"pollen/scribblings/pollen.scrbl")]{pagetree} file in @racket[series-folder] named
@filepath{my-key.ptree}.}
]
@section{Series list}
@defmodule["series-list.rkt" #:packages ()]
This module contains the most commonly used bits of meta-info about @tech{series}. Storing these
bits in a hash table of structs makes them faster to retrieve than when they are stored inside the
metas of the Pollen documents for the series themselves.
@defthing[series-list hash?]{
An immutable hash containing all the title and noun info for each @tech{series}. Each key is
a string and each value is a @racket[series] struct.
}
@defstruct[series ([key string?]
[title string?]
[noun-plural string?]
[noun-singular string?]
[ptree-ordered? boolean?])]{
Struct for holding metadata for a @tech{series}. The @racket[_ptree-ordered?] value should be
@racket[#t] if there is a @filepath{@italic{key}.ptree} file in @racket[series-folder] that provides
information on how articles in the series are ordered.
}
[else ""]))
;; Returns a txexpr, the tag will be discarded by the template/snippets
`(title ,@title-elems ,disposition-part))
;; Convert a bunch of information about an article into some nice English and links.
(define (make-article-footertext pagenode series disposition disp-note-id note-count)
(define series-part
(match (series-metas-title)
(match (current-series-title)
[(? non-empty-string? s-title)
(format "<span class=\"series-part\">This is ~a, part of <a href=\"/~a\">‘~a’</a>.</span>"
(series-metas-noun)
(current-series-noun)
series
s-title)]
[_ ""]))
(define disp-part
(cond [(non-empty-string? disposition)
(define-values (mark verb) (disposition-values disposition))
(format "Now considered <a href=\"/~a#~a\">~a</a>."
#lang racket/base
; SPDX-License-Identifier: BlueOak-1.0.0
; This file is licensed under the Blue Oak Model License 1.0.0.
(require pollen/core
"series-list.rkt"
pollen/pagetree
pollen/setup
pollen/file
net/uri-codec
threading
file/sha1
gregor
txexpr
racket/list
racket/match
racket/port
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-source-path
here-id
listing-context
series-metas-noun ; Retrieve noun-singular from current 'series meta, or ""
series-metas-title ; Retrieve title of series in current 'series meta, or ""metas-series-pagenode
current-series-noun ; Retrieve noun-singular from current 'series meta, or #f
current-series-title ; Retrieve title of series in current 'series meta, or #f
current-series-pagenode
invalidate-series
checked-in?
make-tag-predicate
tx-strs
ymd->english
ymd->dateformat
default-authorname
(define block-tags (append '(title style dt note) default-block-tags))
(define-runtime-path tags-html.rkt "tags-html.rkt")
(define-runtime-path snippets-html.rkt "snippets-html.rkt")
(define-runtime-path dust.rkt "dust.rkt")
(define-runtime-path crystalize.rkt "crystalize.rkt")
(define-runtime-path cache.rkt "cache.rkt")
(define-runtime-path series-list.rkt "series-list.rkt")
(define cache-watchlist
(map resolve-module-path
(list tags-html.rkt
snippets-html.rkt
dust.rkt
cache.rkt
series-list.rkt
crystalize.rkt))))
;; Macro for defining tag functions that automatically branch based on the
;; current output format and the list of poly-targets in the setup module.
;; Use this macro when you know you will need keyword arguments.
;;
(define-syntax (poly-branch-kwargs-tag stx)
#lang racket/base
; SPDX-License-Identifier: BlueOak-1.0.0
; This file is licensed under the Blue Oak Model License 1.0.0.
;; Provides fast metadata for series.
;; TO MAKE A NEW SERIES:
;; 1. Create series/my-key.poly.pm
;; 2. Add an entry for my-key to series-list below
;; 3. Use ◊define-meta[series "my-key"] in articles to add them to the series.
;; 4. If ptree-ordered is #t, also create series/my-key.ptree
(require racket/list)
(struct series (key title noun-plural noun-singular ptree-ordered?))
(define series-list
(make-immutable-hash
(list
;; ------- DEFINE SERIES HERE -----------
; Key Title plural noun singular noun phrase
(+series "marquee-fiction" "Marquee Fiction" "inventions" "an invention" #f)
)))
(define (series-grouped-list)
(group-by series-noun-plural (hash-values series-list)))
;; Quick macro to save a little typing
(define-syntax-rule (+series key title plural singular ptree)
(cons key (series key title plural singular ptree)))
(provide (struct-out series)
series-list
series-grouped-list)