diff --git a/tekuti.el b/tekuti.el index 7140c39..9d4e12c 100644 --- a/tekuti.el +++ b/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))))