@@ -47,11 +47,11 @@ [author string/f] [conceal string/f] [series-page symbol/f] [noun-singular string/f] [note-count integer/f] - [doc-html string/f] + [content-html string/f] [disposition string/f] [disp-html-anchor string/f] [listing-full-html string/f] ; full content but without notes [listing-excerpt-html string/f] ; Not used for now [listing-short-html string/f])) ; Date and title only @@ -88,13 +88,16 @@ [page symbol/f] [html-anchor string/f])) (define-schema listing #:virtual - ([html string/f] - [published date/f] - [series-page symbol/f])) + ([path string/f] + [title string/f] + [author string/f] + [published string/f] + [updated string/f] + [html string/f])) (define (init-cache-db!) (create-table! (cache-conn) 'cache:article) (create-table! (cache-conn) 'cache:note) (create-table! (cache-conn) 'cache:series) @@ -139,37 +142,55 @@ ;; see https://github.com/Bogdanp/deta/issues/14#issuecomment-573344928 (require (prefix-in ast: deta/private/ast)) ;; Builds a query to fetch articles (define (articles type #:series [s #t] #:limit [lim -1] #:order [ord 'desc]) - (define html-field (format "listing_~a_html" type)) + (define html-field + (match type + ['content "content_html"] + [_ (format "listing_~a_html" type)])) (~> (from cache:article #:as a) - (select (fragment (ast:as (ast:qualified "a" html-field) "html")) + (select (as a.page path) + (as a.title-plain title) + a.author a.published - a.series-page - a.conceal) + a.updated + (fragment (ast:as (ast:qualified "a" html-field) "html"))) (where-series s) (where-not-concealed) (limit ,lim) (order-by ([a.published ,ord])) (project-onto listing-schema))) ;; Builds a query that returns articles and notes intermingled chronologically (define (articles+notes type #:series [s #t] #:limit [lim -1] #:order [ord 'desc]) - (define html-field (format "listing_~a_html" type)) + (define html-field + (match type + ['content "content_html"] + [_ (format "listing_~a_html" type)])) (~> (from (subquery (~> (from cache:article #:as A) - (select (fragment (ast:as (ast:qualified "A" html-field) "html")) - A.published - A.series-page - A.conceal) + (select + (as A.page path) + (as A.title-plain title) + A.author + A.published + A.updated + (fragment (ast:as (ast:qualified "A" html-field) "html")) + A.series-page + A.conceal) (union (~> (from cache:note #:as N) - (select (fragment (ast:as (ast:qualified "N" html-field) "html")) - N.published - N.series-page - N.conceal))))) + (select + (as (array-concat N.page "#" N.html-anchor) path) + (as N.title-plain title) + N.author + N.published + (as "" updated) + (fragment (ast:as (ast:qualified "N" html-field) "html")) + N.series-page + N.conceal))))) #:as a) (where-series s) (where-not-concealed) (limit ,lim) (order-by ([a.published ,ord]))