Index: cache.rkt ================================================================== --- cache.rkt +++ cache.rkt @@ -18,19 +18,18 @@ cache-conn ; The most eligible bachelor in Neo Yokyo (schema-out cache:article) (schema-out cache:note) (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 preheat-series! series-grouped-list) ;; Cache DB and Schemas @@ -184,23 +183,12 @@ (for/list ([l (in-entities (cache-conn) list-query)]) (listing-html l))) ;; Return cached HTML of articles and/or notes, fenced within a style txexpr to prevent it being ;; escaped by ->html. See also: definition of `unfence` - -;; E.g.: ( articles+notes) -(define ( query-func #:series [s #t] #:limit [lim -1] #:order [ord 'desc]) - `(style ,@(listing-htmls (query-func 'full #:series s #:limit lim #:order ord)))) -;; ^^^^^ - -(define ( query-func #:series [s #t] #:limit [lim -1] #:order [ord 'desc]) - `(style ,@(listing-htmls (query-func 'excerpt #:series s #:limit lim #:order ord)))) -;; ^^^^^^^^ - -(define ( query-func #:series [s #t] #:limit [lim -1] #:order [ord 'desc]) - `(style ,@(listing-htmls (query-func 'short #:series s #:limit lim #:order ord)))) -;; ^^^^^^ +(define (fenced-listing q) + `(style ,@(listing-htmls q))) ;; Remove "" introduced by using ->html on docs containing output from ;; listing functions (define (unfence html-str) (regexp-replace* #px"<[\\/]{0,1}style>" html-str "")) Index: code-docs/cache.scrbl ================================================================== --- code-docs/cache.scrbl +++ code-docs/cache.scrbl @@ -41,10 +41,16 @@ 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. + +} @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, @@ -71,53 +77,20 @@ ◊title{My New Series} ...some other content -◊( articles+notes #:order 'asc) +◊fenced-listing[(articles+notes 'excerpt #:order 'asc)] }| ] -@deftogether[(@defproc[( - [query-func (-> any/c query?)] - [#:series series (or/c string? (listof string?) boolean?) #t] - [#:limit limit integer? -1] - [order stringish? 'desc]) txexpr?] - @defproc[( - [query-func (-> any/c query?)] - [#:series series (or/c string? (listof string?) boolean?) #t] - [#:limit limit integer? -1] - [order stringish? 'desc]) txexpr?] - @defproc[( - [query-func (-> any/c query?)] - [#:series series (or/c string? (listof string?) boolean?) #t] - [#:limit limit integer? -1] - [order stringish? 'desc]) txexpr?])]{ - -Fetches the HTML for items from the SQLite cache, concatenates their HTML strings and returns -a @racket['style] tagged X-expression with this string as its element. The items will be ordered by -publish date according to @racket[_order] and optionally limited to the series specified in -@racket[_series]. - -The @racket[_query-func] should be either @racket[articles], which will create a listing of articles -only, or @racket[articles+notes], which will include notes intermingled with articles. - -@margin-note{Note that the signature shown for the @racket[_query-func] argument above is -incomplete. If you choose to pass a function other than @racket[articles] or -@racket[articles+notes], you must use a function with exactly the same signature as those -functions.} - -If @racket[_series] expression evaluates to @racket[#f], articles will not be filtered by series. If -it evaluates to @racket[#t] (the default), articles will be filtered by those that specify the -current output of @racket[here-output-path] in their @tt{series_pagenode} column in the SQLite -cache. If a string is supplied, articles will be filtered by those containing that exact value in -their @tt{series_pagenode} column in the SQLite cache. - -The @racket[_order] expression must evaluate to either @racket["ASC"] or @racket["DESC"] and the -@racket[_limit] expressions must evaluate to a value suitable for use in the @tt{LIMIT} clause of -@ext-link["https://sqlite.org/lang_select.html"]{a SQLite @tt{SELECT} statement}. An expression that -evaluates to a negative integer (the default) is the same as having no limit. +@defproc[(fenced-listing [query query?]) txexpr?]{ + +Fetches a the HTML strings from the SQLite cache and returns a @racket['style] tagged X-expression +with these strings as its elements. The @racket[_query] will usually be the result of a call to +@racket[articles] or @racket[articles+notes], but can be any custom query that projects onto the +@racket[listing] schema (see @racket[project-onto]). The reason for enclosing the results in a @racket['style] txexpr is to prevent the HTML from being escaped by @racket[->html] in the template. This tag was picked for the job because there will generally never be a need to include any actual CSS information inside a @tt{"] removed. 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[] tag function or its siblings. +@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 so -that series using the same value in the @tt{noun-plural} column appear together. +that series using the same value in the @tt{noun_plural} column appear together. } @section{Deleting records} Index: code-docs/pollen.scrbl ================================================================== --- code-docs/pollen.scrbl +++ code-docs/pollen.scrbl @@ -79,13 +79,14 @@ @defproc[(block [element xexpr?] ...) txexpr?]{ A container for content that should appear grouped together on larger displays. Intended for use in Series pages, where the template is very minimal to allow for more customization. You would want -output from @racket[] to appear inside a @racket[block], but you would want output -from @racket[] to appear outside it (since each article effectively supplies its own -block). Only relevant to HTML output. +output from @racket[(fenced-listing (articles 'short))] to appear inside a @racket[block], but when +using @racket['excerpt] or @racket['full] in place of @racket['short] in that code, you would want +the output to appear outside it (since the “full” and “excerpt” versions of each article effectively +supply their own blocks). Only relevant to HTML output. } @deftogether[(@defproc[(link [link-id stringish?] [link-text xexpr?]) txexpr?] @defproc[(url [link-id stringish?] [url string?]) void?])]{