diff --git a/scrumelo.el b/scrumelo.el index 73b6aab..c97a6d4 100644 --- a/scrumelo.el +++ b/scrumelo.el @@ -18,6 +18,68 @@ (defvar scrumelo-project-file "~/projects/scrumelo/aeos.org" "The file containing the scrum backlog.") +(defvar scrumelo-bootstrap-css-location + "http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" + "The location of the twitter bootstrap CSS file.") + +(defvar scrumelo-bootstrap-js-location + "http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js" + "The location of the twitter bootstrap JS file.") + +(defvar scrumelo-font-awesome-css-location + "http://netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.min.css" + "The location of the font awesome CSS file.") + +(defvar scrumelo-jquery-js-location + "http://code.jquery.com/jquery-2.0.0.min.js" + "The location of the jQuery JS file.") + +(defun scrumelo--css (href) + "Return a link pointing to HREF." + `(link (@ (href ,href) (rel "stylesheet") (type "text/css")))) + +(defun scrumelo--css-list () + "Return a list of all required CSS files." + (list (scrumelo--css scrumelo-bootstrap-css-location) + (scrumelo--css scrumelo-font-awesome-css-location))) + +(defun scrumelo--js (src) + "Return a script sourcing SRC." + `(script (@ (src ,src) (language "JavaScript") + (type "text/javascript")) "")) + +(defun scrumelo--js-list () + "Return a list of all required JS files." + (list (scrumelo--js scrumelo-bootstrap-js-location) + (scrumelo--js scrumelo-jquery-js-location))) + +(defun scrumelo--story () + "Return a description of the current org heading as a scrum story." + (format "As a %s, I %s to %s" (org-entry-get (point) "Role") + (org-entry-get (point) "Necessity") + (nth 4 (org-heading-components)))) + +(defun scrumelo--story-row () + "Return a table row for the current org headline." + `(tr (td ,(org-entry-get (point) "TODO")) + (td ,(scrumelo--story)))) + +(defun scrumelo--maybe-story-row () + "If looking at a top level heading, return a table row for it." + (when (= (car (org-heading-components)) 1) + (scrumelo--story-row))) + +(defun scrumelo--inner-story-table (buffer) + "Return the inner part of the story table for BUFFER." + (with-current-buffer buffer + (delq nil (org-map-entries + 'scrumelo--maybe-story-row nil nil 'comment)))) + +(defun scrumelo--story-table (buffer) + "Return the story table for BUFFER." + `(table (@ (class "table table-striped")) + ,@(scrumelo--inner-story-table buffer))) + (defun scrumelo-backlog-page (httpcon) "Send the backlog overview over HTTPCON." (let ((buffer (find-file-noselect scrumelo-project-file))) @@ -28,21 +90,11 @@ "\n" (sxml-to-xml `(html (head (title "Scrumelo") - (link (@ (href "http://ryuslash.org/bootstrap2/css/bootstrap.min.css") - (type "text/css") (rel "stylesheet")))) + ,@(scrumelo--css-list) + ,@(scrumelo--js-list)) (body (div (@ (class "container")) - (table (@ (class "table")) - ,@(with-current-buffer buffer - (delq nil - (org-map-entries - (lambda () - (when (= (car (org-heading-components)) 1) - `(tr (td ,(org-entry-get (point) "TODO")) - (td ,(format "As a %s, I %s to %s" - (org-entry-get (point) "Role") - (org-entry-get (point) "Necessity") - (nth 4 (org-heading-components))))))) nil nil 'comment)))))))))))) + ,(scrumelo--story-table buffer))))))))) (defun scrumelo-handler (httpcon) "Send the right requests in HTTPCON to the right functions."