Update metadata in org file after sending
This commit is contained in:
parent
7ce1d86c05
commit
bc5af18647
1 changed files with 23 additions and 3 deletions
26
tekuti.el
26
tekuti.el
|
@ -93,8 +93,26 @@
|
|||
data
|
||||
"&"))
|
||||
|
||||
(defun tekuti--send-finished (status &rest _)
|
||||
(message "Finished: %s" status))
|
||||
(defun tekuti--send-finished (status buffer args)
|
||||
(pcase-exhaustive status
|
||||
(`(:redirect ,url)
|
||||
(save-excursion
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-min))
|
||||
(search-forward "\n\n")
|
||||
(backward-char)
|
||||
(let ((data (org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENTS" "DATE" "COMMENTS_DATE"))))
|
||||
(mapc (lambda (item)
|
||||
(let ((key (car item))
|
||||
(value (cadr item)))
|
||||
(when (and (not (string= key "BODY"))
|
||||
(null (alist-get key data nil nil #'string=))
|
||||
(not (null value)))
|
||||
(insert "#+" key ": " value "\n"))))
|
||||
args))))
|
||||
(message "Created new post: %s" url))
|
||||
(`(:error (error http ,code))
|
||||
(message "Failed to create post: %d" code))))
|
||||
|
||||
;;;###autoload
|
||||
(defun tekuti-send ()
|
||||
|
@ -104,7 +122,9 @@
|
|||
(url-request-extra-headers
|
||||
`(("Content-Type" . "application/x-www-form-urlencoded")))
|
||||
(url-request-data (tekuti-form-encode-data data)))
|
||||
(url-retrieve (format "%s/admin/new-post" tekuti-host) #'tekuti--send-finished)))
|
||||
(url-retrieve (format "%s/admin/new-post" tekuti-host)
|
||||
#'tekuti--send-finished
|
||||
(list (current-buffer) data))))
|
||||
|
||||
(provide 'tekuti)
|
||||
;;; tekuti.el ends here
|
||||
|
|
Loading…
Reference in a new issue