Store and use the update path for a post once it's been created
This way I can keep sending the post to update it in place.
This commit is contained in:
parent
91488f1358
commit
6016689a74
1 changed files with 16 additions and 2 deletions
18
tekuti.el
18
tekuti.el
|
@ -109,11 +109,23 @@
|
|||
(null (alist-get key data nil nil #'string=))
|
||||
(not (null value)))
|
||||
(insert "#+" key ": " value "\n"))))
|
||||
args))))
|
||||
args))
|
||||
(unless (tekuti--get-update-url)
|
||||
(insert "#+UPDATE_URL: "
|
||||
(string-replace "/posts/"
|
||||
"/modify-post/"
|
||||
(car (url-path-and-query
|
||||
(url-generic-parse-url url))))
|
||||
"\n"))))
|
||||
(message "Created new post: %s" url))
|
||||
(`(:error (error http ,code) . ,_)
|
||||
(message "Failed to create post: %d" code))))
|
||||
|
||||
(defun tekuti--get-update-url ()
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(car (map-elt (org-collect-keywords '("UPDATE_URL")) "UPDATE_URL"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun tekuti-send ()
|
||||
(interactive)
|
||||
|
@ -122,7 +134,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)
|
||||
(url-retrieve (format "%s%s" tekuti-host
|
||||
(or (tekuti--get-update-url)
|
||||
"/admin/modify-post"))
|
||||
#'tekuti--send-finished
|
||||
(list (current-buffer) data))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue