Fix setting up comments

This commit is contained in:
Tom Willemse 2023-12-07 23:27:21 -08:00
parent 087165a993
commit 4350856f99

View file

@ -32,7 +32,7 @@
;; #+TITLE: SOME TITLE ;; #+TITLE: SOME TITLE
;; #+DATE: <2021-06-03 Thu 22:45> ;; #+DATE: <2021-06-03 Thu 22:45>
;; #+TAGS: comma,separated ;; #+TAGS: comma,separated
;; #+COMMENT_STATUS: open ;; #+COMMENTS: on
;; #+COMMENTS_DATE: ;; #+COMMENTS_DATE:
;; #+STATUS: publish ;; #+STATUS: publish
@ -71,6 +71,11 @@ with a /.")
pair pair
(error "Unknown post status: %s; Accepted values are: %s" (error "Unknown post status: %s; Accepted values are: %s"
status accepted-values)))) status accepted-values))))
(`("COMMENTS" ,status)
(if (string= status "on")
pair
(error "Unknown value for comments: %s; Can only be on or not present."
status)))
(_ pair))) (_ pair)))
(defun tekuti-build-data-from-org () (defun tekuti-build-data-from-org ()
@ -79,22 +84,25 @@ with a /.")
("DATE" ,(tekuti--format-date)) ("DATE" ,(tekuti--format-date))
("TAGS") ("TAGS")
("STATUS") ("STATUS")
("COMMENT_STATUS") ("COMMENTS")
("COMMENTS-CLOSED-DATE") ("COMMENTS-CLOSED-DATE")
("BODY"))) ("BODY")))
(data (append (data (append
(mapcar (mapcar
#'tekuti--parse-data-keyword #'tekuti--parse-data-keyword
(org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENT_STATUS" "DATE" "COMMENTS_DATE"))) (org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENTS" "DATE" "COMMENTS_DATE")))
(list (list
(list "BODY" (list "BODY"
(with-current-buffer (org-html-export-as-html nil nil nil t) (with-current-buffer (org-html-export-as-html nil nil nil t)
(buffer-substring-no-properties (point-min) (point-max)))))))) (buffer-substring-no-properties (point-min) (point-max))))))))
(mapcar (lambda (item) (seq-remove
(let ((key (car item))) (lambda (pair) (and (string= "COMMENTS" (car pair))
`(,key ,@(or (alist-get key data nil nil #'string=) (null (cdr pair))))
(cdr item))))) (mapcar (lambda (item)
defaults))) (let ((key (car item)))
`(,key ,@(or (alist-get key data nil nil #'string=)
(cdr item)))))
defaults))))
(defun tekuti-form-encode-pair (key value) (defun tekuti-form-encode-pair (key value)
(concat (url-hexify-string key) "=" (url-hexify-string value))) (concat (url-hexify-string key) "=" (url-hexify-string value)))
@ -114,7 +122,7 @@ with a /.")
(goto-char (point-min)) (goto-char (point-min))
(search-forward "\n\n") (search-forward "\n\n")
(backward-char) (backward-char)
(let ((data (org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENT_STATUS" "DATE" "COMMENTS_DATE")))) (let ((data (org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENTS" "DATE" "COMMENTS_DATE"))))
(mapc (lambda (item) (mapc (lambda (item)
(let ((key (car item)) (let ((key (car item))
(value (cadr item))) (value (cadr item)))