From af80956ec669cf48ea6423959b5a4d8f16385d6f Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 24 Oct 2015 19:35:41 +0300
Subject: moving to Gradle
---
src/main/java/com/juick/http/www/RSS.java | 113 ++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 src/main/java/com/juick/http/www/RSS.java
(limited to 'src/main/java/com/juick/http/www/RSS.java')
diff --git a/src/main/java/com/juick/http/www/RSS.java b/src/main/java/com/juick/http/www/RSS.java
new file mode 100644
index 00000000..ab96221e
--- /dev/null
+++ b/src/main/java/com/juick/http/www/RSS.java
@@ -0,0 +1,113 @@
+/*
+ * 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 .
+ */
+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 mids = MessagesQueries.getUserBlog(sql, uid, 0, 0);
+ if (mids.isEmpty()) {
+ response.sendError(404);
+ return;
+ }
+
+ ArrayList msgs = MessagesQueries.getMessages(sql, mids);
+
+ response.setContentType("application/rss+xml; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ out.println("");
+ out.println("");
+ out.println("");
+ out.println("");
+ out.println("" + uname + " - Juick");
+ out.println("http://juick.com/" + uname + "/");
+ out.println("The latest messages by @" + uname + " at Juick");
+ out.println("http://i.juick.com/a/" + uid + ".png" + uname + " - Juickhttp://juick.com/" + uname + "/");
+
+ Iterator i = msgs.iterator();
+ while (i.hasNext()) {
+ Message msg = i.next();
+
+ out.println("- ");
+ out.println("http://juick.com/" + msg.User.UName + "/" + msg.MID + "");
+ out.println("http://juick.com/" + msg.User.UName + "/" + msg.MID + "");
+
+ out.print("");
+ out.println("");
+
+ synchronized (sdfSQL) {
+ try {
+ Date date = sdfSQL.parse(msg.TimestampString);
+ out.println("" + sdfRSS.format(date) + "");
+ } catch (Exception e) {
+ System.err.println("PARSE EXCEPTION: " + msg.TimestampString);
+ }
+ }
+
+ out.println("http://juick.com/" + msg.User.UName + "/" + msg.MID + "");
+ if (!msg.Tags.isEmpty()) {
+ for (int n = 0; n < msg.Tags.size(); n++) {
+ out.println("" + msg.Tags.get(n) + "");
+ }
+ }
+ if (msg.AttachmentType != null) {
+ if (msg.AttachmentType.equals("jpg")) {
+ out.println("");
+ out.println("");
+ } else if (msg.AttachmentType.equals("png")) {
+ out.println("");
+ out.println("");
+ }
+ }
+ out.println("");
+ out.println("
");
+ }
+
+ out.println("");
+ } finally {
+ out.close();
+ }
+ }
+}
--
cgit v1.2.3