From 02363442482baf6402e418e54e491d91b24ccd08 Mon Sep 17 00:00:00 2001 From: Michael Vitz Date: Thu, 11 Dec 2014 12:23:26 +0100 Subject: [PATCH 1/5] Add charset definition to HTML pages Specifying the charset prevents the browser from guessing the charset to use. Relates to #130. --- src/statuses/views/layout.clj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/statuses/views/layout.clj b/src/statuses/views/layout.clj index 934a8a0..f679677 100644 --- a/src/statuses/views/layout.clj +++ b/src/statuses/views/layout.clj @@ -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")] From d4106bf2f3a22ed3c1331f9481d5dad00f8db468 Mon Sep 17 00:00:00 2001 From: Michael Vitz Date: Thu, 11 Dec 2014 12:29:42 +0100 Subject: [PATCH 2/5] Add nav HTML element Instead of a header with role navigation now the HTML5 element nav is used. Relates to #130. --- src/statuses/views/layout.clj | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/statuses/views/layout.clj b/src/statuses/views/layout.clj index f679677..ee58b79 100644 --- a/src/statuses/views/layout.clj +++ b/src/statuses/views/layout.clj @@ -40,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") From 0b4b85e45ad17348eb526be9702477cd675c8f3a Mon Sep 17 00:00:00 2001 From: Michael Vitz Date: Thu, 11 Dec 2014 12:47:06 +0100 Subject: [PATCH 3/5] Remove link from preferences Removes warnings from w3c validator that label and input are not valid inside an a element. Because preferences aren't links anyway this increases semantic as well. Relates to #130. --- src/statuses/views/layout.clj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/statuses/views/layout.clj b/src/statuses/views/layout.clj index ee58b79..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)]) From 53a0804d01c87264ac18dfae59d9a21f9569ecb1 Mon Sep 17 00:00:00 2001 From: Michael Vitz Date: Fri, 13 Mar 2015 09:25:50 +0100 Subject: [PATCH 4/5] Remove id attribute from hidden _method form field. By default hiccup generates an id for every form field. In our case (more than one form with method DELETE on the same page) this leads to non unique ids which leads to w3c validation errors. Relates to #130. Workaround for weavejester/hiccup#109. --- src/statuses/views/form.clj | 19 +++++++++++++++++++ src/statuses/views/main.clj | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/statuses/views/form.clj 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/main.clj b/src/statuses/views/main.clj index adacb00..db11780 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 From d477a31efb4936ec1122f976e8c6aaae44b8a99f Mon Sep 17 00:00:00 2001 From: Michael Vitz Date: Fri, 13 Mar 2015 09:34:11 +0100 Subject: [PATCH 5/5] Fix form inside of span element. Only inline elements may be contained whithin inline elements. Because form is not an inline element this leads to w3c validation errors. Relates to #130. --- src/statuses/views/main.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/statuses/views/main.clj b/src/statuses/views/main.clj index db11780..5f6c2fa 100644 --- a/src/statuses/views/main.clj +++ b/src/statuses/views/main.clj @@ -47,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)]