diff --git a/resources/public/css/screen.css b/resources/public/css/screen.css
index 6343efe..4eb8248 100644
--- a/resources/public/css/screen.css
+++ b/resources/public/css/screen.css
@@ -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% {
diff --git a/resources/templates/about.html b/resources/templates/about.html
index c78972c..aac3f0d 100644
--- a/resources/templates/about.html
+++ b/resources/templates/about.html
@@ -1,5 +1,7 @@
{% extends "base.html" %}
{% block content %}
-
This is my ClojureCup 2015 entry.
+
+ ClojureCup 2015 entry
You can find me on Twitter: @fu86
+ The cource code of this application is located at GitHub: f0086/clojurecup2015-mailhead
{% endblock %}
diff --git a/resources/templates/base.html b/resources/templates/base.html
index 9fa9fa9..5f8bae5 100644
--- a/resources/templates/base.html
+++ b/resources/templates/base.html
@@ -30,12 +30,24 @@
diff --git a/resources/templates/home.html b/resources/templates/home.html
index dbb1133..cd91e1a 100644
--- a/resources/templates/home.html
+++ b/resources/templates/home.html
@@ -2,11 +2,18 @@
{% block content %}
-
Use this form to analyze a e-mail header. Just paste the whole e-mail in raw mode 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.
+
Use this form to analyze a e-mail. Just paste the whole e-mail
+ in raw mode 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.
+
diff --git a/resources/templates/parser-error.html b/resources/templates/parser-error.html
new file mode 100644
index 0000000..d70aaa9
--- /dev/null
+++ b/resources/templates/parser-error.html
@@ -0,0 +1,10 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+
Can't parse the given email
+
{{ mailheader }}
+
+
+{% endblock %}
diff --git a/src/mailhead/parser.clj b/src/mailhead/parser.clj
index 6f2e44f..6a5af8d 100644
--- a/src/mailhead/parser.clj
+++ b/src/mailhead/parser.clj
@@ -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)))
diff --git a/src/mailhead/routes/home.clj b/src/mailhead/routes/home.clj
index 4d94bfb..2816804 100644
--- a/src/mailhead/routes/home.clj
+++ b/src/mailhead/routes/home.clj
@@ -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"))