 (ns todo-repl-webapp.views
   (:require [hiccup.form :as form]
             [hiccup.page :as page]
-            [hiccup.core :as core]))
+            [hiccup.core :as h]))
 
 (def instructions
-  (core/html
+  (h/html
     [:div.alert.alert-info
       [:div [:b "Instructions"]]
       [:div.row

          [:div#display.col-md-7.col-md-offset-2
            (display tasks)]
          (page/include-js "js/eval.js")]))

(defn task-line-item
  "When given a single task (map), return a html table line representing the task"
  [task-map]
  (h/html [:div.panel.panel-default
               [:div.panel-body
                 (task-item task-map)]]))

(defn task-table 
  "When given a vector of tasks (maps), return an html table representing those tasks"
  [task-vec]
  (h/html
      (clojure.string/join
        (map task-line-item task-vec))))

(defn display [x & xs]
  (if-not (empty? x)
    (h/html [:h2 "list"]
          #_[:h3 x]
            (task-table (vec x)))))

(defn home [tasks]
  (h/html [:head 
          [:title "todo-repl"]
          (page/include-css "css/bootstrap.min.css")
          (page/include-js "http://code.jquery.com/jquery-1.10.1.min.js"
