From 21847edc8b557f795bc6e64ca1f84c23252ab314 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Fri, 25 Jul 2014 18:14:56 +0700 Subject: Reader --- src/java/com/juick/http/www/Main.java | 3 + src/java/com/juick/http/www/PageTemplates.java | 3 +- src/java/com/juick/http/www/Reader.java | 78 ++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/java/com/juick/http/www/Reader.java (limited to 'src') diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java index e0c84734..1d5e64d3 100644 --- a/src/java/com/juick/http/www/Main.java +++ b/src/java/com/juick/http/www/Main.java @@ -49,6 +49,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { Stream xmpp; Home home = new Home(); Discover discover = new Discover(); + Reader reader = new Reader(); PM pm = new PM(); Login login = new Login(); Help help = new Help(); @@ -150,6 +151,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); home.doGet(sql, sqlSearch, request, response, visitor); } + } else if (uri.equals("/reader")) { + reader.doGet(sql, request, response); } else if (uri.equals("/post")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); if (visitor != null) { diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index da4c0b81..f0a87c42 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -51,7 +51,7 @@ public class PageTemplates { out.println(""); out.print(""); out.print(""); - out.print(""); + out.print(""); out.print(""); out.print(""); if (headers != null) { @@ -74,6 +74,7 @@ public class PageTemplates { out.print(" "); out.print("
. + */ +package com.juick.http.www; + +import com.juick.server.MessagesQueries; +import com.juick.server.TagQueries; +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author Ugnich Anton + */ +public class Reader { + + protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + com.juick.User visitor = Utils.getVisitorUser(sql, request, response); + + response.setContentType("text/html; charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + String head = ""; + PageTemplates.pageHead(out, "Ссылки", head); + PageTemplates.pageNavigation(out, visitor, null); + out.println("
"); + + out.println("
    "); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT rss_id,url,title FROM reader_links ORDER BY ts DESC LIMIT 100"); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + out.println("
  • " + rs.getString(3) + "
  • "); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + + out.println("
"); + + out.println("
"); + PageTemplates.pageFooter(request, out, visitor, true); + PageTemplates.pageEnd(out); + } finally { + out.close(); + } + } +} -- cgit v1.2.3