fixed superposed textarea to include suggestions for hashtags was buggy when #test and test were both present

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@100472 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-06 20:34:38 +00:00
parent 921ea9647e
commit e7bc490bca
2 changed files with 4 additions and 3 deletions

View File

@ -603,7 +603,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
for (HashTagAndOccurrence wrapper : toSort) {
String hashtag = wrapper.getHashtag();
toReturn.add(new ItemBean(hashtag, hashtag, hashtag, null));
_log.trace(hashtag);
}
return toReturn;
}

View File

@ -96,11 +96,13 @@ public class TextTransfromUtils {
String taggedHTML = "<a class=\"link\" style=\"font-size:14px;\" href=\"?"+
new String(Base64.encodeBase64(GCubeSocialNetworking.HASHTAG_OID.getBytes()))+"="+
new String(Base64.encodeBase64(hashtag.getBytes()))+"\">"+hashtag+"</a>";
//TODO: does not work if the word is no preceeded by #
//dirty trick: double replace because \\boundaries do not accept # char
final String placeholder = "TO_REPLACE_4321234";
final String placeholder = "ñöñö-ñöñö";
String first = escapedFeedText.replaceAll("(?i)\\b"+hashtag.substring(1)+"\\b", placeholder);
escapedFeedText = first.replaceAll("#"+placeholder, taggedHTML);
//this is needed if there is a word equal to an hashtagged one without '#' e.g. #job and job
escapedFeedText = escapedFeedText.replaceAll(placeholder, hashtag.substring(1));
}
return escapedFeedText;
}