                            with-body (assoc params :body (md/md-to-html-string (params :mdbody)))]
                        (do
                          (mutate/comment-ex user with-body)
-                         (redirect (str host (url "/ex/" (:id params))))))
-                     (redirect (str host "/sp/login.html")))))
+                         (redirect (url "/ex/" (:id params)))))
+                     (redirect "/sp/login.html"))))
 
            (GET "/sp/addex" {params :params cookies :cookies} ;;addex
                 (require-auth cookies

                 (if (auth/valid-auth-token? (:value (cookies "authToken")))
                   (let [params-with-dur (assoc params :duration (to-dur-str params) :body (params :mdbody))
                         posted (mutate/create-ex (auth/user-from-cookie cookies) params-with-dur)]
                     (redirect (str host (url "/ex/" (:id posted)))))
                   (redirect (str host "/sp/login.html"))))

           (GET "/sp" {cookies :cookies}
                (if (not= "nobody" (auth/user-from-cookie cookies))
                  (redirect (str host "/sp/latest/1"))
                  (redirect (str host "/sp/login.html")))))
  

         (form-group "password" "Salasana" {:type "password"})
         [:button.btn.btn-default {:type "submit"} "Kirjaudu"]]]]]]])

(defmacro require-auth [cookies form]
  `(if (and (auth/valid-auth-token? (:value (~cookies "authToken"))) (not= "nobody" (auth/user-from-cookie ~cookies)))
     ~form
     (redirect "/sp/login.html")))

(defroutes templates

