From 794678f641877c846f08b0d6b845366c8f340c69 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 2 Sep 2016 12:38:52 +0300 Subject: pm_sent template --- juick-www/src/main/java/com/juick/www/Main.java | 6 ++- juick-www/src/main/java/com/juick/www/PM.java | 70 ++++--------------------- juick-www/src/main/resources/views/pm_sent.html | 36 +++++++++++++ 3 files changed, 50 insertions(+), 62 deletions(-) create mode 100644 juick-www/src/main/resources/views/pm_sent.html (limited to 'juick-www') diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index 1e755ca3..c67eced0 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -190,7 +190,11 @@ public class Main extends HttpServlet implements Stream.StreamListener { } break; case "/pm/sent": - pm.doGetSent(sql, request, response, visitor); + try { + pm.doGetSent(sql, request, response, visitor); + } catch (PebbleException e) { + log("pebble exception", e); + } break; default: Errors.doGet404(sql, request, response); diff --git a/juick-www/src/main/java/com/juick/www/PM.java b/juick-www/src/main/java/com/juick/www/PM.java index f912f0b6..7380ca8f 100644 --- a/juick-www/src/main/java/com/juick/www/PM.java +++ b/juick-www/src/main/java/com/juick/www/PM.java @@ -39,8 +39,6 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import static com.juick.www.PageTemplates.sape; - /** * * @author Ugnich Anton @@ -53,7 +51,6 @@ public class PM { String title = "PM: Inbox"; List msgs = PMQueries.getLastPMInbox(sql, visitor.getUID()); msgs.forEach(m -> m.setText(Utils.formatMessage(m.getText()))); - String links = sape.getPageLinks(request.getRequestURI(), request.getCookies()).render(); response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { PebbleTemplate template = Utils.getEngine().getTemplate("views/pm_inbox.html"); @@ -62,25 +59,11 @@ public class PM { context.put("visitor", visitor); context.put("msgs", msgs); context.put("tags", TagQueries.getPopularTags(sql)); - if (visitor.getUID() == 0) { - context.put("showAdv", true); - context.put("links", links); - } template.evaluate(out, context); } } - protected void doGetSent(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { - /* - int paramBefore = 0; - String paramBeforeStr = request.getParameter("before"); - if (paramBeforeStr != null) { - try { - paramBefore = Integer.parseInt(paramBeforeStr); - } catch (NumberFormatException e) { - } - } - */ + protected void doGetSent(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException { String title = "PM: Sent"; List msgs = PMQueries.getLastPMSent(sql, visitor.getUID()); @@ -92,49 +75,14 @@ public class PM { response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { - PageTemplates.pageHead(out, visitor, title, null); - PageTemplates.pageNavigation(out, visitor, null); - PageTemplates.pageHomeColumn(out, sql, visitor); - - out.println("
"); - - out.println("
"); - out.println("
"); - out.println("
To:
"); - out.println("
"); - out.println("
"); - out.println("
"); - out.println("
"); - - if (!msgs.isEmpty()) { - out.println(""); - } - - /* - if (msgs.size() >= 20) { - String nextpage = "?before=" + msgs.get(msgs.size() - 1); - out.println("

Читать дальше →

"); - } - */ - - out.println("
"); - - PageTemplates.pageFooter(request, out, visitor, false); - PageTemplates.pageEnd(out); + PebbleTemplate template = Utils.getEngine().getTemplate("views/pm_sent.html"); + Map context = new HashMap<>(); + context.put("title", title); + context.put("visitor", visitor); + context.put("msgs", msgs); + context.put("tags", TagQueries.getPopularTags(sql)); + context.put("uname", uname); + template.evaluate(out, context); } } diff --git a/juick-www/src/main/resources/views/pm_sent.html b/juick-www/src/main/resources/views/pm_sent.html new file mode 100644 index 00000000..fc65a4fd --- /dev/null +++ b/juick-www/src/main/resources/views/pm_sent.html @@ -0,0 +1,36 @@ +{% extends "layouts/content.html" %} +{% block content %} +
+
+
To:
+
+
+
+
+{% if not msgs.isEmpty() %} + +{% endif %} +{% endblock %} +{% block "column" %} +{% include "views/partial/homecolumn.html" %} +{% endblock %} \ No newline at end of file -- cgit v1.2.3