diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index a2357f3..630d3a4 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -4,6 +4,18 @@
+
+ uses
+
+
+ uses
+
+
+ uses
+
+
+ uses
+
uses
diff --git a/distro/changelog.xml b/distro/changelog.xml
index f23dbd5..1dd071d 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -1,4 +1,11 @@
+
+ Revised the way we shorten posts' text when this is very long, better heuristic used
+ Fixed bug #320, Users tagging does not work if @ is in the middle of already typed text, works for hashtags too
+ Revised mail notification message formatting, user text is now more clear and visible
+ Revised the way we provide back links for posts, removed assumption that News Feed is always present the default community page, good for single VRE portals support
+
Integrated gwt-bootstrap and revised css
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsService.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsService.java
index 5a4f025..e9c48ba 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsService.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsService.java
@@ -1,6 +1,7 @@
package org.gcube.portlets.user.newsfeed.client;
import java.util.ArrayList;
+import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Like;
@@ -38,7 +39,9 @@ public interface NewsService extends RemoteService {
boolean deleteFeed(String feedid);
- OperationResult comment(String feedid, String text, ArrayList mentionedUsers, String feedOwnerId, boolean isAppFeed);
+ OperationResult comment(String feedid, String text,
+ HashSet mentionedUsers, String feedOwnerId,
+ boolean isAppFeed);
OperationResult editComment(Comment toEdit);
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsServiceAsync.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsServiceAsync.java
index 1396c83..1556dfa 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/NewsServiceAsync.java
@@ -1,6 +1,7 @@
package org.gcube.portlets.user.newsfeed.client;
import java.util.ArrayList;
+import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Like;
@@ -33,7 +34,7 @@ public interface NewsServiceAsync {
void getUserSettings(AsyncCallback callback);
- void comment(String feedid, String text, ArrayList mentionedUsers,
+ void comment(String feedid, String text, HashSet mentionedUsers,
String feedOwnerId, boolean isAppFeed,
AsyncCallback callback);
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/event/AddCommentEvent.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/event/AddCommentEvent.java
index 8798d25..39dcc02 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/event/AddCommentEvent.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/event/AddCommentEvent.java
@@ -1,6 +1,6 @@
package org.gcube.portlets.user.newsfeed.client.event;
-import java.util.ArrayList;
+import java.util.HashSet;
import org.gcube.portlets.user.newsfeed.client.ui.TweetTemplate;
@@ -13,9 +13,9 @@ public class AddCommentEvent extends GwtEvent {
private TweetTemplate owner;
private String text;
- private ArrayList mentionedUsers;
+ private HashSet mentionedUsers;
- public AddCommentEvent(TweetTemplate owner, String text, ArrayList mentionedUsers) {
+ public AddCommentEvent(TweetTemplate owner, String text, HashSet mentionedUsers) {
this.owner = owner;
this.text = text;
this.mentionedUsers = mentionedUsers;
@@ -29,7 +29,7 @@ public class AddCommentEvent extends GwtEvent {
return text;
}
- public ArrayList getMentionedUsers() {
+ public HashSet getMentionedUsers() {
return mentionedUsers;
}
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java
index 93acc3d..02c194c 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java
@@ -2,6 +2,7 @@ package org.gcube.portlets.user.newsfeed.client.panels;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashSet;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
@@ -839,7 +840,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight("300px");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- newsPanel.add(loadingIcon);
+ newsPanel.add(new Image(loading));
}
private void showProblems() {
@@ -919,7 +920,7 @@ public class NewsFeedPanel extends Composite {
}
- private void doAddComment(final TweetTemplate owner, String text, ArrayList mentionedUsers) {
+ private void doAddComment(final TweetTemplate owner, String text, HashSet mentionedUsers) {
newsService.comment(owner.getFeedKey(), text, mentionedUsers, owner.getMyFeedUserId(), owner.isAppFeed(), new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SuperPosedTextArea.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SuperPosedTextArea.java
index 8cee8d5..b6ee90e 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SuperPosedTextArea.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SuperPosedTextArea.java
@@ -4,6 +4,8 @@
package org.gcube.portlets.user.newsfeed.client.ui;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
import org.gcube.portlets.user.gcubewidgets.client.elements.Div;
import org.gcube.portlets.user.newsfeed.client.NewsService;
@@ -40,7 +42,7 @@ public class SuperPosedTextArea extends TextArea {
public final static int ARROW_UP = 38;
public final static int ARROW_DOWN = 40;
- private ArrayList mentionedUsers = new ArrayList();
+ private HashSet mentionedUsers = new HashSet();
private String areaId;
@@ -49,9 +51,10 @@ public class SuperPosedTextArea extends TextArea {
*/
public SuperPosedTextArea(Div highlighterDIV) {
sinkEvents(Event.ONPASTE);
- sinkEvents(Event.ONKEYUP);
+ sinkEvents(Event.ONKEYPRESS);
sinkEvents(Event.ONCONTEXTMENU);
sinkEvents(Event.ONKEYDOWN);
+ sinkEvents(Event.ONKEYUP);
setText(AddCommentTemplate.COMMENT_TEXT);
this.highlighterDIV = highlighterDIV;
//needed to give unique identifiers to the Area (for the jQuery plugin)
@@ -68,7 +71,7 @@ public class SuperPosedTextArea extends TextArea {
public void onFailure(Throwable caught) {
}
});
- DOM.setElementAttribute(getElement(), "id", areaId);
+ getElement().setAttribute("id", areaId);
bind();
Timer t = new Timer() {
@Override
@@ -108,9 +111,13 @@ public class SuperPosedTextArea extends TextArea {
}
break;
}
+ case Event.ONKEYPRESS: {
+ pickUserDlg.onKeyPress(this.getCursorPos(), event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+this.getOffsetHeight(), getText());
+ break;
+ }
case Event.ONKEYUP: {
injectInDiv(getText());
- pickUserDlg.onKeyUp(event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+this.getOffsetHeight(), getText());
+ pickUserDlg.onKeyUp(event.getKeyCode());
break;
}
case Event.ONCONTEXTMENU: {
@@ -122,7 +129,7 @@ public class SuperPosedTextArea extends TextArea {
//avoid the arrow up to move the cursor at the beginning of the textbox and the TAB to move around inputs and enter to go newline
if (event.getKeyCode() == ARROW_UP || event.getKeyCode() == KeyCodes.KEY_TAB || event.getKeyCode() == KeyCodes.KEY_ENTER) {
DOM.eventCancelBubble(event, true);
- DOM.eventPreventDefault(event);
+ event.preventDefault();
return;
}
}
@@ -171,21 +178,17 @@ public class SuperPosedTextArea extends TextArea {
String toAdd = event.getSelectedItem().getAlternativeName();
mentionedUsers.add(toAdd);
- String[] toSplit = getText().split("@"); //get the preceeding part
-
- setText(toSplit[0]+toAdd);
- //Element highDiv = DOM.getElementById("comment-highlighter");
- Element highDiv = highlighterDIV.getElement();
-
- String[] htmlToSplit = highDiv.getInnerHTML().split("@"); //get the preceeding part
- String highLightedUser = ""+toAdd+"";
- highDiv.setInnerHTML(htmlToSplit[0]+highLightedUser);
+ String preceedingPart = getText().substring(0, event.getItemCursorIndexStart());
+ String afterPart = getText().substring(event.getItemCursorIndexEnd()+1);
+
+ setText(preceedingPart + toAdd + " " + afterPart);
+ injectInDiv(getText());
}
});
}
- public ArrayList getMentionedUsers() {
- ArrayList toReturn = new ArrayList();
+ public HashSet getMentionedUsers() {
+ HashSet toReturn = new HashSet();
for (String mentionedUser : mentionedUsers) {
if (getText().contains(mentionedUser))
toReturn.add(mentionedUser);
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java
index df00e7e..13352e9 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java
@@ -147,8 +147,10 @@ public class TweetTemplate extends Composite {
String feedText = feed.getDescription();
String descWithoutHTML = new HTML(feedText).getText();
+
if ( (! feedText.startsWith(" MAX_SHOWTEXT_LENGTH && !displaySingle) {
- feedText = feedText.substring(0, MAX_SHOWTEXT_LENGTH) + "...";
+ final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 500) ? (feedText.length() - (feedText.length() / 3)) : 500;
+ feedText = feedText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
seeMore.setHTML(" See More ");
}
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java
index 0cea4ab..c8d8cbc 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java
@@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
@@ -81,8 +82,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
private static final String SESSION_ADMIN_ATTR = "SESSION_ADMIN_ATTR";
private static final String USER_SETTINGS_ATTR = "USER_SETTINGS_ATTR";
public static final String TEST_USER = "test.user";
- public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
-
+ public static final String TEST_SCOPE = "/gcube/devsec/USTORE_VRE";
+
+ private String APP_ID;
+
/**
*
@@ -92,7 +95,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
private final static int MAX_FEEDS_NO = 45;
public void init() {
- store = new DBCassandraAstyanaxImpl();
+ store = new DBCassandraAstyanaxImpl();
+ APP_ID = this.getClass().getName();
}
public void destroy() {
@@ -570,7 +574,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (likeCommitResult) {
//if the user who liked this post is not the user who posted it notify the poster user (Feed owner)
if (! user.getUsername().equals(feedOwnerId)) {
- NotificationsManager nm = new ApplicationNotificationsManager(getASLSession());
+ NotificationsManager nm = new ApplicationNotificationsManager(getASLSession(), APP_ID);
boolean nResult = nm.notifyLikedFeed(feedOwnerId, feedid, escapeHtml(feedText));
_log.trace("Like Notification added? " + nResult);
}
@@ -602,7 +606,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* @param feedOwnerId the username of the user who created the post that was commented
*/
@Override
- public OperationResult comment(String feedid, String commentText, ArrayList mentionedUserFullNames, String feedOwnerId, boolean isAppFeed) {
+ public OperationResult comment(String feedid, String commentText, HashSet mentionedUserFullNames, String feedOwnerId, boolean isAppFeed) {
boolean commentCommitResult = false;
_log.trace("Trying to add this comment " + commentText);
UserInfo user = getUserSettings().getUserInfo();
@@ -613,9 +617,13 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(commentText);
+ //copy the set into a list
+ ArrayList mentionedUserFullNamesList = new ArrayList();
+ mentionedUserFullNamesList.addAll(mentionedUserFullNames);
+
ArrayList mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
- mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
+ mentionedUsers = getSelectedUserIds(mentionedUserFullNamesList);
escapedCommentText = Utils.convertMentionPeopleAnchorHTML(escapedCommentText, mentionedUsers);
}
@@ -632,7 +640,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
//if the comment was correctly delivered && is not an app feed notify users involved
if (commentCommitResult && isWithinPortal()) {
//if the user who commented this post is not the user who posted it notify the poster user (Feed owner)
- NotificationsManager nm = new ApplicationNotificationsManager(getASLSession());
+ NotificationsManager nm = new ApplicationNotificationsManager(getASLSession(), APP_ID);
if (! user.getUsername().equals(feedOwnerId) && (!isAppFeed)) {
boolean result = nm.notifyOwnCommentReply(feedOwnerId, feedid, escapeHtml(commentText));
_log.trace("Comment Notification to post owner added? " + result);