             [ring.adapter.jetty :refer [run-jetty]]
             [hiccup.page :as page]
             [hiccup.form :as form]
-            [hiccup.util :as util]))
+            [hiccup.util :as util]
+            [ring.util.response :refer [redirect]]))
+
+; State
+
+(def posts (ref {}))
+(def nextId (ref 1))
+
+; Post form
 
 (defn page-layout [title & body]
   (page/html5

      body]
     (page/include-js "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js")]))

(defn post-form []
  (page-layout
    "Post to Screen"
    [:h1 "Post to Screen"]
    (form/form-to {:role "form"}
      [:post "/"]
      [:div.form-group
       (form/text-area {:class "form-control" :rows 20} "code")]
      (form/submit-button {:class "btn btn-primary"} "Post code"))))

(defn show-code [code]
  (code-layout
    "Posted code"
    [:pre
     [:code (util/escape-html code)]]))

(deftemplate page
  (io/resource "index.html") [] [:body] (if is-dev? inject-devmode-html identity))

      body]
     (page/include-js "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js")]))

(defn post-form []
  (page-layout
    "Post to Screen"
    [:h1 "Post to Screen"]
    (form/form-to {:role "form"}
                  [:post "/posts"]
                  [:div.form-group
                   (form/text-area {:class "form-control" :rows 20} "code")]
                  (form/submit-button {:class "btn btn-primary"} "Post code"))))

; Show code

(defn code-layout [title & body]
  (page/html5
