Local Yarn Code

"Check-in [624e5e2b]"
Overview
Comment:Fix series caching
Timelines: family | ancestors | descendants | both | deta-refactor
Files: files | file ages | folders
SHA3-256: 624e5e2b7eb85a38c3aef3debb5fe6644796b2afaf03db8ce38801ae82fbf283
User & Date: joel on 2020-01-13 00:52:40
Other Links: branch diff | manifest | tags
Context
2020-01-13
01:04
Fix cache db filename, index page Leaf check-in: e90a714a user: joel tags: deta-refactor
00:52
Fix series caching check-in: 624e5e2b user: joel tags: deta-refactor
00:37
Fix article+note listing query so date ordering actually works check-in: fc820f2f user: joel tags: deta-refactor
Changes

Modified crystalize.rkt from [e20fefa6] to [950c4fe1].

13
14
15
16
17
18
19

20
21
22
23
24
25
26
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
389
390
391
392
393
394
395

396
397
398

399
400
401

402
403
404
405
         pollen/setup)

(require "dust.rkt" "snippets-html.rkt")

(provide init-cache-db!
         cache-conn            ; The most eligible bachelor in Neo Yokyo
         parse-and-cache-article!

         current-plain-title
         (schema-out cache:article)
         (schema-out cache:note)
         (schema-out cache:series)
         (schema-out cache:index-entry)
         articles
         articles+notes
................................................................................
   [listing-excerpt-html string/f]   ; Not used for now
   [listing-short-html   string/f])) ; Date and title only

(define-schema cache:series #:table "series"
  ([id            id/f #:primary-key #:auto-increment]
   [page          symbol/f]
   [title         string/f]
   [published     date/f]
   [noun-plural   string/f]
   [noun-singular string/f]))

(define-schema cache:index-entry #:table "index_entries"
  ([id          id/f #:primary-key #:auto-increment]
   [entry       string/f]
   [subentry    string/f]
................................................................................
;; listing functions
(define (unfence html-str)
  (regexp-replace* #px"<[\\/]{0,1}style>" html-str ""))

;; Save the current article to the `series` table of the SQLite cache
;; Should be called from a template for series pages
(define (cache-series!)

  (query-exec cache-conn
              (delete (~> (from cache:series #:as s)
                          (where (= s.page ,(here-output-path))))))

  (insert-one! cache-conn
               (make-cache:series
                #:page (here-output-path)

                #:title (hash-ref (current-metas) 'title)
                #:published (hash-ref (current-metas) 'published "")
                #:noun-plural (hash-ref (current-metas) 'noun-plural "")
                #:noun-singular (hash-ref (current-metas) 'noun-singular ""))))







>







 







|







 







>


|
>
|
|
<
>
|
|
|
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403

404
405
406
407
408
         pollen/setup)

(require "dust.rkt" "snippets-html.rkt")

(provide init-cache-db!
         cache-conn            ; The most eligible bachelor in Neo Yokyo
         parse-and-cache-article!
         cache-series!
         current-plain-title
         (schema-out cache:article)
         (schema-out cache:note)
         (schema-out cache:series)
         (schema-out cache:index-entry)
         articles
         articles+notes
................................................................................
   [listing-excerpt-html string/f]   ; Not used for now
   [listing-short-html   string/f])) ; Date and title only

(define-schema cache:series #:table "series"
  ([id            id/f #:primary-key #:auto-increment]
   [page          symbol/f]
   [title         string/f]
   [published     string/f]
   [noun-plural   string/f]
   [noun-singular string/f]))

(define-schema cache:index-entry #:table "index_entries"
  ([id          id/f #:primary-key #:auto-increment]
   [entry       string/f]
   [subentry    string/f]
................................................................................
;; listing functions
(define (unfence html-str)
  (regexp-replace* #px"<[\\/]{0,1}style>" html-str ""))

;; Save the current article to the `series` table of the SQLite cache
;; Should be called from a template for series pages
(define (cache-series!)
  (define here-page (path->string (here-output-path)))
  (query-exec cache-conn
              (delete (~> (from cache:series #:as s)
                          (where (= s.page ,here-page)))))
  (void
   (insert-one! cache-conn
                (make-cache:series

                 #:page (string->symbol here-page)
                 #:title (hash-ref (current-metas) 'title)
                 #:published (hash-ref (current-metas) 'published "")
                 #:noun-plural (hash-ref (current-metas) 'noun-plural "")
                 #:noun-singular (hash-ref (current-metas) 'noun-singular "")))))