@@ -68,10 +68,11 @@ [author-url string/f] [published string/f] [disposition string/f] [content-html string/f] [series-page symbol/f] + [conceal string/f] [listing-full-html string/f] [listing-excerpt-html string/f] ; Not used for now [listing-short-html string/f])) ; Date and title only (define-schema cache:series #:table "series" @@ -269,10 +270,11 @@ #:published note-date #:author author #:author-url author-url #:disposition disposition-attr #:series-page (metas-series-pagenode) + #:conceal (or (maybe-attr 'conceal attrs #f) (maybe-meta 'conceal)) #:content-html content-html #:listing-full-html (html$-note-listing-full pagenode note-id title-html note-date @@ -341,10 +343,17 @@ (where q (= a.series-page ,(s->p series)))] ; WHERE series-page = "item" [#t (where q (= a.series-page ,(path->string (here-output-path))))] [_ q])) +;; (Private use) Convenience for the WHERE `conceal` NOT LIKE clause +(define (where-not-concealed q) + (define base-clause (where q (not (like a.conceal "%all%")))) + (match (listing-context) + ["" base-clause] + [(var context) (where base-clause (not (like a.conceal ,(format "%~a%" context))))])) + ;; Needed to "parameterize" column names ;; see https://github.com/Bogdanp/deta/issues/14#issuecomment-573344928 (require (prefix-in ast: deta/private/ast)) ;; Builds a query to fetch articles @@ -351,12 +360,14 @@ (define (articles type #:series [s #t] #:limit [lim -1] #:order [ord 'desc]) (define html-field (format "listing_~a_html" type)) (~> (from cache:article #:as a) (select (fragment (ast:as (ast:qualified "a" html-field) "html")) a.published - a.series-page) + a.series-page + a.conceal) (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 @@ -364,18 +375,21 @@ (define html-field (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.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.series-page + N.conceal))))) #:as a) (where-series s) + (where-not-concealed) (limit ,lim) (order-by ([a.published ,ord])) (project-onto listing-schema))) ;; Get all the a list of the HTML all the results in a query