git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@179525 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
370b543326
commit
ed35f67885
|
@ -54,12 +54,18 @@ public class SocialMailingUtil {
|
|||
List<Comment> comments,
|
||||
String commentKey,
|
||||
String ... hashtags) {
|
||||
|
||||
String removedMarkup = notification2Save.getDescription().replaceAll("&", "&");
|
||||
removedMarkup = convertHTML2Text(removedMarkup);
|
||||
removedMarkup = removedMarkup.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
|
||||
String sender = notification2Save.getSenderFullName();
|
||||
|
||||
//notification2Save uri contains the absoulte path to the feed in the correct channel, e.g. /group/ustore_vre?oid=f1637958-34d0-48fc-b5ad-13b1116e389d
|
||||
String pathToVRE = siteLandingPagePath + "?";
|
||||
if (notification2Save.getUri().split("\\?").length > 0) {
|
||||
pathToVRE = notification2Save.getUri().split("\\?")[0];
|
||||
}
|
||||
_log.debug("editing hyperlinks for mail client");
|
||||
removedMarkup = removedMarkup.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
|
||||
removedMarkup = removedMarkup.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
|
||||
|
||||
String sender = notification2Save.getSenderFullName();
|
||||
String portalHost = portalURL.replaceAll("https://", "");
|
||||
portalHost = portalHost.replaceAll("http://", "");
|
||||
|
||||
|
@ -86,11 +92,9 @@ public class SocialMailingUtil {
|
|||
|
||||
body.append("<div style=\"color:#000; font-size:13px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
|
||||
.append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something
|
||||
.append("<p>")
|
||||
.append(getActionLink(notification2Save, portalURL)) //Goto
|
||||
.append("</p>")
|
||||
.append(attachmentsNotice)
|
||||
.append(SocialMailingUtil.buildHtmlDiscussion(notification2Save, feed, comments, commentKey)) // the original discussion
|
||||
.append(SocialMailingUtil.buildHtmlDiscussion(portalURL, pathToVRE, notification2Save, feed, comments, commentKey)) // the original discussion
|
||||
.append("</p>")
|
||||
.append("</div><br/>")
|
||||
.append("<p><div style=\"color:#999999; font-size:11px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
|
||||
|
@ -376,7 +380,7 @@ public class SocialMailingUtil {
|
|||
if (node instanceof Element) {
|
||||
Element element = (Element) node;
|
||||
if ("a".equals(element.tagName())) {
|
||||
buffer.append(" ");
|
||||
buffer.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +397,7 @@ public class SocialMailingUtil {
|
|||
Element element = (Element) node;
|
||||
String tagName = element.tagName();
|
||||
if ("a".equals(element.tagName())) {
|
||||
buffer.append(" ");
|
||||
buffer.append(" ");
|
||||
}
|
||||
if ("p".equals(tagName) || "br".equals(tagName)) {
|
||||
buffer.append("\n");
|
||||
|
@ -405,12 +409,12 @@ public class SocialMailingUtil {
|
|||
/**
|
||||
* Build up a discussion given the feed and its comments.
|
||||
* @param notification2Save
|
||||
* @param feed
|
||||
* @param post
|
||||
* @param comments
|
||||
* @param commentKey if not null, when building the discussion stop at this comment.
|
||||
* @return an html string representing the discussion
|
||||
*/
|
||||
protected static String buildHtmlDiscussion(Notification notification2Save, Feed feed, List<Comment> comments, String commentKey){
|
||||
protected static String buildHtmlDiscussion(String portalURL, String pathToVRE, Notification notification2Save, Feed post, List<Comment> comments, String commentKey){
|
||||
|
||||
try{
|
||||
|
||||
|
@ -424,37 +428,40 @@ public class SocialMailingUtil {
|
|||
Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
|
||||
|
||||
// escape html
|
||||
String feedTextNoHtml = convertHTML2Text(feed.getDescription());
|
||||
feedTextNoHtml = feedTextNoHtml.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
|
||||
String postTextNoHtml = post.getDescription().replaceAll("&", "&");
|
||||
postTextNoHtml = postTextNoHtml.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
|
||||
postTextNoHtml = postTextNoHtml.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
|
||||
|
||||
|
||||
// build up html post + comments
|
||||
if(notification2Save.getType() == NotificationType.POST_ALERT || (comments.size() == 0 && notification2Save.getType() == NotificationType.MENTION))
|
||||
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
|
||||
+ "font-style: italic; font-weight:bold\">"
|
||||
+ feed.getFullName()
|
||||
+ post.getFullName()
|
||||
+ ": "
|
||||
+ (feedTextNoHtml.length() > 100 ? feedTextNoHtml.substring(0, 100) + " ..." : feedTextNoHtml)
|
||||
+ (postTextNoHtml.length() > 200 ? postTextNoHtml.substring(0, 200) + " ..." : postTextNoHtml)
|
||||
+ "<p style=\"font-family:Lucida Grande,"
|
||||
+ "Verdana,Bitstream Vera Sans,Arial,sans-serif; "
|
||||
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(feed.getTime()) + "</p>"
|
||||
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(post.getTime()) + "</p>"
|
||||
+"</div>";
|
||||
else
|
||||
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
|
||||
+ "font-style: italic\">"
|
||||
+ feed.getFullName()
|
||||
+ post.getFullName()
|
||||
+ ": "
|
||||
+ (feedTextNoHtml.length() > 100 ? feedTextNoHtml.substring(0, 100) + " ..." : feedTextNoHtml)
|
||||
+ (postTextNoHtml.length() > 200 ? postTextNoHtml.substring(0, 200) + " ..." : postTextNoHtml)
|
||||
+ "<p style=\"font-family:Lucida Grande,"
|
||||
+ "Verdana,Bitstream Vera Sans,Arial,sans-serif; "
|
||||
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(feed.getTime()) + "</p>"
|
||||
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(post.getTime()) + "</p>"
|
||||
+"</div>";
|
||||
|
||||
if(comments != null)
|
||||
for (int i = 0; i < comments.size(); i++) {
|
||||
|
||||
String commentTextNoHtml = comments.get(i).getText().replaceAll("&", "&");
|
||||
commentTextNoHtml = convertHTML2Text(commentTextNoHtml);
|
||||
commentTextNoHtml = commentTextNoHtml.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
|
||||
|
||||
commentTextNoHtml = commentTextNoHtml.replaceAll("href=\"/group/", "href=\""+portalURL + "/group/"); //because there is no indication of the portal (for mentions)
|
||||
commentTextNoHtml = commentTextNoHtml.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal (for hashtags)
|
||||
|
||||
if((commentKey != null && comments.get(i).getKey().equals(commentKey)) && !(notification2Save.getType() == NotificationType.POST_ALERT)){
|
||||
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; "
|
||||
+ "border-left: 3px solid #ccc; font-style: italic; font-weight:bold\">"
|
||||
|
|
Loading…
Reference in New Issue