From 9c2dfaa34c93ee5bf24093c95cff7d4b77b4ecb5 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Thu, 4 May 2017 12:10:26 +0300
Subject: juick-www: pebble message formatter extension
---
.../www/configuration/WwwServletConfiguration.java | 2 ++
.../pebble/extension/FormatterExtension.java | 18 +++++++++++++
.../extension/filters/FormatMessageFilter.java | 31 ++++++++++++++++++++++
juick-www/src/main/webapp/WEB-INF/views/index.html | 2 +-
.../src/main/webapp/WEB-INF/views/pm_inbox.html | 2 +-
.../src/main/webapp/WEB-INF/views/pm_sent.html | 2 +-
6 files changed, 54 insertions(+), 3 deletions(-)
create mode 100644 juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
create mode 100644 juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java
(limited to 'juick-www/src')
diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
index 944fbb80..43ca37db 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
@@ -1,6 +1,7 @@
package com.juick.www.configuration;
import com.mitchellbosecke.pebble.PebbleEngine;
+import com.mitchellbosecke.pebble.extension.FormatterExtension;
import com.mitchellbosecke.pebble.loader.Loader;
import com.mitchellbosecke.pebble.loader.ServletLoader;
import com.mitchellbosecke.pebble.spring4.PebbleViewResolver;
@@ -85,6 +86,7 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
return new PebbleEngine.Builder()
.loader(this.templateLoader())
.extension(springExtension())
+ .extension(new FormatterExtension())
.strictVariables(true)
.build();
}
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
new file mode 100644
index 00000000..e26b5c20
--- /dev/null
+++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
@@ -0,0 +1,18 @@
+package com.mitchellbosecke.pebble.extension;
+
+import com.mitchellbosecke.pebble.extension.filters.FormatMessageFilter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by vitalyster on 04.05.2017.
+ */
+public class FormatterExtension extends AbstractExtension {
+ @Override
+ public Map
{{ msg.getText() | raw }}
+{{ msg | formatMessage }}
{%if msg.AttachmentType is not empty %} {% endif %} diff --git a/juick-www/src/main/webapp/WEB-INF/views/pm_inbox.html b/juick-www/src/main/webapp/WEB-INF/views/pm_inbox.html index fa339a25..d360a651 100644 --- a/juick-www/src/main/webapp/WEB-INF/views/pm_inbox.html +++ b/juick-www/src/main/webapp/WEB-INF/views/pm_inbox.html @@ -15,7 +15,7 @@