aboutsummaryrefslogtreecommitdiff
path: root/src/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/juick/http/www/Discover.java19
-rw-r--r--src/java/com/juick/http/www/User.java14
2 files changed, 19 insertions, 14 deletions
diff --git a/src/java/com/juick/http/www/Discover.java b/src/java/com/juick/http/www/Discover.java
index ca6415ff..4fb4c9c0 100644
--- a/src/java/com/juick/http/www/Discover.java
+++ b/src/java/com/juick/http/www/Discover.java
@@ -22,6 +22,7 @@ import com.juick.server.TagQueries;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
+import java.net.URLEncoder;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Locale;
@@ -43,13 +44,13 @@ public class Discover {
String requesturi = request.getRequestURI();
- int paramTag = 0;
+ com.juick.Tag paramTag = null;
String paramTagStr = null;
if (requesturi.startsWith("/tag/")) {
paramTagStr = URLDecoder.decode(request.getRequestURI().substring(5), "UTF-8");
- paramTag = TagQueries.getTagID(sql, paramTagStr, false);
+ paramTag = TagQueries.getTag(sql, paramTagStr, false);
}
- if (paramTag == 0) {
+ if (paramTag == null) {
response.sendError(404);
return;
}
@@ -65,13 +66,17 @@ public class Discover {
int visitor_uid = visitor != null ? visitor.UID : 0;
- String title = "*" + Utils.encodeHTML(paramTagStr);
- ArrayList<Integer> mids = MessagesQueries.getTag(sql, paramTag, visitor_uid, paramBefore, (visitor == null) ? 40 : 20);
+ String title = "*" + Utils.encodeHTML(paramTag.Name);
+ ArrayList<Integer> mids = MessagesQueries.getTag(sql, paramTag.TID, visitor_uid, paramBefore, (visitor == null) ? 40 : 20);
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
try {
- PageTemplates.pageHead(out, title, null);
+ String canonical = "";
+ if (!paramTag.Name.equals(paramTagStr) && paramBefore == 0) {
+ canonical = "<link rel=\"canonical\" href=\"http://juick.com/tag/" + URLEncoder.encode(paramTag.Name, "UTF-8") + "\"/>";
+ }
+ PageTemplates.pageHead(out, title, canonical);
PageTemplates.pageNavigation(out, locale, visitor, null);
PageTemplates.pageHomeColumn(out, sql, visitor, locale);
@@ -85,7 +90,7 @@ public class Discover {
}
if (mids.size() >= 20) {
- String nextpage = "?before=" + mids.get(mids.size() - 1);
+ String nextpage = "/tag/" + URLEncoder.encode(paramTag.Name, "UTF-8") + "?before=" + mids.get(mids.size() - 1);
out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Older →</a></p>");
}
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
index 51a282d2..d29ae767 100644
--- a/src/java/com/juick/http/www/User.java
+++ b/src/java/com/juick/http/www/User.java
@@ -52,10 +52,10 @@ public class User {
String paramShow = request.getParameter("show");
- int paramTag = 0;
+ com.juick.Tag paramTag = null;
String paramTagStr = request.getParameter("tag");
if (paramTagStr != null && paramTagStr.length() < 64) {
- paramTag = TagQueries.getTagID(sql, paramTagStr, false);
+ paramTag = TagQueries.getTag(sql, paramTagStr, false);
}
int paramBefore = 0;
@@ -82,9 +82,9 @@ public class User {
}
if (paramShow == null) {
- if (paramTag > 0) {
- title += "*" + Utils.encodeHTML(paramTagStr);
- mids = MessagesQueries.getUserTag(sql, user.UID, paramTag, privacy, paramBefore);
+ if (paramTag != null) {
+ title += "*" + Utils.encodeHTML(paramTag.Name);
+ mids = MessagesQueries.getUserTag(sql, user.UID, paramTag.TID, privacy, paramBefore);
} else if (paramSearch != null) {
title += rb.getString("(Menu) Search") + ": " + Utils.encodeHTML(paramSearch);
mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.UID, Utils.encodeSphinx(paramSearch), privacy, paramBefore);
@@ -123,8 +123,8 @@ public class User {
if (paramShow != null) {
nextpage += "&amp;show=" + paramShow;
}
- if (paramTag > 0) {
- nextpage += "&amp;tag=" + URLEncoder.encode(paramTagStr, "UTF-8");
+ if (paramTag != null) {
+ nextpage += "&amp;tag=" + URLEncoder.encode(paramTag.Name, "UTF-8");
}
if (paramSearch != null) {
nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, "UTF-8");