aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/http/www/RSS.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/http/www/RSS.java')
-rw-r--r--src/main/java/com/juick/http/www/RSS.java101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/main/java/com/juick/http/www/RSS.java b/src/main/java/com/juick/http/www/RSS.java
deleted file mode 100644
index 349743b5..00000000
--- a/src/main/java/com/juick/http/www/RSS.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2013, ugnich
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.http.www;
-
-import com.juick.Message;
-import com.juick.server.MessagesQueries;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- *
- * @author ugnich
- */
-public class RSS {
-
- private static final SimpleDateFormat sdfRSS = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
-
- protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, int uid, String uname) throws ServletException, IOException {
- List<Integer> mids = MessagesQueries.getUserBlog(sql, uid, 0, 0);
- if (mids.isEmpty()) {
- response.sendError(404);
- return;
- }
-
- List<Message> msgs = MessagesQueries.getMessages(sql, mids);
-
- response.setContentType("application/rss+xml; charset=UTF-8");
- try (PrintWriter out = response.getWriter()) {
- out.println("<?xml version='1.0' encoding='utf-8'?>");
- out.println("<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:slash='http://purl.org/rss/1.0/modules/slash/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:media='http://search.yahoo.com/mrss/' xmlns:juick='http://juick.com/'>");
- out.println("<channel>");
- out.println("<atom:link href='http://rss.juick.com/" + uname + "/blog' rel='self' type='application/rss+xml'/>");
- out.println("<title>" + uname + " - Juick</title>");
- out.println("<link>http://juick.com/" + uname + "/</link>");
- out.println("<description>The latest messages by @" + uname + " at Juick</description>");
- out.println("<image><url>http://i.juick.com/a/" + uid + ".png</url><title>" + uname + " - Juick</title><link>http://juick.com/" + uname + "/</link></image>");
-
- for (Message msg : msgs) {
- out.println("<item>");
- out.println("<link>http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "</link>");
- out.println("<guid>http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "</guid>");
-
- out.print("<title><![CDATA[@" + msg.getUser().getUName() + ":");
- if (!msg.Tags.isEmpty()) {
- for (int n = 0; n < msg.Tags.size(); n++) {
- out.print(" *" + msg.Tags.get(n));
- }
- }
- out.println("]]></title>");
- out.println("<description><![CDATA[" + PageTemplates.formatMessage(msg.getText()) + "]]></description>");
-
- Date date = msg.getDate();
- out.println("<pubDate>" + sdfRSS.format(date) + "</pubDate>");
-
-
- out.println("<comments>http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + "</comments>");
- if (!msg.Tags.isEmpty()) {
- for (int n = 0; n < msg.Tags.size(); n++) {
- out.println("<category>" + msg.Tags.get(n) + "</category>");
- }
- }
- if (msg.AttachmentType != null) {
- if (msg.AttachmentType.equals("jpg")) {
- out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.getMID() + ".jpg' type='image/jpeg'/>");
- out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.getMID() + ".jpg'/>");
- } else if (msg.AttachmentType.equals("png")) {
- out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.getMID() + ".png' type='image/png'/>");
- out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.getMID() + ".png'/>");
- }
- }
- out.println("<juick:user uid='" + msg.getUser().getUID() + "'/>");
- out.println("</item>");
- }
-
- out.println("</channel></rss>");
- }
- }
-}