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;
|
||||
}
|
||||
|
||||
#cc-logo {
|
||||
float: left;
|
||||
width: 200px;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
{% if cljs %}
|
||||
@-moz-keyframes three-quarters-loader {
|
||||
0% {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{% 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>The cource code of this application is located at GitHub: <a href="https://github.com/f0086/clojurecup2015-mailhead">f0086/clojurecup2015-mailhead</a></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -30,12 +30,24 @@
|
|||
</div>
|
||||
<div id="app-navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li {% ifequal page "home.html" %} class="active"{%endifequal%}>
|
||||
<a href="{{servlet-context}}/">Home</a>
|
||||
</li>
|
||||
<li {% ifequal page "about.html" %} class="active"{%endifequal%}>
|
||||
<a href="{{servlet-context}}/about">About</a>
|
||||
<li {% ifequal page "home.html" %} class="active"{%endifequal%}><a href="{{servlet-context}}/">Home</a> </li>
|
||||
<li>
|
||||
<a class="dropdown-toggle" data-toggle="dropdown"
|
||||
href="#" role="button" aria-haspopup="true"
|
||||
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 {% ifequal page "about.html" %} class="active"{%endifequal%}><a href="{{servlet-context}}/about">About</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,11 +2,18 @@
|
|||
{% block content %}
|
||||
<div class="row">
|
||||
<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">
|
||||
{% csrf-field %}
|
||||
<textarea class="form-control" name="mailheader" placeholder="Paste here your email in source format (with headers)"></textarea><br>
|
||||
<input class="btn btn-success form-control" type="submit" name="send" value="Analyze the header">
|
||||
<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 mail now!">
|
||||
</form>
|
||||
</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))]
|
||||
(MimeMessage. props input-stream)))
|
||||
|
||||
(defn parse [message-string]
|
||||
(defn parse-all [message-string]
|
||||
(->> message-string
|
||||
string->message
|
||||
read-message
|
||||
read-message))
|
||||
|
||||
(defn parse [message-string]
|
||||
(->> message-string
|
||||
parse-all
|
||||
:headers
|
||||
received-headers
|
||||
(map parse-received-headers)))
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
[mailhead.visualize :as v]
|
||||
[mailhead.parser :as parser]
|
||||
[compojure.core :refer [defroutes GET POST]]
|
||||
[ring.util.response :refer [redirect]]
|
||||
[ring.util.http-response :refer [ok content-type]]
|
||||
[clojure.java.io :as io]))
|
||||
|
||||
|
@ -13,17 +14,19 @@
|
|||
(layout/render "about.html"))
|
||||
|
||||
(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)))
|
||||
|
||||
;; TODO: Show more information (mail round trip time, ...)
|
||||
(defn show-result [message-string]
|
||||
(let [parsed-email (parser/parse message-string)
|
||||
token (v/draw parsed-email)]
|
||||
(layout/render "result.html"
|
||||
{:mailheader message-string
|
||||
:email parsed-email
|
||||
:token token})))
|
||||
(if (empty? (parser/parse message-string))
|
||||
(layout/render "parser-error.html" {:mailheader message-string})
|
||||
(let [parsed-email (parser/parse message-string)
|
||||
token (v/draw parsed-email)]
|
||||
(layout/render "result.html"
|
||||
{:mailheader message-string
|
||||
:email parsed-email
|
||||
:token token}))))
|
||||
|
||||
(defn generated-image [token]
|
||||
(-> (clojure.java.io/input-stream (str "generated-images/" token ".svg"))
|
||||
|
|
Loading…
Reference in a new issue