aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com')
-rw-r--r--juick-www/src/main/java/com/juick/www/Errors.java29
1 files changed, 11 insertions, 18 deletions
diff --git a/juick-www/src/main/java/com/juick/www/Errors.java b/juick-www/src/main/java/com/juick/www/Errors.java
index 4ab10229..85ebf1a6 100644
--- a/juick-www/src/main/java/com/juick/www/Errors.java
+++ b/juick-www/src/main/java/com/juick/www/Errors.java
@@ -1,5 +1,7 @@
package com.juick.www;
+import com.mitchellbosecke.pebble.error.PebbleException;
+import com.mitchellbosecke.pebble.template.PebbleTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
@@ -7,6 +9,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
/**
*
@@ -14,29 +18,18 @@ import java.io.PrintWriter;
*/
public class Errors {
- public static String tagsHTML = null;
-
public static void doGet404(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
-
- if (tagsHTML == null) {
- tagsHTML = PageTemplates.formatPopularTags(sql, 80);
- }
-
response.setStatus(404);
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
- PageTemplates.pageHead(out, visitor, "404 Страница не найдена", null);
- PageTemplates.pageNavigation(out, visitor, null);
- PageTemplates.pageHomeColumn(out, sql, visitor);
-
- out.println("<section id=\"content\">");
- out.println("<h1>Страница не найдена</h1>");
- out.println("<p>Сожалеем, но страницу с этим адресом удалил её автор, либо её никогда не существовало.</p>");
- out.println("</section>");
-
- PageTemplates.pageFooter(request, out, visitor, false);
- PageTemplates.pageEnd(out);
+ PebbleTemplate template = Utils.getEngine().getTemplate("views/404.html");
+ Map<String, Object> context = new HashMap<>();
+ context.put("title", "404 Страница не найдена");
+ context.put("visitor", visitor);
+ template.evaluate(out, context);
+ } catch (PebbleException e) {
+ // log("pebble exception", e);
}
}
}