           [:tr
            [:td]
            (for [env environments]
-             [:td (escape-html env)])]]
+             [:td (h env)])]]
          [:tbody
           (for [row rows]
             [:tr
              [:td
-              (let [system-name (escape-html (some :system row))]
-                [:a {:href (str/join ["?systems=" system-name])}
-                 system-name])]
+              (let [system-name (h (some :system row))]
+                [:a {:href (str/join ["?systems=" (h system-name)])}
+                 (h system-name)])]
              (for [host row]
                (host-as-html host))])]]))
 

(defn- host-as-html [host]
  [:td {:class (str/join " " ["host" (some-> host
                                             :color
                                             name)])}
   (escape-html (:hostname host))
   (when (:message host)
     [:span.message (escape-html (:message host))])
   (when (:components host)
     [:ol.components
      (for [comp (prefer-order-of color-by-importance (:components host) :color)]
        [:li {:class (str/join " " ["component" (some-> comp
                                                        :color
                                                        name)])
              :title (:message comp)
              :data-name (:name comp)}
         (:name comp)])
      [:li.more]])])

(defn- environment-table-as-html [environments rows]

(ns greenyet.view
  (:require [clojure.string :as str]
            [hiccup.core :refer [h html]]))

(defn- index-of [list item]
  (count (take-while (partial not= item) list)))
