aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-03-10 20:28:32 +0300
committerGravatar Vitaly Takmazov2017-03-10 20:28:32 +0300
commitd05897b15a84b3ac51fe8f123baeef948a371e24 (patch)
tree0944f6fc2fa162bf82b1ff933abc2f117682db48 /juick-www/src/main/java/com/juick/www
parentc189636002c3245633730969ac00206e19a8105e (diff)
juick-www: using @RequestParam to match juick-api
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/User.java24
1 files changed, 9 insertions, 15 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/User.java b/juick-www/src/main/java/com/juick/www/controllers/User.java
index 1ab7e691..e84c8913 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/User.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/User.java
@@ -30,6 +30,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
import javax.inject.Inject;
import javax.servlet.ServletException;
@@ -62,7 +63,8 @@ public class User {
@RequestMapping("/{uname}/")
protected void doGetBlog(HttpServletRequest request, HttpServletResponse response,
- @PathVariable String uname) throws IOException {
+ @PathVariable String uname,
+ @RequestParam(required = false, defaultValue = "0") Integer before) throws IOException {
com.juick.User user = userService.getUserByName(uname);
com.juick.User visitor = webApp.getVisitorUser(request, response);
if (user.isBanned()) {
@@ -90,14 +92,6 @@ public class User {
}
}
- int paramBefore = 0;
- String paramBeforeStr = request.getParameter("before");
- if (paramBeforeStr != null) {
- try {
- paramBefore = Integer.parseInt(paramBeforeStr);
- } catch (NumberFormatException e) {
- }
- }
String paramSearch = request.getParameter("search");
if (paramSearch != null && paramSearch.length() > 64) {
@@ -117,20 +111,20 @@ public class User {
if (paramShow == null) {
if (paramTag != null) {
title = "Блог " + user.getName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName());
- mids = messagesService.getUserTag(user.getUid(), paramTag.TID, privacy, paramBefore);
+ mids = messagesService.getUserTag(user.getUid(), paramTag.TID, privacy, before);
} else if (paramSearch != null) {
title = "Блог " + user.getName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch);
- mids = messagesService.getUserSearch(user.getUid(), Utils.encodeSphinx(paramSearch), privacy, paramBefore);
+ mids = messagesService.getUserSearch(user.getUid(), Utils.encodeSphinx(paramSearch), privacy, before);
} else {
title = "Блог " + user.getName();
- mids = messagesService.getUserBlog(user.getUid(), privacy, paramBefore);
+ mids = messagesService.getUserBlog(user.getUid(), privacy, before);
}
} else if (paramShow.equals("recomm")) {
title = "Рекомендации " + user.getName();
- mids = messagesService.getUserRecommendations(user.getUid(), paramBefore);
+ mids = messagesService.getUserRecommendations(user.getUid(), before);
} else if (paramShow.equals("photos")) {
title = "Фотографии " + user.getName();
- mids = messagesService.getUserPhotos(user.getUid(), privacy, paramBefore);
+ mids = messagesService.getUserPhotos(user.getUid(), privacy, before);
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
@@ -142,7 +136,7 @@ public class User {
user.getName() + "\" href=\"//rss.juick.com/" + user.getName() + "/blog\"/>";
if (paramTag != null && tagService.getTagNoIndex(paramTag.TID)) {
head += "<meta name=\"robots\" content=\"noindex,nofollow\"/>";
- } else if (paramBefore > 0 || paramShow != null) {
+ } else if (before > 0 || paramShow != null) {
head += "<meta name=\"robots\" content=\"noindex\"/>";
}
templates.pageHead(out, visitor, title, head);