Overview
Comment: | Support article listings from cached HTML. Resolves [f580d194] |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e493f1c6d4aa9f296b1dad4cc2a11a16 |
User & Date: | joel on 2019-04-07 20:58:31 |
Other Links: | manifest | tags |
References
2019-04-07
| ||
21:14 | • Closed ticket [f580d194]: Need for “listings” functions to support series surfaces architectural problem plus 4 other changes artifact: eeb97d83 user: joel | |
Context
2019-04-07
| ||
21:11 | Simplify a couple of HTML conversions check-in: e54b3c52 user: joel tags: trunk | |
20:58 | Support article listings from cached HTML. Resolves [f580d194] check-in: e493f1c6 user: joel tags: trunk | |
2019-04-04
| ||
15:49 | Add lang to html tag in template check-in: 6f93d21a user: joel tags: trunk | |
Changes
Modified code-docs/crystalize.scrbl from [c3a0a528] to [c9cfb91f].
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | “Crystalizing” is an extra layer in between docs and templates that destructures the doc and stores it in various pieces in a SQLite cache. Individual articles save chunks of rendered HTML to the cache when their individual pages are rendered. The SQLite cache is then referenced by any page that collects multiple articles and notes together. This is much faster than fetching docs and metas through Pollen’s cache and re-converting them to HTML. |
Modified code-docs/dust.scrbl from [3dab2a11] to [1d7645f5].
︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | + + + + + + | @defproc[(series-pagetree) pagetree?])] These are project-wide pagetrees: @racket[articles-pagetree] contains a pagenode for every Pollen document contained in @racket[articles-path], and @racket[series-pagetree] contains a pagenode for every Pollen document in @racket[series-path]. The pagenodes themselves point to the rendered @tt{.html} targets of the source documents. @defproc[(here-output-path) path?] Returns the path to the current output file, relative to @racket[current-project-root]. If no metas are available, raises an error. This is like what you can get from the @tt{here} variable that Pollen provides, except it is available outside templates. @section{Metas and @code{txexpr}s} @defproc[(maybe-attr [key symbol?] [attrs txexpr-attrs?] [missing-expr any/c ""]) any/c] Find the value of @racket[_key] in the supplied list of attributes, returning the value of @racket[_missing-expr] if it’s not there. |
︙ |
Modified code-docs/snippets-html.scrbl from [d3b4b700] to [da39e280].
︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | + | "../dust.rkt" "../snippets-html.rkt" racket/base racket/contract racket/string pollen/template pollen/pagetree txexpr sugar/coerce)) @title{@filepath{snippets-html.rkt}} @defmodule["snippets-html.rkt" #:packages ()] Each “snippet” module provides all the document- and article-level blocks of structural markup |
︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | + + + + + + | The @racket[_title-specified-in-doc?] form changes the HTML markup structure used. @defproc[(html$-article-close [footertext string?]) non-empty-string?] Returns a string containing a closing @tt{<section>} tag, a @tt{<footer>} element containing @racket[_footertext], and a closing @tt{<article>} tag. If @racket[_footertext] is empty, the @tt{<footer>} element will be omitted. @defproc[(html$-article-listing-short [web-path string?] [pubdate string?] [title string?]) non-empty-string?] Returns a string of HTML for an article as it would appear in a listing context in “short” form (date and title only). @defproc[(html$-page-body-close) non-empty-string?] Returns a string containing the page’s @tt{<footer>} and closing tags. @defproc[(html$-note-title [author string?] [pagenode pagenode?] [parent-title string?]) non-empty-string?] |
︙ |
Modified crystalize.rkt from [87ac52b6] to [5177f4d3].
︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + + + + + | ;; since the database is merely a disposable cache, and since all the input ;; will be coming from me. (require pollen/setup pollen/core pollen/template racket/string racket/function txexpr db/base "sqlite-tools.rkt" "snippets-html.rkt" "dust.rkt") ;; ~~~ Provides ~~~ (provide spell-of-summoning! crystalize-article! article-plain-title list-short/articles list-full/articles list-full/articles+notes unfence preheat-series!) ;; ~~~ Private use ~~~ (define DBFILE (build-path (current-project-root) "vitreous.sqlite")) ;; Since the DB exists to serve as a high-speed cache, the tables are constructed so that |
︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | + | note_id title_html_flow author author_url date disposition content_html series_pagenode listing_full_html listing_excerpt_html ; Not used for now listing_short_html)) (define table_series-fields '(pagenode title |
︙ | |||
120 121 122 123 124 125 126 | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | - + | (notes->last-disposition-values note-txprs)) (let* ([pubdate (select-from-metas 'published (current-metas))] [doc-html (->html (cdr body-txpr))] [title-specified? (not (equal? '() maybe-title))] [title-val (if (not (null? maybe-title)) (car maybe-title) maybe-title)] [title-tx (make-article-title title-val body-txpr disposition disp-note-id)] |
︙ | |||
146 147 148 149 150 151 152 | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | (maybe-meta 'noun (series-noun)) (length note-txprs) doc-html disposition disp-note-id (string-append header doc-html footer) "" ; listing_excerpt_html: Not yet used |
︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | + | note-id title-html-flow author author-url note-date disposition-attr content-html (symbol->string (series-pagenode)) listing-full-html "" ; listing_excerpt_html: Not used for now "")) ; listing_short_html: Not used for now ;; save to db (define save-note-query (format (string-append "INSERT OR REPLACE INTO `notes` (`rowid`, ~a) " |
︙ |
Modified dust.rkt from [23ec4654] to [86d18cd5].
︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | + + | ;; joel@jdueck.net ;; https://joeldueck.com ;; ------------------------------------------------------------------------- (require pollen/core pollen/pagetree pollen/setup pollen/file net/uri-codec gregor txexpr racket/list 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 series-noun ; Retrieve noun-singular from current 'series meta, or "" series-title ; Retrieve title of series in current 'series meta, or "" series-pagenode make-tag-predicate tx-strs ymd->english ymd->dateformat |
︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | + + + + + + + + + + + | (define articles-path "articles") (define (default-title body-txprs) (format "“~a…”" (first-words body-txprs 5))) (define (maybe-meta m [missing ""]) (or (select-from-metas m (current-metas)) missing)) ;; Return the current output path, relative to (current-project-root) ;; Similar to the variable 'here' which is only accessible in Pollen templates, ;; except this is an actual path, not a string. (define (here-output-path) (cond [(current-metas) (define-values (_ rel-path-parts) (drop-common-prefix (explode-path (current-project-root)) (explode-path (string->path (select-from-metas 'here-path (current-metas)))))) (->output-path (apply build-path rel-path-parts))] [else (error "No metas are available")])) ;; Checks current-metas for a 'series meta and returns the pagenode of that series, ;; or '|| if no series is specified. (define (series-pagenode) (define maybe-series (or (select-from-metas 'series (current-metas)) "")) (cond [(non-empty-string? maybe-series) |
︙ |
Modified pollen.rkt from [4cf3382b] to [f565258c].
︙ | |||
38 39 40 41 42 43 44 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | - + + + + | (provide (all-defined-out) (all-from-out "crystalize.rkt" "snippets-html.rkt")) (module setup racket/base (require syntax/modresolve pollen/setup) (provide (all-defined-out)) (define poly-targets '(html)) |
︙ |
Added series/template.html.p version [a5d01b90].
|
Modified snippets-html.rkt from [7d073437] to [404c13df].
︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | + | openssl/sha1 "dust.rkt") (provide html$-page-head html$-page-body-open html$-article-open html$-article-close html$-article-listing-short html$-page-body-close html$-note-title html$-note-contents html$-note-listing-full html$-note-in-article html$-notes-section) |
︙ | |||
74 75 76 77 78 79 80 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | - + + + + + + + + | (define (html$-article-close footertext) (cond [(non-empty-string? footertext) ◊string-append{</section> <footer class="article-info"><span class="x">(</span>◊|footertext|<span class="x">)</span></footer> </article>}] [else "</section></article>"])) |
︙ |
Modified template.html.p from [e3f9080d] to [51a5e67e].
1 2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | - | <!DOCTYPE html> <html lang="en"> |