From 36f0bb5b96e2b0200150b41214cd3e49d41a38c2 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 13 Jan 2017 14:42:45 +0300
Subject: juick-www: fix rss controller
---
.../main/java/com/juick/www/controllers/RSS.java | 7 ++--
juick-www/src/main/webapp/WEB-INF/layouts/rss.html | 38 ++++++++++++++++++++++
juick-www/src/main/webapp/WEB-INF/layouts/rss.xml | 38 ----------------------
3 files changed, 43 insertions(+), 40 deletions(-)
create mode 100644 juick-www/src/main/webapp/WEB-INF/layouts/rss.html
delete mode 100644 juick-www/src/main/webapp/WEB-INF/layouts/rss.xml
(limited to 'juick-www')
diff --git a/juick-www/src/main/java/com/juick/www/controllers/RSS.java b/juick-www/src/main/java/com/juick/www/controllers/RSS.java
index 79fd8e67..b48ae2d0 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/RSS.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/RSS.java
@@ -23,12 +23,14 @@ import com.juick.service.MessagesService;
import com.juick.service.UserService;
import com.juick.util.DateFormattersHolder;
import com.juick.util.MessageUtils;
+import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;
@@ -45,7 +47,8 @@ public class RSS {
@Inject
MessagesService messagesService;
- @RequestMapping(value = "/rss/{uname}", method = RequestMethod.GET)
+ @RequestMapping(value = "/rss/{uname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_ATOM_XML_VALUE)
+ @ResponseBody
protected String doGet(JdbcTemplate sql, HttpServletResponse response,
@PathVariable String uname, ModelMap model) {
int uid = userService.getUIDbyName(uname);
@@ -61,6 +64,6 @@ public class RSS {
model.addAttribute("user", msgs.stream().findFirst().get().getUser());
model.addAttribute("msgs", msgs);
model.addAttribute("sdfRSS", DateFormattersHolder.getRssFormatterInstance());
- return "webapp/WEB-INF/layouts/rss";
+ return "layouts/rss";
}
}
diff --git a/juick-www/src/main/webapp/WEB-INF/layouts/rss.html b/juick-www/src/main/webapp/WEB-INF/layouts/rss.html
new file mode 100644
index 00000000..23866c8a
--- /dev/null
+++ b/juick-www/src/main/webapp/WEB-INF/layouts/rss.html
@@ -0,0 +1,38 @@
+
+
+
+
+ {{ user.getName() }} - Juick
+ http://juick.com/{{ user.getName() }}/
+ The latest messages by @{{ user.getName() }} at Juick
+
+ http://i.juick.com/a/{{ user.getUid() }}.png
+ {{ user.getName() }} - Juick
+ http://juick.com/{{ user.getName() }}/
+
+ {% for msg in msgs %}
+ -
+ http://juick.com/{{ msg.getUser().getName() }}/{{ msg.getMid() }}
+ http://juick.com/{{ msg.getUser().getName() }}/{{ msg.getMid() }}
+
+
+ {{ sdfRSS.format(msg.getDate()) }}
+ http://juick.com/{{ msg.getUser().getName() }}/{{ msg.getMid() }}
+ {% for tag in msg.getTags() %}
+ {{ tag }}
+ {% endfor %}
+ {% if msg.getAttachmentType() is not empty %}
+ {% if msg.getAttachmentType() == "jpg" %}
+
+
+ {% elseif msg.getAttachmentType() == "png" %}
+
+
+ {% endif %}
+ {% endif %}
+
+
+ {% endfor %}
+
+
diff --git a/juick-www/src/main/webapp/WEB-INF/layouts/rss.xml b/juick-www/src/main/webapp/WEB-INF/layouts/rss.xml
deleted file mode 100644
index 23866c8a..00000000
--- a/juick-www/src/main/webapp/WEB-INF/layouts/rss.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
- {{ user.getName() }} - Juick
- http://juick.com/{{ user.getName() }}/
- The latest messages by @{{ user.getName() }} at Juick
-
- http://i.juick.com/a/{{ user.getUid() }}.png
- {{ user.getName() }} - Juick
- http://juick.com/{{ user.getName() }}/
-
- {% for msg in msgs %}
- -
- http://juick.com/{{ msg.getUser().getName() }}/{{ msg.getMid() }}
- http://juick.com/{{ msg.getUser().getName() }}/{{ msg.getMid() }}
-
-
- {{ sdfRSS.format(msg.getDate()) }}
- http://juick.com/{{ msg.getUser().getName() }}/{{ msg.getMid() }}
- {% for tag in msg.getTags() %}
- {{ tag }}
- {% endfor %}
- {% if msg.getAttachmentType() is not empty %}
- {% if msg.getAttachmentType() == "jpg" %}
-
-
- {% elseif msg.getAttachmentType() == "png" %}
-
-
- {% endif %}
- {% endif %}
-
-
- {% endfor %}
-
-
--
cgit v1.2.3