Add macro to ease usage of http parameters
This commit is contained in:
parent
e3ef726cb9
commit
16ad33e32c
1 changed files with 43 additions and 47 deletions
36
eliss.el
36
eliss.el
|
@ -13,6 +13,14 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(defmacro with-eliss-http-params (params httpcon &rest body)
|
||||
"Bind parameters PARAMS from HTTPCON and execute BODY."
|
||||
`(let (,@(mapcar (lambda (p)
|
||||
`(,p (elnode-http-param ,httpcon ,(symbol-name p))))
|
||||
params))
|
||||
,@body))
|
||||
(put 'with-eliss-http-params 'lisp-indent-function 2)
|
||||
|
||||
(defvar eliss-data-directory "~/projects/eliss/projects")
|
||||
|
||||
(defun project-row (project)
|
||||
|
@ -205,15 +213,9 @@ certain other properties.
|
|||
(POST
|
||||
(let* ((project (match-string 1 (elnode-http-mapping httpcon)))
|
||||
(filename (concat eliss-data-directory "/" project ".org"))
|
||||
(buffer (find-file-noselect filename))
|
||||
(subject (elnode-http-param httpcon "subject"))
|
||||
(tags (elnode-http-param httpcon "tags"))
|
||||
(i-m-human (elnode-http-param httpcon "i-m-human"))
|
||||
(i-r-bot (elnode-http-param httpcon "i-r-bot"))
|
||||
(content (elnode-http-param httpcon "content"))
|
||||
(category (elnode-http-param httpcon "category"))
|
||||
(name (elnode-http-param httpcon "name"))
|
||||
(email (elnode-http-param httpcon "email")))
|
||||
(buffer (find-file-noselect filename)))
|
||||
(with-eliss-http-params (subject tags i-m-human i-r-bot content
|
||||
category name email) httpcon
|
||||
(when (and (equal i-m-human "t") (equal i-r-bot ""))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-min))
|
||||
|
@ -229,7 +231,7 @@ certain other properties.
|
|||
(org-set-property "ID" (org-id-new project))
|
||||
(org-set-property "AuthorName" name)
|
||||
(org-set-property "AuthorEmail" email)
|
||||
(save-buffer)))
|
||||
(save-buffer))))
|
||||
(elnode-send-redirect httpcon (concat "/" project "/"))))))
|
||||
|
||||
(defun eliss-new-comment (httpcon)
|
||||
|
@ -240,15 +242,9 @@ certain other properties.
|
|||
(issue (match-string 2 (elnode-http-mapping httpcon)))
|
||||
(entry (cdr (org-id-find issue)))
|
||||
(filename (concat eliss-data-directory "/" project ".org"))
|
||||
(buffer (find-file-noselect filename))
|
||||
(subject (elnode-http-param httpcon "subject"))
|
||||
(name (elnode-http-param httpcon "name"))
|
||||
(email (elnode-http-param httpcon "email"))
|
||||
(i-m-human (elnode-http-param httpcon "i-m-human"))
|
||||
(i-r-bot (elnode-http-param httpcon "i-r-bot"))
|
||||
(content (elnode-http-param httpcon "content"))
|
||||
(name (elnode-http-param httpcon "name"))
|
||||
(email (elnode-http-param httpcon "email")))
|
||||
(buffer (find-file-noselect filename)))
|
||||
(with-eliss-http-params (subject name email i-m-human i-r-bot
|
||||
content) httpcon
|
||||
(when (and (equal i-m-human "t") (equal i-r-bot ""))
|
||||
(with-current-buffer buffer
|
||||
(goto-char entry)
|
||||
|
@ -261,7 +257,7 @@ certain other properties.
|
|||
(fill-region text-start (point)))
|
||||
(org-set-property "AuthorName" name)
|
||||
(org-set-property "AuthorEmail" email)
|
||||
(save-buffer)))
|
||||
(save-buffer))))
|
||||
(elnode-send-redirect httpcon (concat "/" project "/" issue "/"))))))
|
||||
|
||||
(defun eliss-handler (httpcon)
|
||||
|
|
Loading…
Reference in a new issue