Make the app usable
This commit is contained in:
parent
2d0ddc7f2a
commit
adc27b3177
7 changed files with 62 additions and 18 deletions
|
@ -9,6 +9,12 @@ textarea {
|
||||||
height: 350px !important;
|
height: 350px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#cc-logo {
|
||||||
|
float: left;
|
||||||
|
width: 200px;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
{% if cljs %}
|
{% if cljs %}
|
||||||
@-moz-keyframes three-quarters-loader {
|
@-moz-keyframes three-quarters-loader {
|
||||||
0% {
|
0% {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p>This is my ClojureCup 2015 entry.</p>
|
<img id="cc-logo" src="/img/cup.svg">
|
||||||
|
<h1>ClojureCup 2015 entry</h1>
|
||||||
<p>You can find me on Twitter: <a href="https://twitter.com/fu86">@fu86</a></p>
|
<p>You can find me on Twitter: <a href="https://twitter.com/fu86">@fu86</a></p>
|
||||||
|
<p>The cource code of this application is located at GitHub: <a href="https://github.com/f0086/clojurecup2015-mailhead">f0086/clojurecup2015-mailhead</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -30,12 +30,24 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="app-navbar" class="navbar-collapse collapse">
|
<div id="app-navbar" class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li {% ifequal page "home.html" %} class="active"{%endifequal%}>
|
<li {% ifequal page "home.html" %} class="active"{%endifequal%}><a href="{{servlet-context}}/">Home</a> </li>
|
||||||
<a href="{{servlet-context}}/">Home</a>
|
<li>
|
||||||
</li>
|
<a class="dropdown-toggle" data-toggle="dropdown"
|
||||||
<li {% ifequal page "about.html" %} class="active"{%endifequal%}>
|
href="#" role="button" aria-haspopup="true"
|
||||||
<a href="{{servlet-context}}/about">About</a>
|
aria-expanded="false">
|
||||||
|
Try some examples<span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="{{servlet-context}}/example/1">Example
|
||||||
|
#1 (simple)</a></li>
|
||||||
|
<li><a href="{{servlet-context}}/example/2">Example
|
||||||
|
#2 (internal routing)</a></li>
|
||||||
|
<li><a href="{{servlet-context}}/example/3">Example
|
||||||
|
#3 (loops)</a></li>
|
||||||
|
<li><a href="{{servlet-context}}/example/4">Example
|
||||||
|
#4 (misconfiguration)</a></li>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li {% ifequal page "about.html" %} class="active"{%endifequal%}><a href="{{servlet-context}}/about">About</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,11 +2,18 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<p>Use this form to analyze a e-mail header. Just paste the whole e-mail in <strong>raw mode</strong> here and hit the analyze button. The e-mail will be analyzed and an visual representation will be generated. Use this tool o analyze e-mail problems or to see which servers, locations and companies the e-mail passed.</p>
|
<p>Use this form to analyze a e-mail. Just paste the whole e-mail
|
||||||
|
in <strong>raw mode</strong> here and hit the analyze button. The e-mail
|
||||||
|
will be analyzed and an visual representation will be generated. Use this
|
||||||
|
tool to find e-mail problems or to see which servers, locations and
|
||||||
|
companies the e-mail passed. This tool is intended for debugging e-mail
|
||||||
|
communication.</p>
|
||||||
|
|
||||||
<form action="/analyze" method="post">
|
<form action="/analyze" method="post">
|
||||||
{% csrf-field %}
|
{% csrf-field %}
|
||||||
<textarea class="form-control" name="mailheader" placeholder="Paste here your email in source format (with headers)"></textarea><br>
|
<textarea class="form-control" name="mailheader" placeholder="Paste your e-mail in source format (with headers) here."></textarea><br>
|
||||||
<input class="btn btn-success form-control" type="submit" name="send" value="Analyze the header">
|
<input class="btn btn-success form-control" type="submit" name="send"
|
||||||
|
value="Analyze the mail now!">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
10
resources/templates/parser-error.html
Normal file
10
resources/templates/parser-error.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="span12">
|
||||||
|
<h1>Can't parse the given email</h1>
|
||||||
|
<pre>{{ mailheader }}</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -26,10 +26,14 @@
|
||||||
input-stream (ByteArrayInputStream. (.getBytes string))]
|
input-stream (ByteArrayInputStream. (.getBytes string))]
|
||||||
(MimeMessage. props input-stream)))
|
(MimeMessage. props input-stream)))
|
||||||
|
|
||||||
(defn parse [message-string]
|
(defn parse-all [message-string]
|
||||||
(->> message-string
|
(->> message-string
|
||||||
string->message
|
string->message
|
||||||
read-message
|
read-message))
|
||||||
|
|
||||||
|
(defn parse [message-string]
|
||||||
|
(->> message-string
|
||||||
|
parse-all
|
||||||
:headers
|
:headers
|
||||||
received-headers
|
received-headers
|
||||||
(map parse-received-headers)))
|
(map parse-received-headers)))
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
[mailhead.visualize :as v]
|
[mailhead.visualize :as v]
|
||||||
[mailhead.parser :as parser]
|
[mailhead.parser :as parser]
|
||||||
[compojure.core :refer [defroutes GET POST]]
|
[compojure.core :refer [defroutes GET POST]]
|
||||||
|
[ring.util.response :refer [redirect]]
|
||||||
[ring.util.http-response :refer [ok content-type]]
|
[ring.util.http-response :refer [ok content-type]]
|
||||||
[clojure.java.io :as io]))
|
[clojure.java.io :as io]))
|
||||||
|
|
||||||
|
@ -13,17 +14,19 @@
|
||||||
(layout/render "about.html"))
|
(layout/render "about.html"))
|
||||||
|
|
||||||
(defn show-sample [index]
|
(defn show-sample [index]
|
||||||
(let [email-content (slurp (str "/home/aaron/workbench/clojurecup2015/sample-data/header" index ".eml"))]
|
(let [email-content (slurp (str "/home/aaron/workbench/clojurecup2015/sample-data/example" index ".eml"))]
|
||||||
(show-result email-content)))
|
(show-result email-content)))
|
||||||
|
|
||||||
;; TODO: Show more information (mail round trip time, ...)
|
;; TODO: Show more information (mail round trip time, ...)
|
||||||
(defn show-result [message-string]
|
(defn show-result [message-string]
|
||||||
(let [parsed-email (parser/parse message-string)
|
(if (empty? (parser/parse message-string))
|
||||||
token (v/draw parsed-email)]
|
(layout/render "parser-error.html" {:mailheader message-string})
|
||||||
(layout/render "result.html"
|
(let [parsed-email (parser/parse message-string)
|
||||||
{:mailheader message-string
|
token (v/draw parsed-email)]
|
||||||
:email parsed-email
|
(layout/render "result.html"
|
||||||
:token token})))
|
{:mailheader message-string
|
||||||
|
:email parsed-email
|
||||||
|
:token token}))))
|
||||||
|
|
||||||
(defn generated-image [token]
|
(defn generated-image [token]
|
||||||
(-> (clojure.java.io/input-stream (str "generated-images/" token ".svg"))
|
(-> (clojure.java.io/input-stream (str "generated-images/" token ".svg"))
|
||||||
|
|
Loading…
Reference in a new issue