diff --git a/.classpath b/.classpath index 1221d1e..b52e78d 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index d986405..3e6b0b7 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,6 +1,6 @@ -#Tue Apr 16 18:09:11 CEST 2013 +#Sun Jun 02 00:32:02 CEST 2013 eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-0.3.0-SNAPSHOT +lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-0.4.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index a7f437d..fe006d9 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -5,9 +5,6 @@ - - uses - diff --git a/pom.xml b/pom.xml index fed865f..89cc431 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user share-updates war - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT gCube Share Updates Portlet @@ -137,11 +137,6 @@ jtidy r938 - - org.jsoup - jsoup - 1.6.1 - net.eliasbalasis tibcopagebus4gwt diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateService.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateService.java index 5260558..92036cf 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateService.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateService.java @@ -17,7 +17,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; */ @RemoteServiceRelativePath("shareupdateServlet") public interface ShareUpdateService extends RemoteService { - ClientFeed share(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, String linkTitle, String linkDesc, String url, String urlThumbnail, String host); + ClientFeed share(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, String linkTitle, String linkDesc, String url, String urlThumbnail, String host, ArrayList mentionedUsers); UserSettings getUserSettings(); diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateServiceAsync.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateServiceAsync.java index 2facd55..f5e4dcf 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdateServiceAsync.java @@ -17,7 +17,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback; public interface ShareUpdateServiceAsync { void share(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, String linkTitle, String linkDesc, String url, - String urlThumbnail, String host, AsyncCallback callback); + String urlThumbnail, String host, ArrayList mentionedUsers, + AsyncCallback callback); void checkLink(String linkToCheck, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/ContentEditDiv.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/ContentEditDiv.java deleted file mode 100644 index 734483b..0000000 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/ContentEditDiv.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.gcube.portlets.user.shareupdates.client.elements; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.HasText; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -public class ContentEditDiv extends HTML implements HasText { - - public ContentEditDiv() { - super(DOM.createElement("div")); - //important to make it act like a textarea - DOM.setElementAttribute(getElement(), "contentEditable", "true"); - DOM.setElementAttribute(getElement(), "id", "mycontentEditableElement"); - } - - public ContentEditDiv(String text) { - this(); - setText(text); - } - - public void setEnabled(boolean enabled) { - DOM.setElementPropertyBoolean(getElement(), "disabled", !enabled); - } - - - public static native void setEndOfContenteditable() /*-{ - var contentEditableElement = $doc.getElementById("mycontentEditableElement"); - var range,selection; - if($doc.createRange)//Firefox, Chrome, Opera, Safari, IE 9+ - { - range = $doc.createRange();//Create a range (a range is a like the selection but invisible) - range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range - range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start - selection = $wnd.getSelection();//get the selection object (allows you to change selection) - selection.removeAllRanges();//remove any selections already made - selection.addRange(range);//make the range you have just created the visible selection - } - else if($doc.selection)//IE 8 and lower - { - range = $doc.body.createTextRange();//Create a range (a range is a like the selection but invisible) - range.moveToElementText(contentEditableElement);//Select the entire contents of the element with the range - range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start - range.select();//Select the range (make it the visible selection - } - }-*/; -} diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/Span.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/Span.java deleted file mode 100644 index 712b488..0000000 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/Span.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.gcube.portlets.user.shareupdates.client.elements; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.HasText; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -public class Span extends HTML implements HasText { - - public Span() { - super(DOM.createElement("span")); - } - - public Span(String text) { - this(); - setText(text); - } - - public void setCSSClassName(String className) { - getElement().addClassName(className); - } -} diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/TagBox.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/TagBox.java deleted file mode 100644 index f14083f..0000000 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/elements/TagBox.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.gcube.portlets.user.shareupdates.client.elements; - -import com.google.gwt.user.client.ui.TextBox; - -/** - * - * @author Massimiliano Assante, ISTI-CNR - * - */ -public class TagBox extends TextBox { - - public TagBox() { - } - - public TagBox(String text) { - super(); - this.setStylePrimaryName("user-token"); - getElement().setAttribute("value", text); - //random heuristic, the "i" and "l" char occupies very few px :) - int iCounter = 14 - 2*(text.split("i").length + (text.split("l").length)); - setWidth((text.length()*6+iCounter)+"px"); - setReadOnly(true); - } -} diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java index b19bd9b..439a28c 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.shareupdates.client.form; +import java.util.ArrayList; + import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapter; import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException; @@ -43,7 +45,7 @@ public class ShareUpdateForm extends Composite { .create(ShareUpdateService.class); final PageBusAdapter pageBusAdapter = new PageBusAdapter(); - protected final static String SHARE_UPDATE_TEXT = "Share an update or paste a link, use “@” and then start typing to tag people"; + protected final static String SHARE_UPDATE_TEXT = "Share an update or paste a link, use “@” to mention someone"; protected final static String ERROR_UPDATE_TEXT = "Looks like empty to me!"; private final static String LISTBOX_LEVEL = " - "; @@ -65,6 +67,18 @@ public class ShareUpdateForm extends Composite { } @UiField HTMLPanel mainPanel; + @UiField + LinkPlaceholder preview; + + @UiField + Button submitButton; + + @UiField + Image avatarImage; + + @UiField SuperPosedTextArea shareTextArea; + + @UiField ListBox privacyLevel = new ListBox(false); UserInfo myUserInfo; @@ -110,18 +124,6 @@ public class ShareUpdateForm extends Composite { } }); } - @UiField - LinkPlaceholder preview; - - @UiField - Button submitButton; - - @UiField - Image avatarImage; - - @UiField SmartTextArea shareTextArea; - - @UiField ListBox privacyLevel = new ListBox(false); @UiHandler("shareTextArea") void onShareUpdateClick(ClickEvent e) { @@ -147,8 +149,8 @@ public class ShareUpdateForm extends Composite { return; } //then you can post, but pass html - String toPost = shareTextArea.getHTML().trim(); - postTweet(toPost); + String toPost = shareTextArea.getText(); + postTweet(toPost, shareTextArea.getMentionedUsers()); } }); } @@ -156,15 +158,13 @@ public class ShareUpdateForm extends Composite { * * @param textToPost */ - private void postTweet(String textToPost) { - //String toShare = escapeHtml(textToPost); - String toShare = textToPost; - if (! checkTextLength(new HTML(toShare).getText())) { //need to convert it to text + private void postTweet(String textToPost, ArrayList mentionedUsers) { + String toShare = escapeHtml(textToPost); + if (! checkTextLength(toShare)) { Window.alert("We found a single word containing more than 50 chars and it's not a link, is it meaningful?"); return; } - submitButton.setEnabled(false); shareTextArea.setEnabled(false); @@ -186,11 +186,12 @@ public class ShareUpdateForm extends Composite { linkUrlThumbnail = myLinkPreviewer.getUrlThumbnail(); linkHost = myLinkPreviewer.getHost(); } - shareupdateService.share(toShare, FeedType.TWEET, getPrivacyLevel(), vreId, linkTitle, linkDescription, linkUrl, linkUrlThumbnail, linkHost, new AsyncCallback() { + shareupdateService.share(toShare, FeedType.TWEET, getPrivacyLevel(), vreId, linkTitle, linkDescription, linkUrl, linkUrlThumbnail, linkHost, mentionedUsers, new AsyncCallback() { public void onFailure(Throwable caught) { submitButton.setEnabled(true); shareTextArea.setEnabled(true); shareTextArea.setText(SHARE_UPDATE_TEXT); + shareTextArea.cleanHighlihterDiv(); preview.clear(); myLinkPreviewer = null; } @@ -199,6 +200,7 @@ public class ShareUpdateForm extends Composite { submitButton.setEnabled(true); shareTextArea.setEnabled(true); shareTextArea.setText(SHARE_UPDATE_TEXT); + shareTextArea.cleanHighlihterDiv(); preview.clear(); myLinkPreviewer = null; if (feed == null) @@ -232,6 +234,7 @@ public class ShareUpdateForm extends Composite { + /** * Escape an html string. Escaping data received from the client helps to * prevent cross-site script vulnerabilities. diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.ui.xml b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.ui.xml index 191d282..101bb8b 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.ui.xml +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.ui.xml @@ -4,16 +4,22 @@ - - @@ -25,7 +31,8 @@ diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/SmartTextArea.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/SuperPosedTextArea.java similarity index 54% rename from src/main/java/org/gcube/portlets/user/shareupdates/client/form/SmartTextArea.java rename to src/main/java/org/gcube/portlets/user/shareupdates/client/form/SuperPosedTextArea.java index 442ba2d..90da174 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/SmartTextArea.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/SuperPosedTextArea.java @@ -11,47 +11,39 @@ import org.gcube.portlets.user.pickuser.client.events.PickedUserEventHandler; import org.gcube.portlets.user.pickuser.shared.PickingUser; import org.gcube.portlets.user.shareupdates.client.ShareUpdateService; import org.gcube.portlets.user.shareupdates.client.ShareUpdateServiceAsync; -import org.gcube.portlets.user.shareupdates.client.elements.ContentEditDiv; -import org.gcube.portlets.user.shareupdates.client.elements.Span; -import org.gcube.portlets.user.shareupdates.client.elements.TagBox; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.DomEvent; +import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.TextArea; /** - * - * @author Massimiliano Assante, ISTI-CNR - * - * SmartTextArea allows pasting of links with preview generation and tagging of people + * @author massi * */ -public class SmartTextArea extends ContentEditDiv { - /** - * Create a remote service proxy to talk to the server-side Greeting service. - */ +public class SuperPosedTextArea extends TextArea { private final ShareUpdateServiceAsync shareupdateService = GWT .create(ShareUpdateService.class); private final HandlerManager eventBus = new HandlerManager(null); + PickUsersDialog pickUserDlg; public final static int ARROW_UP = 38; public final static int ARROW_DOWN = 40; - PickUsersDialog pickUserDlg; + + private ArrayList mentionedUsers = new ArrayList(); + /** * */ - public SmartTextArea() { - bind(); + public SuperPosedTextArea() { sinkEvents(Event.ONPASTE); - sinkEvents(Event.ONCONTEXTMENU); sinkEvents(Event.ONKEYUP); + sinkEvents(Event.ONCONTEXTMENU); sinkEvents(Event.ONKEYDOWN); shareupdateService.getPortalUsers(new AsyncCallback>() { @@ -65,56 +57,43 @@ public class SmartTextArea extends ContentEditDiv { public void onFailure(Throwable caught) { } }); + DOM.setElementAttribute(getElement(), "id", "postTextArea"); + bind(); } /** - * events binder + * @param element */ - private void bind() { - eventBus.addHandler(PickedUserEvent.TYPE, new PickedUserEventHandler() { - @Override - public void onSelectedUser(PickedUserEvent event) { - String[] toSplit = getHTML().split("@"); //get the interesting part - TagBox span = new TagBox(event.getSelectedUser().getFullName()); - setHTML(toSplit[0]); - getElement().appendChild(span.getElement()); - getElement().appendChild(new Span(" ").getElement()); - setEndOfContenteditable(); - } - }); + public SuperPosedTextArea(Element element) { + super(element); } /** - * paste and other events overridden + * paste event overridden */ public void onBrowserEvent(Event event) { super.onBrowserEvent(event); switch (event.getTypeInt()) { case Event.ONPASTE: { - final String before = getHTML(); + final String before = getText(); GWT.log("BEFORE:" + before); Timer t = new Timer() { @Override public void run() { - String toCheck = extractLink(getHTML()); - if (toCheck != null) { - GWT.log("toCheck1:" + toCheck); - ShareUpdateForm.get().checkLink(new HTML(toCheck).getText()); - String sanitized = before + toCheck; - setHTML(sanitized); - setEndOfContenteditable(); - } + String toCheck = getText().replaceAll(before, ""); + ShareUpdateForm.get().checkLink(toCheck); } }; t.schedule(100); break; } - case Event.ONCONTEXTMENU: { - removeSampleText(); + case Event.ONKEYUP: { + injectInDiv(getText()); + pickUserDlg.onKeyUp(event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+65, getText()); break; } - case Event.ONKEYUP: { - pickUserDlg.onKeyUp(event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+65, getText()); + case Event.ONCONTEXTMENU: { + removeSampleText(); break; } case Event.ONKEYDOWN: { @@ -129,47 +108,61 @@ public class SmartTextArea extends ContentEditDiv { break; } } - DomEvent.fireNativeEvent(event, this, this.getElement()); } - - /** - * extract the pasted link - * @param textToCheck - * @return null if there's no link present - */ - private String extractLink(String textToCheck) { - GWT.log("textToCheck:" + textToCheck); - String [] parts = textToCheck.split("\\s"); - // Attempt to convert each item into an URL. - for( String item : parts ) { - if (item.startsWith("http")) { - return item; - } - if (item.startsWith("href") || item.startsWith("HREF")) { //this is for (damned) safari because sometimes it paste , and all the double spaces by the html version   + text = textAreaText.replaceAll("(\r\n|\n)","
"); + text = text.replaceAll("\\s\\s","  "); + + for (String mentionedUser : mentionedUsers) { + text = text.replaceAll(mentionedUser,""+mentionedUser+""); + } + // re-inject the processed text into the div + DOM.getElementById("highlighter").setInnerHTML(text); + } + + /** + * events binder + */ + private void bind() { + eventBus.addHandler(PickedUserEvent.TYPE, new PickedUserEventHandler() { + @Override + public void onSelectedUser(PickedUserEvent event) { + + String toAdd = event.getSelectedUser().getFullName(); + mentionedUsers.add(toAdd); + + String[] toSplit = getText().split("@"); //get the preceeding part + + setText(toSplit[0]+toAdd); + Element highDiv = DOM.getElementById("highlighter"); + + String[] htmlToSplit = highDiv.getInnerHTML().split("@"); //get the preceeding part + String highLightedUser = ""+toAdd+""; + highDiv.setInnerHTML(htmlToSplit[0]+highLightedUser); + } + }); + } + + public ArrayList getMentionedUsers() { + ArrayList toReturn = new ArrayList(); + for (String mentionedUser : mentionedUsers) { + if (getText().contains(mentionedUser)) + toReturn.add(mentionedUser); + } + GWT.log(toReturn.toString()); + return mentionedUsers; + } } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index 3eccafd..56aebea 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -24,7 +24,6 @@ import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; -import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.shared.ClientFeed; @@ -52,10 +51,7 @@ import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; import org.gcube.vomanagement.usermanagement.model.GroupModel; import org.gcube.vomanagement.usermanagement.model.UserModel; -import org.htmlcleaner.HtmlCleaner; -import org.htmlcleaner.TagNode; import org.htmlparser.beans.StringBean; -import org.jsoup.Jsoup; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.w3c.tidy.Tidy; @@ -128,9 +124,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar /** * */ - public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel, String vreId, String linkTitle, String linkDesc, String url, String urlThumbnail, String host) { + public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel, String vreId, String linkTitle, String linkDesc, String url, String urlThumbnail, String host, ArrayList mentionedUserFullNames) { - String escapedFeedText = transformPost(postText); + String escapedFeedText = escapeHtml(postText); ASLSession session = getASLSession(); String username = session.getUsername(); String email = username+"@isti.cnr.it"; @@ -188,7 +184,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar toShare.getUriThumbnail(), toShare.getLinkHost()); //send the notification to the mentioned users - ArrayList mentionedUserIds = getSelectedUserIds(extractPeopleTags(postText)); + ArrayList mentionedUserIds = getSelectedUserIds(mentionedUserFullNames); if (mentionedUserIds != null && mentionedUserIds.size() > 0) { NotificationsManager nm = new ApplicationNotificationsManager(session); Thread thread = new Thread(new MentionNotificationsThread(toShare.getKey(), escapedFeedText, nm, mentionedUserIds)); @@ -198,84 +194,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar return cf; } - - /** - * this method is used when posting a feed - * - * It converts the tagged people etc etc - * - * @return a String ready to be posted - */ - private String transformPost(String postText) { - ArrayList taggedPeople = extractPeopleTags(postText); - if (taggedPeople == null || taggedPeople.size() == 0) { //there are no tagged people, remove html and go - String escapedFeedText = escapeHtml(postText); //here escape html to avoid xss attacks - String html = "" + escapedFeedText + ""; - return html2text(html); - } else { - _log.trace("postText curing: " + postText); - // this is needed to reconstruct the place of people tags, selfexplaining i think - int i = 0; - while (postText.contains(""; - String postWithPlaceHolders = html2text(html); - _log.trace("before cure: " + postWithPlaceHolders); - /* - * at this point you have the html removed and somthing like "text text text _usr_place_holder_[0] text text text _usr_place_holder_[1]" - * you need to replace _usr_place_holder_[i](s) with the people with same index in taggedPeople ArrayList - */ - String escapedFeedText = escapeHtml(postWithPlaceHolders); //here escape html to avoid xss attacks - ArrayList usernames = getSelectedUserIds(taggedPeople); - i = 0; - for (String tagged : taggedPeople) { - String username = (i < usernames.size()) ? usernames.get(i) : ""; - String taggedHTML = "
"+tagged+" "; - escapedFeedText = escapedFeedText.replace("_usr_place_holder_["+i+"]", taggedHTML); - i++; - } - _log.trace("After cure: " + escapedFeedText); - return escapedFeedText; - } - } - - /** - * this method extractPeopleTags from the user post - * @param postText text with tagged people: txt .. extractPeopleTags(String postText) { - ArrayList toReturn = new ArrayList(); - String toParse = "" + postText + ""; - - HtmlCleaner cleaner = new HtmlCleaner(); - // parse the string HTML - TagNode pageData = cleaner.clean(toParse); - TagNode[] inputElements = pageData.getElementsByName("input", true); - if (inputElements != null) { - for (int i = 0; i < inputElements.length; i++) { - System.out.println("Found input " + inputElements[i].getAttributes().get("value")); - toReturn.add(inputElements[i].getAttributes().get("value")); - } - } else { - _log.trace("No person tags in this post"); - } - return toReturn; - } - /** - * remove all the html and leave the text - * @param html - * @return the text inside the html - */ - private static String html2text(String html) { - return Jsoup.parse(html).text().replace(" "," "); - } @@ -297,13 +215,11 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar * @return the text with the clickable url in it */ public String transformUrls(String feedText) { - System.out.println("transformUrls" + feedText); StringBuilder sb = new StringBuilder(); // separate input by spaces ( URLs have no spaces ) String [] parts = feedText.split("\\s"); // Attempt to convert each item into an URL. for (int i = 0; i < parts.length; i++) { - System.out.println("part: " + parts[i]); if (parts[i].startsWith("http")) { try { URL url = new URL(parts[i]); diff --git a/src/main/webapp/ShareUpdates.css b/src/main/webapp/ShareUpdates.css index 12bc375..2628a13 100644 --- a/src/main/webapp/ShareUpdates.css +++ b/src/main/webapp/ShareUpdates.css @@ -1,14 +1,88 @@ +/* Superpose TextArea and Highlight DIV trick starts here */ +#supercontainer { + position: relative; +} + +#highlighterContainer { + position: absolute; + left: 0; + top: 0; + cursor: text; + width: 525px; + height: 54px; +} + +#inputContainer { + position: relative; +} + +#highlighter { + padding: 4px 2px; + color: #ffffff; + background-color: #FFF; + margin: 0px; + font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, + sans-serif; + font-size: 13px; + letter-spacing: normal; + line-height: normal; + + border: 1px solid transparent; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + + width: 525px; + height: 54px; + + word-wrap: break-word; /* this is very important when usere paste long links*/ +} + + +.postTextArea { + padding: 4px 2px; + color: #999; + background-color: transparent; + + margin: 0px; + font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, + sans-serif; + font-size: 13px; + letter-spacing: normal; + line-height: normal; + + border: 1px solid #999; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + + width: 525px; + height: 54px; +} + +.highlightedUser { + background-color: #D8DFEA !important; +} + +/* DIV trick ends here */ + + +.darker-color { + color: #333; + background-color: transparent; + transition: background .25s ease-in-out; + -moz-transition: background .25s ease-in-out; + -webkit-transition: background .25s ease-in-out; +} + .framed { margin: 0 0 10px; padding: 10px; margin: 0px 5px; - background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom; - border-radius: 6px !important; - -moz-border-radius: 6px !important; - -webkit-border-radius: 6px !important; - + -moz-border-radius: 6px !important; + -webkit-border-radius: 6px !important; border: 1px solid #DBDBDB; } @@ -16,6 +90,7 @@ text-align: right; padding-top: 2px; } + .member-photo { display: block; padding: 2px; @@ -34,11 +109,11 @@ } .hide-description { - margin-top: 5px; + margin-top: 5px; } -.hide-description span label{ - padding-left: 5px; +.hide-description span label { + padding-left: 5px; } .linkpreview-bgcolor { @@ -125,35 +200,6 @@ a.link:hover { padding-bottom: 3px; } -.shareContainer-in { - padding-left: 5px; -} - -.post-message { - height: 54px; - color: #999; - font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, - sans-serif; - font-size: 13px; - padding: 4px 2px; - width: 525px; - border: 1px solid #999; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - border-radius: 4px; - letter-spacing: normal; - max-height: 54px; - overflow: auto; -} - -.dark-color { - color: #333; - background-color: #FFF; - transition: background .25s ease-in-out; - -moz-transition: background .25s ease-in-out; - -webkit-transition: background .25s ease-in-out; -} - .toolsContainer { padding-top: 3px; width: 600px; @@ -189,13 +235,12 @@ a.link:hover { } /* smart textarea */ - -#mycontentEditableElement input[type="text"] { +#mycontentEditableElement input[type="text"] { font-family: verdana, arial, sans-serif; font-size: 11px; padding: 1px 3px; color: #1C2A47; - border: 1px solid #9DACCC; + border: 1px solid #9DACCC; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; diff --git a/src/main/webapp/ShareUpdates.html b/src/main/webapp/ShareUpdates.html index 92c34e6..0a30930 100644 --- a/src/main/webapp/ShareUpdates.html +++ b/src/main/webapp/ShareUpdates.html @@ -6,18 +6,30 @@ - - + + - - - - + + + + - - + + + + - -
- + + + +
+ diff --git a/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp b/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp index 5b6223a..8414dc6 100644 --- a/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp @@ -16,4 +16,14 @@ + + +
\ No newline at end of file diff --git a/src/main/webapp/js/jquery.autosize.js b/src/main/webapp/js/jquery.autosize.js new file mode 100644 index 0000000..370279e --- /dev/null +++ b/src/main/webapp/js/jquery.autosize.js @@ -0,0 +1,187 @@ +/*! + jQuery Autosize v1.16.12 + (c) 2013 Jack Moore - jacklmoore.com + updated: 2013-05-31 + license: http://www.opensource.org/licenses/mit-license.php +*/ + +(function ($) { + var + defaults = { + className: 'autosizejs', + append: '', + callback: false + }, + hidden = 'hidden', + borderBox = 'border-box', + lineHeight = 'lineHeight', + + // border:0 is unnecessary, but avoids a bug in FireFox on OSX + copy = '
+ -
- +
+
+
+
+
+
+
+ +
privacy level: - +