|
|
|
@ -64,7 +64,7 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
|
|
|
|
|
public static final String loading = GWT.getModuleBaseURL() + "../images/loading-comments.gif";
|
|
|
|
|
|
|
|
|
|
private static final int MAX_SHOWTEXT_LENGTH = 512;
|
|
|
|
|
private static final int MAX_SHOWTEXT_LENGTH = 612;
|
|
|
|
|
|
|
|
|
|
private EnhancedFeed myPost;
|
|
|
|
|
private UserInfo myUserInfo;
|
|
|
|
@ -148,7 +148,7 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
this.separator.setVisible(false);
|
|
|
|
|
this.myPost = myPost;
|
|
|
|
|
isAppPost = myPost.getFeed().isApplicationFeed();
|
|
|
|
|
Feed feed = myPost.getFeed();
|
|
|
|
|
Feed post = myPost.getFeed();
|
|
|
|
|
this.eventBus = eventBus;
|
|
|
|
|
this.isUsers = myPost.isUsers();
|
|
|
|
|
this.carousel = new Carousel();
|
|
|
|
@ -162,24 +162,24 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if there is one attachment or a link preview, maintain backward compatibility
|
|
|
|
|
if (feed.getUri() != null && feed.getUri().compareTo("") != 0 && feed.getLinkTitle() != null && feed.getLinkTitle().compareTo("") != 0 && !feed.isMultiFileUpload()) {
|
|
|
|
|
if (post.getUri() != null && post.getUri().compareTo("") != 0 && post.getLinkTitle() != null && post.getLinkTitle().compareTo("") != 0 && !post.isMultiFileUpload()) {
|
|
|
|
|
|
|
|
|
|
// hide the attachments panel
|
|
|
|
|
attachmentPreviewPanel.setVisible(false);
|
|
|
|
|
|
|
|
|
|
LinkPreviewer linkPreviewer = new LinkPreviewer(feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.getUriThumbnail(), feed.getUri());
|
|
|
|
|
LinkPreviewer linkPreviewer = new LinkPreviewer(post.getLinkTitle(), post.getLinkDescription(), post.getLinkHost(), post.getUriThumbnail(), post.getUri());
|
|
|
|
|
|
|
|
|
|
// enable the image previewer if it is an image (mime)
|
|
|
|
|
if(feed.getLinkHost().contains("image/")){
|
|
|
|
|
if(post.getLinkHost().contains("image/")){
|
|
|
|
|
|
|
|
|
|
ArrayList<EnhancedImage> listOfEnhancedImages;
|
|
|
|
|
|
|
|
|
|
EnhancedImage enhancedImage = new EnhancedImage(
|
|
|
|
|
feed.getUri(),
|
|
|
|
|
feed.getLinkTitle() +
|
|
|
|
|
" (" + feed.getLinkDescription() + ", type:" + feed.getLinkHost() +")",
|
|
|
|
|
feed.getLinkTitle(),
|
|
|
|
|
feed.getUri()
|
|
|
|
|
post.getUri(),
|
|
|
|
|
post.getLinkTitle() +
|
|
|
|
|
" (" + post.getLinkDescription() + ", type:" + post.getLinkHost() +")",
|
|
|
|
|
post.getLinkTitle(),
|
|
|
|
|
post.getUri()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
listOfEnhancedImages = new ArrayList<EnhancedImage>();
|
|
|
|
@ -200,7 +200,7 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// in case there are attachments, we have to fill attachmentPreviewPanel instead of the previewPanel
|
|
|
|
|
if(feed.isMultiFileUpload()){
|
|
|
|
|
if(post.isMultiFileUpload()){
|
|
|
|
|
|
|
|
|
|
// set style to the attachment container
|
|
|
|
|
attachmentPreviewPanel.setStyleName("attachment-preview-container");
|
|
|
|
@ -213,12 +213,12 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
|
|
|
|
|
// remember that one attachment is stored in the fields: uri, uriThumbnail, linkTitle, linkDescription, linkHost
|
|
|
|
|
Attachment firstAttachment = new Attachment(
|
|
|
|
|
feed.getKey(), // it is meaningless but it's needed
|
|
|
|
|
feed.getUri(),
|
|
|
|
|
feed.getLinkTitle(),
|
|
|
|
|
feed.getLinkDescription(),
|
|
|
|
|
feed.getUriThumbnail(),
|
|
|
|
|
feed.getLinkHost());
|
|
|
|
|
post.getKey(), // it is meaningless but it's needed
|
|
|
|
|
post.getUri(),
|
|
|
|
|
post.getLinkTitle(),
|
|
|
|
|
post.getLinkDescription(),
|
|
|
|
|
post.getUriThumbnail(),
|
|
|
|
|
post.getLinkHost());
|
|
|
|
|
|
|
|
|
|
// create first attachment previewer and pass it the carousel
|
|
|
|
|
AttachmentPreviewer firstAttachmentPreviewer = new AttachmentPreviewer(firstAttachment);
|
|
|
|
@ -230,11 +230,11 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
if(firstAttachment.getMimeType().contains("image/")){
|
|
|
|
|
|
|
|
|
|
EnhancedImage enhancedImage = new EnhancedImage(
|
|
|
|
|
feed.getUri(),
|
|
|
|
|
feed.getLinkTitle() +
|
|
|
|
|
" (" + feed.getLinkDescription() + ", type:" + feed.getLinkHost() +")",
|
|
|
|
|
feed.getLinkTitle(),
|
|
|
|
|
feed.getUri()
|
|
|
|
|
post.getUri(),
|
|
|
|
|
post.getLinkTitle() +
|
|
|
|
|
" (" + post.getLinkDescription() + ", type:" + post.getLinkHost() +")",
|
|
|
|
|
post.getLinkTitle(),
|
|
|
|
|
post.getUri()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
listOfEnhancedImages.add(enhancedImage);
|
|
|
|
@ -258,7 +258,7 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
EnhancedImage enhancedImage = new EnhancedImage(
|
|
|
|
|
otherAttachment.getUri(),
|
|
|
|
|
otherAttachment.getName() +
|
|
|
|
|
" (" + otherAttachment.getDescription() + ", type:" + feed.getLinkHost() +")",
|
|
|
|
|
" (" + otherAttachment.getDescription() + ", type:" + post.getLinkHost() +")",
|
|
|
|
|
otherAttachment.getName(),
|
|
|
|
|
otherAttachment.getUri()
|
|
|
|
|
);
|
|
|
|
@ -296,30 +296,30 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
|
|
|
|
|
commentArea.setHTML("<a>" + NewsFeedPanel.COMMENT_LABEL + "</a>");
|
|
|
|
|
|
|
|
|
|
String feedText = feed.getDescription();
|
|
|
|
|
String descWithoutHTML = new HTML(feedText).getText();
|
|
|
|
|
String postText = post.getDescription();
|
|
|
|
|
String descWithoutHTML = new HTML(postText).getText();
|
|
|
|
|
|
|
|
|
|
if ( (! feedText.startsWith("<span")) && descWithoutHTML.length() > MAX_SHOWTEXT_LENGTH && !displaySingle) {
|
|
|
|
|
final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 500) ? (feedText.length() - (feedText.length() / 3)) : 500;
|
|
|
|
|
feedText = feedText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
|
|
|
|
|
if ( (! postText.startsWith("<span")) && descWithoutHTML.length() > MAX_SHOWTEXT_LENGTH && !displaySingle) {
|
|
|
|
|
final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 600) ? (postText.length() - (postText.length() / 3)) : 600;
|
|
|
|
|
postText = postText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
|
|
|
|
|
seeMore.setHTML("<a class=\"seemore\"> See More </a>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
avatarImage.setUrl(feed.getThumbnailURL());
|
|
|
|
|
avatarImage.setUrl(post.getThumbnailURL());
|
|
|
|
|
avatarImage.setPixelSize(40, 40);
|
|
|
|
|
|
|
|
|
|
//replace the < & and >
|
|
|
|
|
feedText = feedText.replaceAll("<","<").replaceAll(">",">");
|
|
|
|
|
feedText = feedText.replaceAll("&","&");
|
|
|
|
|
postText = postText.replaceAll("<","<").replaceAll(">",">");
|
|
|
|
|
postText = postText.replaceAll("&","&");
|
|
|
|
|
|
|
|
|
|
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (showTimelineSource && feed.getVreid() != null && feed.getVreid().compareTo("") != 0) {
|
|
|
|
|
if (showTimelineSource && post.getVreid() != null && post.getVreid().compareTo("") != 0) {
|
|
|
|
|
this.vreSourceInMetadata.setVisible(true);
|
|
|
|
|
this.separator.setVisible(true);
|
|
|
|
|
String vreName = feed.getVreid().substring(feed.getVreid().lastIndexOf("/")+1);
|
|
|
|
|
String vreName = post.getVreid().substring(post.getVreid().lastIndexOf("/")+1);
|
|
|
|
|
vreSourceInMetadata.setText(vreName);
|
|
|
|
|
vreSourceInMetadata.addClickHandler(new ClickHandler() {
|
|
|
|
|
@Override
|
|
|
|
@ -334,32 +334,32 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+profilePageURL
|
|
|
|
|
+"?"+
|
|
|
|
|
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
|
|
|
|
Encoder.encode(feed.getEntityId())+"\">"+feed.getFullName()+"</a>");
|
|
|
|
|
contentArea.setHTML(feedText);
|
|
|
|
|
Encoder.encode(post.getEntityId())+"\">"+post.getFullName()+"</a>");
|
|
|
|
|
contentArea.setHTML(postText);
|
|
|
|
|
|
|
|
|
|
//check if the user has his own avatar
|
|
|
|
|
if (feed.getThumbnailURL().contains("img_id=0") || !feed.getThumbnailURL().contains("?")) { //it means no avatar is set
|
|
|
|
|
if (post.getThumbnailURL().contains("img_id=0") || !post.getThumbnailURL().contains("?")) { //it means no avatar is set
|
|
|
|
|
avatarImage.setVisible(false);
|
|
|
|
|
String f = "A";
|
|
|
|
|
String s = "Z";
|
|
|
|
|
if (feed.getFullName() != null) {
|
|
|
|
|
String[] parts = feed.getFullName().split("\\s");
|
|
|
|
|
if (post.getFullName() != null) {
|
|
|
|
|
String[] parts = post.getFullName().split("\\s");
|
|
|
|
|
if (parts.length > 0) {
|
|
|
|
|
f = parts[0].toUpperCase();
|
|
|
|
|
s = parts[parts.length-1].toUpperCase();
|
|
|
|
|
} else {
|
|
|
|
|
f = feed.getFullName().substring(0,1);
|
|
|
|
|
s = feed.getFullName().substring(1,2);
|
|
|
|
|
f = post.getFullName().substring(0,1);
|
|
|
|
|
s = post.getFullName().substring(1,2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
avatarReplacement.setInitials(feed.getEntityId(), f, s);
|
|
|
|
|
avatarReplacement.setInitials(post.getEntityId(), f, s);
|
|
|
|
|
avatarReplacement.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// messageSeparator.setVisible(false);
|
|
|
|
|
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+feed.getUri()+"\">"+feed.getFullName()+"</a>");
|
|
|
|
|
contentArea.setHTML(feedText);
|
|
|
|
|
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+post.getUri()+"\">"+post.getFullName()+"</a>");
|
|
|
|
|
contentArea.setHTML(postText);
|
|
|
|
|
|
|
|
|
|
if (isAppPost) {
|
|
|
|
|
if (myUserInfo.isAdmin())
|
|
|
|
@ -374,25 +374,25 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
String formattedTime;
|
|
|
|
|
// TODO java.util.Calendar is not yet available in GWT
|
|
|
|
|
if(now.getYear() != feed.getTime().getYear())
|
|
|
|
|
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(feed.getTime());
|
|
|
|
|
if(now.getYear() != post.getTime().getYear())
|
|
|
|
|
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(post.getTime());
|
|
|
|
|
else
|
|
|
|
|
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(feed.getTime());
|
|
|
|
|
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(post.getTime());
|
|
|
|
|
|
|
|
|
|
timeArea.setText(formattedTime);
|
|
|
|
|
String formattedTimeWithYear = DateTimeFormat.getFormat("dd MMMM yyyy h:mm a ").format(feed.getTime());
|
|
|
|
|
String formattedTimeWithYear = DateTimeFormat.getFormat("dd MMMM yyyy h:mm a ").format(post.getTime());
|
|
|
|
|
timeArea.setTitle(formattedTimeWithYear);
|
|
|
|
|
if (! feed.getCommentsNo().equals("0")) {
|
|
|
|
|
if (! post.getCommentsNo().equals("0")) {
|
|
|
|
|
commentsNo.setVisible(true);
|
|
|
|
|
commentsNo.setText(feed.getCommentsNo());
|
|
|
|
|
commentsNo.setTitle(feed.getCommentsNo() + " people commented this.");
|
|
|
|
|
commentsNo.setText(post.getCommentsNo());
|
|
|
|
|
commentsNo.setTitle(post.getCommentsNo() + " people commented this.");
|
|
|
|
|
}
|
|
|
|
|
if (! feed.getLikesNo().equals("0")) {
|
|
|
|
|
if (! post.getLikesNo().equals("0")) {
|
|
|
|
|
likesNo.setVisible(true);
|
|
|
|
|
likesNo.setText(feed.getLikesNo());
|
|
|
|
|
likesNo.setText(post.getLikesNo());
|
|
|
|
|
likesNo.setTitle("Show People who have " + NewsFeedPanel.LIKED_LABEL + " this.");
|
|
|
|
|
}
|
|
|
|
|
totalComments = Integer.parseInt(feed.getCommentsNo());
|
|
|
|
|
totalComments = Integer.parseInt(post.getCommentsNo());
|
|
|
|
|
}
|
|
|
|
|
catch (NumberFormatException e) {
|
|
|
|
|
totalComments = 0;
|
|
|
|
@ -462,19 +462,12 @@ public class TweetTemplate extends Composite {
|
|
|
|
|
|
|
|
|
|
@UiHandler("seeMore")
|
|
|
|
|
void onSeeMoreClick(ClickEvent e) {
|
|
|
|
|
String feedText = myPost.getFeed().getDescription();
|
|
|
|
|
String postText = myPost.getFeed().getDescription();
|
|
|
|
|
//replace the < & and >
|
|
|
|
|
feedText = feedText.replaceAll("<","<").replaceAll(">",">");
|
|
|
|
|
feedText = feedText.replaceAll("&","&");
|
|
|
|
|
|
|
|
|
|
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contentArea.setHTML("<a class=\"link\"href=\"" + profilePageURL + "?"+
|
|
|
|
|
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
|
|
|
|
Encoder.encode(myPost.getFeed().getEntityId())+"\">"+
|
|
|
|
|
myPost.getFeed().getFullName()+"</a> " + feedText);
|
|
|
|
|
postText = postText.replaceAll("<","<").replaceAll(">",">");
|
|
|
|
|
postText = postText.replaceAll("&","&");
|
|
|
|
|
|
|
|
|
|
contentArea.setHTML(postText);
|
|
|
|
|
seeMore.setHTML("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|