Skip to content

Commit

Permalink
Improve highlighting of trace view, dims untaken path.
Browse files Browse the repository at this point in the history
  • Loading branch information
ordnungswidrig committed Aug 5, 2016
1 parent 571f867 commit 14d738d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/liberator/dev.clj
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
(format
"svg.getElementById(\"%s\").setAttribute(\"class\", svg.getElementById(\"%s\").getAttribute(\"class\") + \" %s\");" id id (if (result->bool r1) "hl-true" "hl-false"))))
(map vector log (rest log))))

"};"
"setTimeout(function(){insertStyle()}, 500);"
"setTimeout(function(){insertStyle()}, 1000);"
"setTimeout(function(){insertStyle()}, 5000);"

""])]
[:body
[:a {:href mount-url} "List of all traces"]
Expand All @@ -99,10 +99,10 @@
[:ol (map (fn [[l [n r]]] [:li (h l) ": " (h n) " "
(if (nil? r) [:em "nil"] (h (pr-str r)))]) log)]
[:div {:style "text-align: center;"}
[:object {:id "trace" :data (str mount-url "trace.svg") :width "90%"
[:object {:id "trace" :data (str mount-url "trace.svg") :width "100%"
:style "border: 1px solid #666;"}]]


[:h3 "Full Request"]
[:pre [:tt (h (with-out-str (clojure.pprint/pprint r)))]]])
"application/json"
Expand All @@ -123,7 +123,7 @@

(defresource list-handler
:available-media-types ["text/html"]
:handle-ok (fn [_]
:handle-ok (fn [_]
(html5
[:head
[:title "Liberator Request Traces"]]
Expand Down Expand Up @@ -168,11 +168,11 @@
:available-media-types ["text/css"]
:handle-ok "#x-liberator-trace {
display:block;
position:absolute;
top:0;
right:0;
margin-top: 1em;
margin-right: 1em;
padding: 0 1em;
Expand All @@ -192,7 +192,6 @@
(defn- wrap-trace-ui [handler]
(let [base-url (with-slash mount-url)]
(routes
;; (fn [_]
(GET (str base-url "trace.svg") [] (fn [_] trace-svg))
(ANY (str base-url "styles.css") [] styles)
(ANY [(str base-url ":id") :id #".+"] [id] #((log-handler id) %))
Expand Down Expand Up @@ -226,7 +225,7 @@
:ui - Include link to a resource that dumps the current request
:header - Include full trace in response header"
[handler & opts]
(->
(->
(fn [request]
(let [request-log (atom [])]
(binding [*current-id* (next-id)]
Expand Down
9 changes: 8 additions & 1 deletion src/liberator/trace.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.node:not(.hl-false):not(.hl-true) polygon { fill: #f8f8f8; stroke: #dddddd; }
.node ellipse { fill: #f8f8f8; stroke: #dddddd; }
.node text { fill: #999999; }
.edge path { stroke: #999999; stroke-width: 1;}
.edge text { fill: #999999; }
.edge polygon { fill: #999999; stroke: #999999 }

.node.hl-true:not([id^="handle"]) polygon { fill: #ccffcc; stroke: #00dd00; }
.node.hl-true polygon { stroke-width: 3;}
.node.hl-true text { fill: #003300; }
Expand All @@ -10,4 +17,4 @@
.node.hl-false text { fill: #330000; }
.edge.hl-false path { stroke: #dd0000; stroke-width: 3;}
.edge.hl-false polygon { fill: #dd0000; stroke: #dd0000; stroke-width: 3;}
.edge.hl-false text { fill: #dd0000; }
.edge.hl-false text { fill: #dd0000; }

0 comments on commit 14d738d

Please sign in to comment.