Use a property list for optional input settings
This commit is contained in:
parent
5a76a27674
commit
f598009d82
1 changed files with 41 additions and 29 deletions
70
eliss.el
70
eliss.el
|
@ -51,25 +51,28 @@ container div."
|
||||||
(directory-files eliss-data-directory nil
|
(directory-files eliss-data-directory nil
|
||||||
"\\.org$"))))))
|
"\\.org$"))))))
|
||||||
|
|
||||||
(defun eliss-control-group (name label &optional placeholder default)
|
(defun eliss-control-group (name label &rest plist)
|
||||||
"Return an often-used common HTML structure.
|
"Return an often-used common HTML structure.
|
||||||
|
|
||||||
Set the name and id attributes of the input to NAME, give it the
|
Set the name and id attributes of the input to NAME, give it the
|
||||||
label LABEL, optionally add a placeholder PLACEHOLDER and
|
label LABEL. The property list PLIST can be used to define
|
||||||
optionally a value DEFAULT."
|
certain other properties.
|
||||||
`(div (@ (class "control-group"))
|
|
||||||
(label (@ (class "control-label")
|
- `:default' may specify a default value to appear in the input.
|
||||||
(for ,name)) ,label)
|
|
||||||
(div (@ (class "controls"))
|
- `:placeholder' may specify a placeholder for the input, which
|
||||||
(input (@ (type "text")
|
appears if no value has been given."
|
||||||
(name ,name)
|
(let ((default (plist-get plist :default))
|
||||||
(id ,name)
|
(placeholder (plist-get plist :placeholder)))
|
||||||
,(if placeholder
|
`(div (@ (class "control-group"))
|
||||||
`(placeholder ,placeholder)
|
(label (@ (class "control-label")
|
||||||
nil)
|
(for ,name)) ,label)
|
||||||
,(if default
|
(div (@ (class "controls"))
|
||||||
`(value ,default)
|
(input (@ (type "text")
|
||||||
nil))))))
|
(name ,name)
|
||||||
|
(id ,name)
|
||||||
|
,(when placeholder `(placeholder ,placeholder))
|
||||||
|
,(when default `(value ,default))))))))
|
||||||
|
|
||||||
(defun eliss-project-page (httpcon)
|
(defun eliss-project-page (httpcon)
|
||||||
"Send a list of issues and an issue-creation form over HTTPCON."
|
"Send a list of issues and an issue-creation form over HTTPCON."
|
||||||
|
@ -98,14 +101,18 @@ optionally a value DEFAULT."
|
||||||
(legend "New issue")
|
(legend "New issue")
|
||||||
(div (@ (class "row"))
|
(div (@ (class "row"))
|
||||||
(div (@ (class "span5"))
|
(div (@ (class "span5"))
|
||||||
,(eliss-control-group "subject" "Subject"
|
,(eliss-control-group
|
||||||
"I wanna say...")
|
"subject" "Subject"
|
||||||
,(eliss-control-group "category" "Category" nil
|
:placeholder "I wanna say...")
|
||||||
"bug")
|
,(eliss-control-group "category" "Category"
|
||||||
,(eliss-control-group "tags" "Tags" "tag1:tag2")
|
:default "bug")
|
||||||
,(eliss-control-group "name" "Name" "John Doe")
|
,(eliss-control-group "tags" "Tags"
|
||||||
,(eliss-control-group "email" "Email"
|
:placeholder "tag1:tag2")
|
||||||
"john@example.com")
|
,(eliss-control-group "name" "Name"
|
||||||
|
:placeholder "John Doe")
|
||||||
|
,(eliss-control-group
|
||||||
|
"email" "Email"
|
||||||
|
:placeholder "john@example.com")
|
||||||
(input (@ (type "hidden")
|
(input (@ (type "hidden")
|
||||||
(name "i-m-human")
|
(name "i-m-human")
|
||||||
(value "t")))
|
(value "t")))
|
||||||
|
@ -166,12 +173,17 @@ optionally a value DEFAULT."
|
||||||
(div (@ (class "row"))
|
(div (@ (class "row"))
|
||||||
(div (@ (class "span5"))
|
(div (@ (class "span5"))
|
||||||
,(eliss-control-group
|
,(eliss-control-group
|
||||||
"subject" "Subject" nil
|
"subject" "Subject"
|
||||||
(concat "RE: " title))
|
:default (concat "RE: " title)
|
||||||
,(eliss-control-group "name" "Name"
|
:required t)
|
||||||
"John Doe")
|
|
||||||
,(eliss-control-group
|
,(eliss-control-group
|
||||||
"email" "Email" "john@example.com")
|
"name" "Name"
|
||||||
|
:placeholder "John Doe"
|
||||||
|
:required t)
|
||||||
|
,(eliss-control-group
|
||||||
|
"email" "Email"
|
||||||
|
:placeholder "john@example.com"
|
||||||
|
:required t)
|
||||||
(input (@ (type "hidden")
|
(input (@ (type "hidden")
|
||||||
(name "i-m-human")
|
(name "i-m-human")
|
||||||
(value "t")))
|
(value "t")))
|
||||||
|
|
Loading…
Reference in a new issue