Index: cache.rkt ================================================================== --- cache.rkt +++ cache.rkt @@ -7,10 +7,12 @@ db/base db/sqlite3 threading pollen/setup racket/match + (rename-in racket/list + (group-by group-list-by)) "dust.rkt" (except-in pollen/core select)) (provide init-cache-db! cache-conn ; The most eligible bachelor in Neo Yokyo @@ -25,11 +27,12 @@ articles+notes listing-htmls - unfence) + unfence + series-grouped-list) ;; Cache DB and Schemas (define DBFILE (build-path (current-project-root) "vitreous.sqlite")) (define cache-conn (sqlite3-connect #:database DBFILE #:mode 'create)) @@ -199,5 +202,12 @@ ;; Remove "" introduced by using ->html on docs containing output from ;; listing functions (define (unfence html-str) (regexp-replace* #px"<[\\/]{0,1}style>" html-str "")) + +;; +;; ~~~ Fetching series ~~~ +;; +(define (series-grouped-list) + (~> (for/list ([row (in-entities cache-conn (from cache:series #:as s))]) row) + (group-list-by cache:series-noun-plural _ string-ci=?))) Index: index.html.pp ================================================================== --- index.html.pp +++ index.html.pp @@ -1,31 +1,12 @@ #lang pollen ◊; SPDX-License-Identifier: BlueOak-1.0.0 ◊; This file is licensed under the Blue Oak Model License 1.0.0. -◊(require pollen/template db/base racket/list racket/match) - -◊(define (fetch-series) - (define q "SELECT noun_plural, page, title FROM series ORDER BY noun_plural DESC") - (query-rows cache-conn q)) - -◊(define (series-item->txpr s) - (match-define (list n pagenode title) s) - `(li (a [[href ,pagenode]] (i ,title)))) - -◊(define (series-grouped-list) - ;; Produces '((("noun1" "p.html" "Title") ("noun1" "q.html" "Title")) (("noun2" ...) ...)) - (define init-group - (group-by first (map vector->list (fetch-series)) string-ci=?)) - - (define series-list-items - (for/list ([group (in-list init-group)]) - `(div (h2 ,(first (first group))) (ul ,@(map series-item->txpr group))))) - `(section [[class "series-list"] [style "margin-top: 1.3rem"]] ,@series-list-items)) - - +◊(require pollen/template racket/file) + ◊html$-page-head["The Local Yarn" #f]