You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/09/05 08:02:35 UTC
[1/2] incubator-ponymail git commit: add a regex for catching URLs
Repository: incubator-ponymail
Updated Branches:
refs/heads/coffee-and-cake 6fd100c06 -> 80707ed34
add a regex for catching URLs
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/567d7d85
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/567d7d85
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/567d7d85
Branch: refs/heads/coffee-and-cake
Commit: 567d7d8586baae3a214fd0c712ddb979443cbfc7
Parents: 6fd100c
Author: Daniel Gruno <hu...@apache.org>
Authored: Mon Sep 5 09:57:27 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Mon Sep 5 09:57:27 2016 +0200
----------------------------------------------------------------------
site/js/coffee/misc.coffee | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/567d7d85/site/js/coffee/misc.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/misc.coffee b/site/js/coffee/misc.coffee
index 3bbcbc0..e8cedec 100644
--- a/site/js/coffee/misc.coffee
+++ b/site/js/coffee/misc.coffee
@@ -72,3 +72,20 @@ Array.prototype.remove = (val) ->
return this
return this;
+ponymail_url_regex = new RegExp(
+ "(" +
+ "(?:(?:[a-z]+)://)" +
+ "(?:\\S+(?::\\S*)?@)?" +
+ "(?:" +
+ "([01][0-9][0-9]|2[0-4][0-9]|25[0-5])" +
+ "|" +
+ "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
+ "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
+ "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
+ "\\.?" +
+ ")" +
+ "(?::\\d{2,5})?" +
+ "(?:[/?#]([^,<>()\\[\\] \\t\\r\\n]|(<[^:\\s]*?>|\\([^:\\s]*?\\)|\\[[^:\\s]*?\\]))*)?" +
+ ")\\.?"
+ , "mi"
+)
\ No newline at end of file
[2/2] incubator-ponymail git commit: convert links to HTML inside
email body
Posted by hu...@apache.org.
convert links to HTML inside email body
also fix the float issue
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/80707ed3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/80707ed3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/80707ed3
Branch: refs/heads/coffee-and-cake
Commit: 80707ed344551b8abb8a6c5fdbce9e277c83ed9f
Parents: 567d7d8
Author: Daniel Gruno <hu...@apache.org>
Authored: Mon Sep 5 10:02:19 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Mon Sep 5 10:02:19 2016 +0200
----------------------------------------------------------------------
site/css/ponymail2.css | 4 +++
site/js/coffee/email_display_basic.coffee | 43 ++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/80707ed3/site/css/ponymail2.css
----------------------------------------------------------------------
diff --git a/site/css/ponymail2.css b/site/css/ponymail2.css
index 7143356..bbae155 100644
--- a/site/css/ponymail2.css
+++ b/site/css/ponymail2.css
@@ -417,4 +417,8 @@ a {
padding-top: 0px;
width: calc(100% - 90px);
float: left;
+}
+
+.email_body {
+ float: left;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/80707ed3/site/js/coffee/email_display_basic.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/email_display_basic.coffee b/site/js/coffee/email_display_basic.coffee
index b6fdb4e..11bdce2 100644
--- a/site/js/coffee/email_display_basic.coffee
+++ b/site/js/coffee/email_display_basic.coffee
@@ -45,7 +45,7 @@ readEmail = (obj) ->
ponymail_current_email = new BasicEmailDisplay(parent, mid)
ponymail_email_open.push(ponymail_current_email)
-
+### Basic email display class ###
class BasicEmailDisplay
constructor: (@parent, @mid) ->
@placeholder = get("placeholder_" + @mid) || new HTML('div', { class: "email_placeholder", id: "placeholder_" + @mid})
@@ -116,10 +116,49 @@ class BasicEmailDisplay
@placeholder.inject(headers)
+ ### Convert links to HTML ###
+ @htmlbody = @parseBody(json.body)
+
### Now inject the body ###
- b = new HTML('pre', {}, json.body)
+ b = new HTML('pre', {class: "email_body"}, @htmlbody)
@placeholder.inject(b)
+
+ ### parseBody: find links and HTML'ify them ###
+ parseBody: (splicer) ->
+ ### Array holding text and links ###
+ textbits = []
+
+ ### Find the first link, if any ###
+ i = splicer.search(ponymail_url_regex)
+ urls = 0
+
+ ### While we have more links, ... ###
+ while i != -1
+ urls++
+ ### Only parse the first 50 URLs... srsly ###
+ if urls > 50
+ break
+ ### Text preceding the link? add it to textbits frst ###
+ if i > 0
+ t = splicer.substr(0, i)
+ textbits.push(t)
+ splicer = splicer.substr(i)
+
+ ### Find the URL and cut it out as a link ###
+ m = splicer.match(ponymail_url_regex)
+ if m
+ url = m[1]
+ i = url.length
+ t = splicer.substr(0, i)
+ textbits.push(new HTML('a', {href: url}, url))
+ splicer = splicer.substr(i)
+ ### Find the next link ###
+ i = splicer.search(ponymail_url_regex)
+
+ ### push the remaining text into textbits ###
+ textbits.push(splicer)
+ return textbits
hide: () ->
@placeholder.show(false)