aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/Discover.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/juick/http/www/Discover.java')
-rw-r--r--src/java/com/juick/http/www/Discover.java19
1 files changed, 12 insertions, 7 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>");
}