aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/RSS.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2015-10-24 19:35:41 +0300
committerGravatar Vitaly Takmazov2015-10-24 19:35:41 +0300
commitaf80956ec669cf48ea6423959b5a4d8f16385d6f (patch)
tree3589c77814185cd8bf43408f46793aaf8917c27a /src/java/com/juick/http/www/RSS.java
parent7a96f3f799e2e2358be246b3e9f0aa412ef28a2d (diff)
moving to Gradle
Diffstat (limited to 'src/java/com/juick/http/www/RSS.java')
-rw-r--r--src/java/com/juick/http/www/RSS.java113
1 files changed, 0 insertions, 113 deletions
diff --git a/src/java/com/juick/http/www/RSS.java b/src/java/com/juick/http/www/RSS.java
deleted file mode 100644
index ab96221e..00000000
--- a/src/java/com/juick/http/www/RSS.java
+++ /dev/null
@@ -1,113 +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 java.io.IOException;
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- *
- * @author ugnich
- */
-public class RSS {
-
- private static final SimpleDateFormat sdfSQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- private static final SimpleDateFormat sdfRSS = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
-
- protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response, int uid, String uname) throws ServletException, IOException {
- ArrayList<Integer> mids = MessagesQueries.getUserBlog(sql, uid, 0, 0);
- if (mids.isEmpty()) {
- response.sendError(404);
- return;
- }
-
- ArrayList<Message> msgs = MessagesQueries.getMessages(sql, mids);
-
- response.setContentType("application/rss+xml; charset=UTF-8");
- PrintWriter out = response.getWriter();
- try {
- 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>");
-
- Iterator<Message> i = msgs.iterator();
- while (i.hasNext()) {
- Message msg = i.next();
-
- out.println("<item>");
- out.println("<link>http://juick.com/" + msg.User.UName + "/" + msg.MID + "</link>");
- out.println("<guid>http://juick.com/" + msg.User.UName + "/" + msg.MID + "</guid>");
-
- out.print("<title><![CDATA[@" + msg.User.UName + ":");
- 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.Text) + "]]></description>");
-
- synchronized (sdfSQL) {
- try {
- Date date = sdfSQL.parse(msg.TimestampString);
- out.println("<pubDate>" + sdfRSS.format(date) + "</pubDate>");
- } catch (Exception e) {
- System.err.println("PARSE EXCEPTION: " + msg.TimestampString);
- }
- }
-
- out.println("<comments>http://juick.com/" + msg.User.UName + "/" + msg.MID + "</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.MID + ".jpg' type='image/jpeg'/>");
- out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.MID + ".jpg'/>");
- } else if (msg.AttachmentType.equals("png")) {
- out.println("<media:content url='http://i.juick.com/photos-1024/" + msg.MID + ".png' type='image/png'/>");
- out.println("<media:thumbnail url='http://i.juick.com/ps/" + msg.MID + ".png'/>");
- }
- }
- out.println("<juick:user uid='" + msg.User.UID + "'/>");
- out.println("</item>");
- }
-
- out.println("</channel></rss>");
- } finally {
- out.close();
- }
- }
-}