Show the generated image on the HMTL esult page
This commit is contained in:
parent
d96250b444
commit
0786d3492a
2 changed files with 16 additions and 6 deletions
|
@ -3,7 +3,12 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
{{ mailheader }}
|
<h1>Results</h1>
|
||||||
|
<img src="/image/{{ token }}">
|
||||||
|
|
||||||
|
|
||||||
|
<h2>The analyzed email</h2>
|
||||||
|
<pre>{{ mailheader }}</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [mailhead.layout :as layout]
|
(:require [mailhead.layout :as layout]
|
||||||
[mailhead.visualize :as v]
|
[mailhead.visualize :as v]
|
||||||
[compojure.core :refer [defroutes GET POST]]
|
[compojure.core :refer [defroutes GET POST]]
|
||||||
[ring.util.http-response :refer [ok]]
|
[ring.util.http-response :refer [ok content-type]]
|
||||||
[clojure.java.io :as io]))
|
[clojure.java.io :as io]))
|
||||||
|
|
||||||
(defn home-page []
|
(defn home-page []
|
||||||
|
@ -13,13 +13,18 @@
|
||||||
|
|
||||||
(defn analyze-mailheader [mailheader]
|
(defn analyze-mailheader [mailheader]
|
||||||
(let [token (v/draw mailheader)]
|
(let [token (v/draw mailheader)]
|
||||||
;; TODO: Generate token
|
|
||||||
;; TODO: Generate image
|
|
||||||
;; TODO: Show image and other data on result.html
|
;; TODO: Show image and other data on result.html
|
||||||
(layout/render "result.html" {:mailheader mailheader})))
|
(layout/render "result.html"
|
||||||
|
{:mailheader mailheader
|
||||||
|
:token token})))
|
||||||
|
|
||||||
|
(defn generated-image [token]
|
||||||
|
(-> (clojure.java.io/input-stream (str "generated-images/" token ".svg"))
|
||||||
|
ok
|
||||||
|
(content-type "image/svg+xml")))
|
||||||
|
|
||||||
(defroutes home-routes
|
(defroutes home-routes
|
||||||
(GET "/" [] (home-page))
|
(GET "/" [] (home-page))
|
||||||
|
(GET "/image/:token" [token] (generated-image token))
|
||||||
(POST "/analyze" [mailheader] (analyze-mailheader mailheader))
|
(POST "/analyze" [mailheader] (analyze-mailheader mailheader))
|
||||||
(GET "/about" [] (about-page)))
|
(GET "/about" [] (about-page)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue