Add comments to issues
This commit is contained in:
parent
506c9713e9
commit
81d569edc2
1 changed files with 68 additions and 11 deletions
79
eliss.el
79
eliss.el
|
@ -103,14 +103,16 @@
|
|||
(issue (match-string 2 (elnode-http-mapping httpcon)))
|
||||
(filename (concat eliss-data-directory "/" project ".org"))
|
||||
(buffer (find-file-noselect filename))
|
||||
(entry (cdr (org-id-find issue))))
|
||||
(entry (cdr (org-id-find issue)))
|
||||
title)
|
||||
(elnode-http-start httpcon 200 '("Content-Type" . "text/html"))
|
||||
(with-current-buffer buffer
|
||||
(goto-char entry)
|
||||
(set 'title (nth 4 (org-heading-components)))
|
||||
(elnode-http-return
|
||||
httpcon (eliss-page
|
||||
project
|
||||
`(h1 ,(nth 4 (org-heading-components)))
|
||||
`(h1 ,title)
|
||||
`(div (@ (class "row"))
|
||||
(div (@ (class "span6"))
|
||||
(dl (@ (class "dl-horizontal"))
|
||||
|
@ -125,14 +127,41 @@
|
|||
`(pre ,(buffer-substring-no-properties
|
||||
(org-end-of-meta-data-and-drawers)
|
||||
(org-entry-end-position)))
|
||||
`(div ,@(progn
|
||||
(org-goto-first-child)
|
||||
(org-map-entries (lambda ()
|
||||
`(div (h2 ,(nth 4 (org-heading-components)))
|
||||
(pre ,(buffer-substring-no-properties
|
||||
(org-end-of-meta-data-and-drawers)
|
||||
(org-entry-end-position)))))
|
||||
nil 'tree))))))))
|
||||
`(div ,@(org-map-entries (lambda ()
|
||||
`(div (h2 ,(nth 4 (org-heading-components)))
|
||||
(pre ,(buffer-substring-no-properties
|
||||
(org-end-of-meta-data-and-drawers)
|
||||
(org-entry-end-position)))))
|
||||
"/+COMMENT" 'tree))
|
||||
`(form (@ (action ,(concat "/" project "/" issue
|
||||
"/comment/"))
|
||||
(method "POST")
|
||||
(class "form-horizontal"))
|
||||
(fieldset
|
||||
(legend "New comment")
|
||||
(div (@ (class "row"))
|
||||
(div (@ (class "span5"))
|
||||
,(eliss-control-group
|
||||
"subject" "Subject" nil
|
||||
(concat "RE: " title))
|
||||
,(eliss-control-group "name" "Name"
|
||||
"John Doe")
|
||||
,(eliss-control-group
|
||||
"email" "Email" "john@example.com")
|
||||
(input (@ (type "hidden")
|
||||
(name "i-m-human")
|
||||
(value "t")))
|
||||
(input (@ (type "hidden")
|
||||
(name "i-r-bot")))
|
||||
(input (@ (type "submit")
|
||||
(value "Comment")
|
||||
(class "pull-right"))))
|
||||
(div (@ (class "span7"))
|
||||
(label (@ (for "content")) "Comment:")
|
||||
(textarea (@ (name "content")
|
||||
(id "content")
|
||||
(class "span7")
|
||||
(rows "15")) ""))))))))))
|
||||
|
||||
(defun eliss-new-issue (httpcon)
|
||||
(elnode-method httpcon
|
||||
|
@ -162,12 +191,40 @@
|
|||
(save-buffer)))
|
||||
(elnode-send-redirect httpcon (concat "/" project "/"))))))
|
||||
|
||||
(defun eliss-new-comment (httpcon)
|
||||
(elnode-method httpcon
|
||||
(POST
|
||||
(let* ((project (match-string 1 (elnode-http-mapping httpcon)))
|
||||
(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")))
|
||||
(when (and (equal i-m-human "t") (equal i-r-bot ""))
|
||||
(with-current-buffer buffer
|
||||
(goto-char entry)
|
||||
(org-end-of-subtree)
|
||||
(org-insert-heading-after-current)
|
||||
(insert subject)
|
||||
(org-set-property "TODO" "COMMENT")
|
||||
(let ((text-start (point)))
|
||||
(insert "\n\n" content)
|
||||
(fill-region text-start (point)))
|
||||
(save-buffer)))
|
||||
(elnode-send-redirect httpcon (concat "/" project "/" issue "/"))))))
|
||||
|
||||
(defun eliss-handler (httpcon)
|
||||
(elnode-dispatcher
|
||||
httpcon
|
||||
'(("^/$" . eliss-project-list)
|
||||
("^/\\([-a-zA-Z0-9]+\\)/$" . eliss-project-page)
|
||||
("^/\\([-a-zA-Z0-9]+\\)/new/$" . eliss-new-issue)
|
||||
("^/\\([-a-zA-Z0-9]+\\)/\\([-a-z0-9:]+\\)/$" . eliss-issue-page)
|
||||
("^/\\([-a-zA-Z0-9]+\\)/new/$" . eliss-new-issue))))
|
||||
("^/\\([-a-zA-Z0-9]+\\)/\\([-a-z0-9:]+\\)/comment/$" . eliss-new-comment))))
|
||||
|
||||
(elnode-start 'eliss-handler :port 8028 :host "localhost")
|
||||
|
|
Loading…
Reference in a new issue