aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java34
-rw-r--r--src/java/com/juick/http/www/UserThread.java9
-rw-r--r--web/style3.css9
3 files changed, 45 insertions, 7 deletions
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index 80b5a22e..11d20f32 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -52,7 +52,7 @@ public class PageTemplates {
out.println("<html>");
out.println("<head>");
out.println(" <title>" + title + "</title>");
- out.println(" <link rel=\"stylesheet\" href=\"//static.juick.com/style3.2013010301.css\"/>");
+ out.println(" <link rel=\"stylesheet\" href=\"//static.juick.com/style3.2013010500.css\"/>");
out.println(" <link rel=\"icon\" type=\"image/png\" href=\"//static.juick.com/favicon.png\"/>");
out.println(" <script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>");
out.println(" <script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\" defer=\"defer\" async=\"async\"></script>");
@@ -261,6 +261,29 @@ public class PageTemplates {
}
private static Pattern regexLinks2 = Pattern.compile("((?<=\\s)|(?<=\\A))([\\[\\{]|&lt;)((?:ht|f)tps?://(?:www\\.)?([^\\/\\s\\\"\\)\\!]+)/?(?:[^\\]\\}](?<!&gt;))*)([\\]\\}]|&gt;)");
+ public static String formatMessageCode(String msg) {
+ msg = msg.replaceAll("&", "&amp;");
+ msg = msg.replaceAll("<", "&lt;");
+ msg = msg.replaceAll(">", "&gt;");
+
+ // http://juick.com/last?page=2
+ // <a href="http://juick.com/last?page=2" rel="nofollow">http://juick.com/last?page=2</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))((?:ht|f)tps?://(?:www\\.)?([^\\/\\s\\n\\\"]+)/?[^\\s\\n\\\"]*)", "$1<a href=\"$2\" rel=\"nofollow\">$2</a>");
+
+ // (http://juick.com/last?page=2)
+ // (<a href="http://juick.com/last?page=2" rel="nofollow">http://juick.com/last?page=2</a>)
+ Matcher m = regexLinks2.matcher(msg);
+ StringBuffer sb = new StringBuffer();
+ while (m.find()) {
+ String url = m.group(3).replace(" ", "%20").replaceAll("\\s+", "");
+ m.appendReplacement(sb, "$1$2<a href=\"" + url + "\" rel=\"nofollow\">" + url + "</a>$5");
+ }
+ m.appendTail(sb);
+ msg = sb.toString();
+
+ return "<pre>" + msg + "</pre>";
+ }
+
public static String formatMessage(String msg) {
msg = msg.replaceAll("&", "&amp;");
msg = msg.replaceAll("<", "&lt;");
@@ -360,6 +383,13 @@ public class PageTemplates {
break;
}
+ String txt;
+ if (!msg.Tags.isEmpty() && msg.Tags.contains("code")) {
+ txt = formatMessageCode(msg.Text);
+ } else {
+ txt = formatMessage(msg.Text);
+ }
+
out.println(" <li id=\"msg-" + msg.MID + "\" class=\"msg\">");
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>");
@@ -367,7 +397,7 @@ public class PageTemplates {
if (msg.Place != null) {
out.println(" <div class=\"msg-place\"><a href=\"/places/" + msg.Place.pid + "\">" + msg.Place.name + "</a></div>");
}
- out.println(" <div class=\"msg-txt\">" + formatMessage(msg.Text) + "</div>");
+ out.print(" <div class=\"msg-txt\">" + txt + "</div>");
if (msg.AttachmentType != null) {
if (msg.AttachmentType.equals("jpg")) {
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index 9001bd17..3b315be2 100644
--- a/src/java/com/juick/http/www/UserThread.java
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -114,6 +114,13 @@ public class UserThread {
break;
}
+ String txt;
+ if (!msg.Tags.isEmpty() && msg.Tags.contains("code")) {
+ txt = PageTemplates.formatMessageCode(msg.Text);
+ } else {
+ txt = PageTemplates.formatMessage(msg.Text);
+ }
+
out.println("<ul>");
out.println(" <li id=\"msg-" + mid + "\" class=\"msg msgthread\">");
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
@@ -122,7 +129,7 @@ public class UserThread {
if (msg.Place != null) {
out.println(" <div class=\"msg-place\"><a href=\"/places/" + msg.Place.pid + "\">" + msg.Place.name + "</a></div>");
}
- out.println(" <div class=\"msg-txt\">" + PageTemplates.formatMessage(msg.Text) + "</div>");
+ out.println(" <div class=\"msg-txt\">" + txt + "</div>");
if (msg.AttachmentType != null) {
if (msg.AttachmentType.equals("jpg")) {
diff --git a/web/style3.css b/web/style3.css
index c79f6a66..adb686f0 100644
--- a/web/style3.css
+++ b/web/style3.css
@@ -1,4 +1,4 @@
-html,body,div,h1,h2,ul,li,form,input,textarea { margin: 0; padding: 0; }
+html,body,div,h1,h2,ul,li,form,input,textarea,pre { margin: 0; padding: 0; }
html,input { font-family: sans-serif; font-size: 12pt; }
html { background: #EEEEE5; color: #000; }
h1,h2 { font-weight: normal; }
@@ -6,6 +6,7 @@ ul { list-style-type: none; }
a { text-decoration: none; color: #069; }
img,hr { border: none; }
hr { height: 1px; background: #CCC; }
+pre { white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; }
#header, #topwrapper { width: 1000px; margin: 0 auto; }
#content, #footer { width: 600px; margin: 0 auto; }
@@ -44,7 +45,7 @@ hr { height: 1px; background: #CCC; }
.msg-ts, .msg-ts>a { color: #999; }
.msg-menu { margin: 0 0 0 6px; padding: 2px 0; }
.msg-menu img { vertical-align: top; }
-.msg-header { float: left; margin: 0 0 8px 10px; overflow: hidden; }
+.msg-header { float: left; margin: 0 0 8px 10px; max-width: 350px; overflow: hidden; }
.msg-place { clear: both; font-size: small; margin: 8px 0 8px 58px; }
.msg-place>a { color: #999; }
.msg-txt { clear: both; margin: 8px 0 8px 58px; overflow: hidden; }
@@ -140,8 +141,8 @@ blockquote { border-left: 1px dashed #CCC; margin: 10px 0 10px 10px; padding-lef
.msg-media,.msg-links,.msg-comment,.msg-comments,.msg-recomms { margin-left: 0px; }
.title2 h2 { font-size: large; }
-
+
.fix,.abs { position: static; }
#column { clear: both; margin: 0 3%; width: 44%; float: left; }
#rcol { float: left; width: 44%; margin: 20px 3% 0 3%; }
-} \ No newline at end of file
+}