Index: crystalize.rkt ================================================================== --- crystalize.rkt +++ crystalize.rkt @@ -1,6 +1,6 @@ -#lang pollen/mode racket/base +#lang racket/base ;; Copyright (c) 2018 Joel Dueck. ;; ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. @@ -42,11 +42,12 @@ ;; ~~~ Provides ~~~ (provide spell-of-summoning! crystalize-article! - article-plain-title) + article-plain-title + preheat-series!) ;; ~~~ Private use ~~~ (define DBFILE (build-path (current-project-root) "vitreous.sqlite")) @@ -152,11 +153,11 @@ "" ; listing_excerpt_html: Not yet used "")) ; listing_short_html: Not yet used (apply query! (make-insert/replace-query 'articles table_articles-fields) article-record) - ◊string-append{◊header ◊doc-html ◊notes-section-html ◊footer}) + (string-append header doc-html notes-section-html footer)) ;; ~~~ Article-related helper functions ~~~ ;; ;; Return both a plain-text and HTML version of a title for the current article, @@ -281,5 +282,24 @@ ;; return html$ of note (html$-note-in-article note-id note-date content-html author author-url)) (define (article-plain-title pagenode) (query-value (sqltools:dbc) "SELECT `title_plain` FROM `articles` WHERE `pagenode` = ?1" (symbol->string pagenode))) + +;; ~~~ Series ~~~ + +;; Preloads the SQLite cache with info about each series. +;; I may not actually need this but I’m leaving it for now. +(define (preheat-series!) + (query! "DELETE FROM `series`") + (define series-values + (for/list ([series-pagenode (in-list (cdr (series-pagetree)))]) + (define series-metas (get-metas series-pagenode)) + (list (symbol->string series-pagenode) + (hash-ref series-metas 'title) + (hash-ref series-metas 'published) + (hash-ref series-metas 'noun-plural "") + (hash-ref series-metas 'noun-singular "")))) + (define sql$-insert (make-insert-rows-query 'series table_series-fields series-values)) + (displayln sql$-insert) + (query! sql$-insert)) +