aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main/java/com/juick/util
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-08-23 00:47:37 +0300
committerGravatar Vitaly Takmazov2017-08-23 01:08:02 +0300
commit3e4807157e3c244820dd4d5149997970530e4fcb (patch)
tree6603098f912a0119f57e37ed94658141ff09e85e /juick-core/src/main/java/com/juick/util
parent007951db3ae9f9ba89a726960b0ef1639d63f3df (diff)
www: Twitter Cards
Diffstat (limited to 'juick-core/src/main/java/com/juick/util')
-rw-r--r--juick-core/src/main/java/com/juick/util/MessageUtils.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/juick-core/src/main/java/com/juick/util/MessageUtils.java b/juick-core/src/main/java/com/juick/util/MessageUtils.java
index a901fac1..03b677d4 100644
--- a/juick-core/src/main/java/com/juick/util/MessageUtils.java
+++ b/juick-core/src/main/java/com/juick/util/MessageUtils.java
@@ -17,8 +17,13 @@
package com.juick.util;
+import com.juick.Message;
+import com.juick.Tag;
+import org.apache.commons.codec.CharEncoding;
import org.apache.commons.lang3.StringUtils;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -137,4 +142,22 @@ public class MessageUtils {
msg = msg.replaceAll("\n", "<br/>\n");
return msg;
}
+
+ public static String getMessageHashTags(final Message jmsg) {
+ StringBuilder hashtags = new StringBuilder();
+ for (Tag tag : jmsg.getTags()) {
+ hashtags.append("#").append(tag).append(" ");
+ }
+ return hashtags.toString();
+ }
+
+ // TODO: check if it is really needed
+ public static String percentEncode(final String s) {
+ String ret = StringUtils.EMPTY;
+ try {
+ ret = URLEncoder.encode(s, CharEncoding.UTF_8).replace("+", "%20").replace("*", "%2A").replace("%7E", "~");
+ } catch (UnsupportedEncodingException e) {
+ }
+ return ret;
+ }
}