aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/www')
-rw-r--r--src/main/java/com/juick/www/WebApp.java58
1 files changed, 7 insertions, 51 deletions
diff --git a/src/main/java/com/juick/www/WebApp.java b/src/main/java/com/juick/www/WebApp.java
index a7c5eb8b..cf9570aa 100644
--- a/src/main/java/com/juick/www/WebApp.java
+++ b/src/main/java/com/juick/www/WebApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2024, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -16,34 +16,22 @@
*/
package com.juick.www;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import javax.inject.Inject;
-
-import com.juick.model.Message;
import com.juick.model.Tag;
import com.juick.model.User;
import com.juick.service.TagService;
-import io.pebbletemplates.pebble.PebbleEngine;
-import io.pebbletemplates.pebble.template.PebbleTemplate;
-
import jakarta.annotation.PostConstruct;
-
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import org.springframework.web.util.UriComponentsBuilder;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Stream;
+
/**
*
* @author Ugnich Anton
@@ -54,8 +42,6 @@ public class WebApp {
private TagService tagService;
@Inject
private ResourceUrlProvider resourceUrlProvider;
- @Inject
- private PebbleEngine pebbleEngine;
@Value("${img_url:http://localhost:8080/i/}")
private String baseImagesUri;
UriComponentsBuilder avatarBuilder;
@@ -105,34 +91,4 @@ public class WebApp {
avatarBuilder.replacePath(getAvatarWebPath(user));
return avatarBuilder.build().toUriString();
}
-
- public Optional<String> renderPlaintext(String body, String messageUrl) {
- PebbleTemplate noteTemplate = pebbleEngine.getTemplate("email/plaintext");
- Map<String, Object> context = new HashMap<>();
- context.put("messageBody", body);
- context.put("messageUrl", messageUrl);
- try {
- Writer writer = new StringWriter();
- noteTemplate.evaluate(writer, context);
- return Optional.of(writer.toString());
- } catch (IOException e) {
- return Optional.empty();
- }
- }
-
- public Optional<String> renderHtml(String body, String messageUrl, Message msg, String hash) {
- PebbleTemplate noteTemplate = pebbleEngine.getTemplate("email/html");
- Map<String, Object> context = new HashMap<>();
- context.put("messageBody", body);
- context.put("messageUrl", messageUrl);
- context.put("msg", msg);
- context.put("hash", hash);
- try {
- Writer writer = new StringWriter();
- noteTemplate.evaluate(writer, context);
- return Optional.of(writer.toString());
- } catch (IOException e) {
- return Optional.empty();
- }
- }
}