Index: cache.rkt ================================================================== --- cache.rkt +++ cache.rkt @@ -21,11 +21,10 @@ (schema-out cache:series) (schema-out cache:index-entry) (schema-out listing) delete-article! delete-notes! - current-plain-title articles articles+notes listing-htmls fenced-listing unfence @@ -35,12 +34,10 @@ ;; Cache DB and Schemas (define DBFILE (build-path (current-project-root) "vitreous.sqlite")) (define cache-conn (make-parameter (sqlite3-connect #:database DBFILE #:mode 'create))) -(define current-plain-title (make-parameter "void")) - (define-schema cache:article #:table "articles" ([id id/f #:primary-key #:auto-increment] [page symbol/f] [title-plain string/f] [title-html-flow string/f] Index: code-docs/cache.scrbl ================================================================== --- code-docs/cache.scrbl +++ code-docs/cache.scrbl @@ -46,25 +46,10 @@ @defproc[(preheat-series!) void?]{ Save info about each series in @racket[series-folder] to the cache. -} - -@defparam[current-plain-title title-plain non-empty-string? #:value "void"]{ - -Contains (or sets) the “plain” title (i.e., with no HTML markup) for the current article based on -analysis done by @racket[parse-and-cache-article!]. If the article did not specify a title, -a default title is supplied. If the article contained a @racket[note] that used the -@code{#:disposition} attribute, the disposition-mark may be included in the title. - -This is a weird parameter, and at some point I will probably get rid of it and have -@racket[parse-and-cache-article!] supply it as an extra return value instead. - -@margin-note{Note that this needs to be called @emph{after} @racket[parse-and-cache-article!] in -order to get an up-to-date value.} - } @section{Retrieving cached data} Some of this looks a little wacky, but it’s a case of putting a little extra complextity into the Index: crystalize.rkt ================================================================== --- crystalize.rkt +++ crystalize.rkt @@ -3,11 +3,10 @@ ; SPDX-License-Identifier: BlueOak-1.0.0 ; This file is licensed under the Blue Oak Model License 1.0.0. (require deta db/base - db/sqlite3 threading racket/match racket/string txexpr pollen/template @@ -17,12 +16,12 @@ (require "dust.rkt" "cache.rkt" "snippets-html.rkt") (provide parse-and-cache-article! cache-series!) -;; Save an article and its notes (if any) to the database, and return the -;; rendered HTML of the complete article. +;; Save an article and its notes (if any) to the database, and return +;; (values plain-title [rendered HTML of the complete article]) (define (parse-and-cache-article! pagenode doc) (define-values (doc-no-title maybe-title) (splitf-txexpr doc (make-tag-predicate 'title))) (define-values (body-txpr note-txprs) (splitf-txexpr doc-no-title (make-tag-predicate 'note))) @@ -45,11 +44,10 @@ (length note-txprs))] [footer (html$-article-close footertext)] [listing-short (html$-article-listing-short pagenode pubdate title-html)] [notes-section-html (cache-notes! pagenode title-plain note-txprs)]) (cache-index-entries! pagenode doc) ; note original doc is used here - (current-plain-title title-plain) (delete-article! pagenode) (insert-one! (cache-conn) (make-cache:article #:page pagenode #:title-plain title-plain @@ -66,11 +64,11 @@ #:disposition disposition #:disp-html-anchor disp-note-id #:listing-full-html (string-append header doc-html footer) #:listing-excerpt-html "" #:listing-short-html listing-short)) - (string-append header doc-html notes-section-html footer))) + (values title-plain (string-append header doc-html notes-section-html footer)))) (define (check-for-poem-title doc-txpr) (match (car (get-elements doc-txpr)) [(txexpr 'div (list (list 'class "poem")) Index: template.html.p ================================================================== --- template.html.p +++ template.html.p @@ -1,15 +1,15 @@ ◊; SPDX-License-Identifier: BlueOak-1.0.0 ◊; This file is licensed under the Blue Oak Model License 1.0.0. -◊(define article-html (parse-and-cache-article! here doc)) -◊html$-page-head[(current-plain-title)] +◊(define-values (plain-title article-html) (parse-and-cache-article! here doc)) +◊html$-page-head[plain-title] ◊html$-page-body-open[] ◊article-html ◊html$-page-body-close[]