diff options
author | Ugnich Anton | 2012-12-26 14:30:03 +0700 |
---|---|---|
committer | Ugnich Anton | 2012-12-26 14:30:03 +0700 |
commit | 9adb555fe41f6322310be1fea406d9d8d44acafe (patch) | |
tree | bcc81e6bebdb607ec5f0651379adf78e97214f16 /src/java/com/juick/http/www/Blogs.java | |
parent | f4bbf04c16efada11d1d371f0b6abc2f30780bc7 (diff) |
New tags URLs
Diffstat (limited to 'src/java/com/juick/http/www/Blogs.java')
-rw-r--r-- | src/java/com/juick/http/www/Blogs.java | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java index 0250a157..fb0657ad 100644 --- a/src/java/com/juick/http/www/Blogs.java +++ b/src/java/com/juick/http/www/Blogs.java @@ -22,6 +22,7 @@ import com.juick.server.TagQueries; import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.net.URLEncoder; import java.sql.Connection; import java.sql.PreparedStatement; @@ -42,6 +43,16 @@ import javax.servlet.http.HttpServletResponse; public class Blogs { protected void doGet(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String paramTagStrQuery = request.getParameter("tag"); + if (paramTagStrQuery != null) { + String url = "/tag/" + URLEncoder.encode(paramTagStrQuery, "UTF-8"); + String paramBeforeStr = request.getParameter("before"); + if (paramBeforeStr != null) { + url += "?before=" + paramBeforeStr; + } + Utils.sendPermanentRedirect(response, url); + } + com.juick.User visitor = Utils.getVisitorUser(sql, request); Locale locale = request.getLocale(); ResourceBundle rb = ResourceBundle.getBundle("Blogs", locale); @@ -52,9 +63,14 @@ public class Blogs { String paramShow = request.getParameter("show"); int paramTag = 0; - String paramTagStr = request.getParameter("tag"); - if (paramTagStr != null && paramTagStr.length() < 64) { + String paramTagStr = null; + if (request.getRequestURI().startsWith("/tag/")) { + paramTagStr = URLDecoder.decode(request.getRequestURI().substring(5), "UTF-8"); paramTag = TagQueries.getTagID(sql, paramTagStr, false); + if (paramTag == 0) { + response.sendError(404); + return; + } } int paramBefore = 0; @@ -135,20 +151,10 @@ public class Blogs { out.println("<div id=\"wrapper\">"); out.println("<div id=\"content\">"); - //PageTemplates.pageFilters(out, locale, visitor); - if (mids.size() > 0) { - /* - if (paramShow != null && paramShow.equals("photos")) { - PageTemplates.printPhotos(out, sql, mids, locale); - } else { - */ out.println("<ul>"); - PageTemplates.printMessages(out, sql, mids, visitor, locale); + PageTemplates.printMessages(out, sql, null, mids, visitor, locale); out.println("</ul>"); - /* - } - */ } if (mids.size() == 20) { @@ -156,9 +162,6 @@ public class Blogs { if (paramShow != null) { nextpage += "&show=" + paramShow; } - if (paramTag > 0) { - nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8"); - } out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Older →</a></p>"); } @@ -169,20 +172,20 @@ public class Blogs { out.println("<div id=\"column\" class=\"stickya\">"); if (visitor != null) { out.println(" <ul>"); - out.println(" <li><a href=\"?show=my\">" + rb.getString("My feed") + "</a></li>"); - out.println(" <li><a href=\"?show=private\">" + rb.getString("Private") + "</a></li>"); - out.println(" <li><a href=\"?show=discuss\">" + rb.getString("Discussions") + "</a></li>"); - out.println(" <li><a href=\"?show=recommended\">" + rb.getString("Recommended") + "</a></li>"); + out.println(" <li><a href=\"/?show=my\">" + rb.getString("My feed") + "</a></li>"); + out.println(" <li><a href=\"/?show=private\">" + rb.getString("Private") + "</a></li>"); + out.println(" <li><a href=\"/?show=discuss\">" + rb.getString("Discussions") + "</a></li>"); + out.println(" <li><a href=\"/?show=recommended\">" + rb.getString("Recommended") + "</a></li>"); out.println(" </ul>"); out.println(" <hr/>"); } out.println(" <ul>"); - out.println(" <li><a href=\"?\">" + rb.getString("All messages") + "</a></li>"); - out.println(" <li><a href=\"?show=top\">" + rb.getString("Popular") + "</a></li>"); - out.println(" <li><a href=\"?show=photos\">" + rb.getString("With photos") + "</a></li>"); + out.println(" <li><a href=\"/\">" + rb.getString("All messages") + "</a></li>"); + out.println(" <li><a href=\"/?show=top\">" + rb.getString("Popular") + "</a></li>"); + out.println(" <li><a href=\"/?show=photos\">" + rb.getString("With photos") + "</a></li>"); out.println(" </ul>"); out.println(" <hr/>"); - out.println(" <p>" + getTags(sql, 30) + "</p>"); + out.println(" <p>" + getTags(sql, 36) + "</p>"); out.println("</div>"); out.println("<div id=\"rcol\"></div>"); @@ -229,7 +232,7 @@ public class Blogs { for (int i = 0; i < cnt; i++) { String tag = Utils.encodeHTML(tags[i].Name); try { - tag = "<a href=\"/?tag=" + URLEncoder.encode(tags[i].Name, "UTF-8") + "\">" + tag + "</a>"; + tag = "<a href=\"/tag/" + URLEncoder.encode(tags[i].Name, "UTF-8") + "\">" + tag + "</a>"; } catch (UnsupportedEncodingException e) { } |