diff --git a/src/statuses/views/form.clj b/src/statuses/views/form.clj new file mode 100644 index 0000000..d48ecde --- /dev/null +++ b/src/statuses/views/form.clj @@ -0,0 +1,19 @@ +(ns statuses.views.form + (:require [hiccup.def :refer [defelem]] + [hiccup.util :refer [to-uri]])) + +(defelem form-to + "Create a form that points to a particular method and route. + e.g. (form-to [:put \"/post\"] + ...)" + [[method action] & body] + (let [method-str (.toUpperCase (name method)) + action-uri (to-uri action)] + (-> (if (contains? #{:get :post} method) + [:form {:method method-str, :action action-uri}] + [:form {:method "POST", :action action-uri} + [:input {:type "hidden" + :name "_method" + :value method-str}]]) + (concat body) + (vec)))) diff --git a/src/statuses/views/layout.clj b/src/statuses/views/layout.clj index 934a8a0..1e8665e 100644 --- a/src/statuses/views/layout.clj +++ b/src/statuses/views/layout.clj @@ -7,10 +7,10 @@ [statuses.views.common :refer [icon]])) (defn preference [id title iconname] - [:li [:a {:name id} - (icon iconname) - [:label {:for (str "pref-" id)} title] - (check-box {:class "pref" :disabled "disabled"} (str "pref-" id))]]) + [:li [:p.navbar-text + (icon iconname) + [:label {:for (str "pref-" id)} title] + (check-box {:class "pref" :disabled "disabled"} (str "pref-" id))]]) (defn nav-link [url title iconname] [:li (link-to url (icon iconname) title)]) @@ -27,6 +27,7 @@ ([title username content footer] (html5 [:head + [:meta {:charset "utf-8"}] [:meta {:name "viewport" :content "width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no"}] [:title (str title " - innoQ Statuses")] @@ -39,17 +40,18 @@ :type "application/atom+xml"}] [:style "body { }"]] [:body - [:header.navbar.navbar-default.navbar-fixed-top {:role "navigation"} - [:div.container-fluid - [:div.navbar-header - [:button.navbar-toggle.collapsed {:type "button" :data-target ".navbar-collapse" :data-toggle "collapse"} - [:span.sr-only "Toggle navigation"] - [:span.icon-bar] - [:span.icon-bar] - [:span.icon-bar]] - [:a {:class "navbar-brand", :href "/statuses/updates"} "Statuses"]] - [:div.collapse.navbar-collapse - [:ul.nav.navbar-nav (nav-links username)]]]] + [:header + [:nav.navbar.navbar-default.navbar-fixed-top {:role "navigation"} + [:div.container-fluid + [:div.navbar-header + [:button.navbar-toggle.collapsed {:type "button" :data-target ".navbar-collapse" :data-toggle "collapse"} + [:span.sr-only "Toggle navigation"] + [:span.icon-bar] + [:span.icon-bar] + [:span.icon-bar]] + [:a {:class "navbar-brand", :href "/statuses/updates"} "Statuses"]] + [:div.collapse.navbar-collapse + [:ul.nav.navbar-nav (nav-links username)]]]]] [:main.container-fluid.tweet-wrapper content] [:footer footer] (include-js "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js") diff --git a/src/statuses/views/main.clj b/src/statuses/views/main.clj index adacb00..5f6c2fa 100644 --- a/src/statuses/views/main.clj +++ b/src/statuses/views/main.clj @@ -2,11 +2,12 @@ (:require [clj-time.local :refer [format-local-time]] [hiccup.core :refer [html]] [hiccup.element :refer [link-to]] - [hiccup.form :refer [form-to hidden-field text-field]] + [hiccup.form :refer [hidden-field text-field]] [statuses.configuration :refer [config]] [statuses.routes :refer [avatar-path update-path updates-path profile-path]] [statuses.views.common :as common :refer [icon]] + [statuses.views.form :refer [form-to]] [statuses.views.layout :as layout])) (defn- button @@ -46,9 +47,9 @@ [:span.author (link-to (str (updates-path) "?author=" author) author)] (if in-reply-to [:span.reply (link-to (update-path in-reply-to) in-reply-to)]) - [:span.actions (button "reply" "Reply" "reply") + [:div.actions (button "reply" "Reply" "reply") (if can-delete? - [:span.delete (delete-form id)])] + [:div.delete (delete-form id)])] [:span.time [:a.permalink {:href (update-path id)} (format-time time)]] ] [:div.post-content (common/linkify text)]