◊(Local Yarn Code "Check-in [47d9eea5]")

Overview
Comment:Get rid of current-plain-title ([1909139d])
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 47d9eea54df98d334ed689a93ac347ee720f0cdc3d32b833cb85f5479cfa84c3
User & Date: joel on 2020-02-20 04:53:49
Other Links: manifest | tags
References
2020-02-20
08:30
Update code docs to reflect [47d9eea54] check-in: b223c8a5 user: joel tags: trunk
Context
2020-02-20
08:30
Update code docs to reflect [47d9eea54] check-in: b223c8a5 user: joel tags: trunk
04:53
Get rid of current-plain-title ([1909139d]) check-in: 47d9eea5 user: joel tags: trunk
04:41
Update code docs for cache to reflect [37240160] check-in: c18bd9b3 user: joel tags: trunk
Changes

Modified cache.rkt from [727011c9] to [fa204a09].

19
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
46
47
48
19
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







-













-
-







         (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

(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]
   [title-specified?     boolean/f]
   [published            string/f]

Modified code-docs/cache.scrbl from [c47b8041] to [bc3bc40e].

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
44
45
46
47
48
49
50















51
52
53
54
55
56
57







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-








}

@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
back end to make things simple on the front end. These functions are most commonly used inside the
@emph{body} of a Pollen document (i.e., series pages). 

Modified crystalize.rkt from [271e4525] to [783ca339].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


24
25
26
27
28
29
30
1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16
17
18
19
20


21
22
23
24
25
26
27
28
29







-













-
-
+
+







#lang racket/base

; 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
         (except-in pollen/core select) ; avoid conflict with deta
         )

(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)))
  (define-values (disposition disp-note-id)
    (notes->last-disposition-values note-txprs))
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
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







-




















-
+







                                               disposition
                                               disp-note-id
                                               (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
                  #:title-html-flow title-html
                  #:title-specified? title-specified?
                  #:published pubdate
                  #:updated (maybe-meta 'updated)
                  #:author (maybe-meta 'author default-authorname)
                  #:conceal (maybe-meta 'conceal)
                  #:series-page series-node
                  #:noun-singular (maybe-meta 'noun (series-metas-noun))
                  #:note-count (length note-txprs)
                  #:doc-html doc-html
                  #: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"))
             (list* (txexpr 'p
                            (list (list 'class "verse-heading"))

Modified template.html.p from [f2509ece] to [e923bd95].

1
2
3
4
5
6


7
8
9
10
11
12
13
14
15
1
2
3
4


5
6
7
8
9
10
11
12
13
14
15




-
-
+
+









<!DOCTYPE html>
◊; SPDX-License-Identifier: BlueOak-1.0.0
◊; This file is licensed under the Blue Oak Model License 1.0.0.
<html lang="en">
◊(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[]

</html>