aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-09-02 12:38:52 +0300
committerGravatar Vitaly Takmazov2016-09-02 12:38:52 +0300
commit794678f641877c846f08b0d6b845366c8f340c69 (patch)
tree90e54d6082dfd68f560fea94cb72044433f8f44e /juick-www/src
parentd97bfe93f5f886ec4e85e0ac71889942d76511f8 (diff)
pm_sent template
Diffstat (limited to 'juick-www/src')
-rw-r--r--juick-www/src/main/java/com/juick/www/Main.java6
-rw-r--r--juick-www/src/main/java/com/juick/www/PM.java70
-rw-r--r--juick-www/src/main/resources/views/pm_sent.html36
3 files changed, 50 insertions, 62 deletions
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<com.juick.Message> 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<com.juick.Message> 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("<section id=\"content\">");
-
- out.println("<form action=\"/pm/send\" method=\"POST\" enctype=\"multipart/form-data\">");
- out.println("<div class=\"newpm\">");
- out.println(" <div class=\"newpm-to\">To: <input type=\"text\" name=\"uname\" placeholder=\"username\" value=\"" + uname + "\"/></div>");
- out.println(" <div class=\"newpm-body\"><textarea name=\"body\" rows=\"2\"></textarea></div>");
- out.println(" <div class=\"newpm-send\"><input type=\"submit\" value=\"OK\"/></div>");
- out.println("</div>");
- out.println("</form>");
-
- if (!msgs.isEmpty()) {
- out.println("<ul>");
- for (com.juick.Message msg : msgs) {
-
- String txt = Utils.formatMessage(msg.getText());
-
- out.println(" <li class=\"msg\">");
- out.println(" <div class=\"msg-avatar\"><img src=\"//i.juick.com/a/" + visitor.getUID() + ".png\"/></div>");
- out.println(" <div class=\"msg-cont\">");
- out.println(" <div class=\"msg-header\">→ <a href=\"/" + msg.getUser().getUName() + "/\">@" + msg.getUser().getUName() + "</a>:</div>");
- out.println(" <div class=\"msg-ts\"><a href=\"#\" onclick=\"return false\" title=\"" + PageTemplates.sdfSQL.format(msg.getDate()) + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.getDate()) + "</a></div>");
- out.println(" <div class=\"msg-txt\">" + txt + "</div>");
- out.println(" </div>");
- out.println(" </li>");
- }
- out.println("</ul>");
- }
-
- /*
- if (msgs.size() >= 20) {
- String nextpage = "?before=" + msgs.get(msgs.size() - 1);
- out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Читать дальше →</a></p>");
- }
- */
-
- out.println("</section>");
-
- PageTemplates.pageFooter(request, out, visitor, false);
- PageTemplates.pageEnd(out);
+ PebbleTemplate template = Utils.getEngine().getTemplate("views/pm_sent.html");
+ Map<String, Object> 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 %}
+<form action="/pm/send" method="POST" enctype="multipart/form-data">
+ <div class="newpm">
+ <div class="newpm-to">To: <input type="text" name="uname" placeholder="username" value="{{ uname }}"/></div>
+ <div class="newpm-body"><textarea name="body" rows="2"></textarea></div>
+ <div class="newpm-send"><input type="submit" value="OK"/></div>
+ </div>
+</form>
+{% if not msgs.isEmpty() %}
+<ul id="private-messages">
+ {% for msg in msgs %}
+ <li class="msg">
+ <div class="msg-cont">
+ <div class="msg-ts">{{ msg.getDate() }}</div>
+ <div class="msg-avatar">
+ <a href="/{{ msg.getUser().getUName() }}/">
+ <img src="//i.juick.com/a/{{ msg.getUser().getUID() }}.png" alt="{{ msg.getUser().getUName() }}"/>
+ </a>
+ </div>
+ <div class="msg-header">
+ <a href="/{{ msg.getUser().getUName() }}/">@{{ msg.getUser().getUName() }}</a>:
+ </div>
+ <div class="msg-txt">{{ msg.getText() | raw }}</div>
+
+
+
+ </div>
+ </li>
+ {% endfor %}
+</ul>
+{% endif %}
+{% endblock %}
+{% block "column" %}
+{% include "views/partial/homecolumn.html" %}
+{% endblock %} \ No newline at end of file