diff options
author | Tom Willemse | 2013-05-18 00:39:49 +0200 |
---|---|---|
committer | Tom Willemse | 2013-05-18 00:39:58 +0200 |
commit | f598009d82c90ed11fb36b58308e4df0420afe51 (patch) | |
tree | 395dcea7de3deca557fe845f41188e17c9b8224d | |
parent | 5a76a276747cb60ec7f3a43d05b360e22f54c130 (diff) | |
download | eliss-f598009d82c90ed11fb36b58308e4df0420afe51.tar.gz eliss-f598009d82c90ed11fb36b58308e4df0420afe51.zip |
Use a property list for optional input settings
-rw-r--r-- | eliss.el | 70 |
1 files changed, 41 insertions, 29 deletions
@@ -51,25 +51,28 @@ container div." (directory-files eliss-data-directory nil "\\.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. Set the name and id attributes of the input to NAME, give it the -label LABEL, optionally add a placeholder PLACEHOLDER and -optionally a value DEFAULT." - `(div (@ (class "control-group")) - (label (@ (class "control-label") - (for ,name)) ,label) - (div (@ (class "controls")) - (input (@ (type "text") - (name ,name) - (id ,name) - ,(if placeholder - `(placeholder ,placeholder) - nil) - ,(if default - `(value ,default) - nil)))))) +label LABEL. The property list PLIST can be used to define +certain other properties. + +- `:default' may specify a default value to appear in the input. + +- `:placeholder' may specify a placeholder for the input, which + appears if no value has been given." + (let ((default (plist-get plist :default)) + (placeholder (plist-get plist :placeholder))) + `(div (@ (class "control-group")) + (label (@ (class "control-label") + (for ,name)) ,label) + (div (@ (class "controls")) + (input (@ (type "text") + (name ,name) + (id ,name) + ,(when placeholder `(placeholder ,placeholder)) + ,(when default `(value ,default)))))))) (defun eliss-project-page (httpcon) "Send a list of issues and an issue-creation form over HTTPCON." @@ -98,14 +101,18 @@ optionally a value DEFAULT." (legend "New issue") (div (@ (class "row")) (div (@ (class "span5")) - ,(eliss-control-group "subject" "Subject" - "I wanna say...") - ,(eliss-control-group "category" "Category" nil - "bug") - ,(eliss-control-group "tags" "Tags" "tag1:tag2") - ,(eliss-control-group "name" "Name" "John Doe") - ,(eliss-control-group "email" "Email" - "john@example.com") + ,(eliss-control-group + "subject" "Subject" + :placeholder "I wanna say...") + ,(eliss-control-group "category" "Category" + :default "bug") + ,(eliss-control-group "tags" "Tags" + :placeholder "tag1:tag2") + ,(eliss-control-group "name" "Name" + :placeholder "John Doe") + ,(eliss-control-group + "email" "Email" + :placeholder "john@example.com") (input (@ (type "hidden") (name "i-m-human") (value "t"))) @@ -166,12 +173,17 @@ optionally a value DEFAULT." (div (@ (class "row")) (div (@ (class "span5")) ,(eliss-control-group - "subject" "Subject" nil - (concat "RE: " title)) - ,(eliss-control-group "name" "Name" - "John Doe") + "subject" "Subject" + :default (concat "RE: " title) + :required t) + ,(eliss-control-group + "name" "Name" + :placeholder "John Doe" + :required t) ,(eliss-control-group - "email" "Email" "john@example.com") + "email" "Email" + :placeholder "john@example.com" + :required t) (input (@ (type "hidden") (name "i-m-human") (value "t"))) |