aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/WebApp.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/WebApp.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/WebApp.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/juick-www/src/main/java/com/juick/www/WebApp.java b/juick-www/src/main/java/com/juick/www/WebApp.java
index c3437c0b..f254b5fa 100644
--- a/juick-www/src/main/java/com/juick/www/WebApp.java
+++ b/juick-www/src/main/java/com/juick/www/WebApp.java
@@ -16,13 +16,17 @@
*/
package com.juick.www;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.Message;
import com.juick.Tag;
import com.juick.service.TagService;
+import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.XmppException;
import rocks.xmpp.core.session.Extension;
@@ -32,8 +36,11 @@ import rocks.xmpp.extensions.component.accept.ExternalComponent;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.stream.Stream;
@@ -41,6 +48,7 @@ import java.util.stream.Stream;
*
* @author Ugnich Anton
*/
+@Component
public class WebApp implements DisposableBean {
private static Logger logger = LoggerFactory.getLogger(WebApp.class);
@@ -48,7 +56,8 @@ public class WebApp implements DisposableBean {
@Inject
private TagService tagService;
-
+ @Inject
+ private ObjectMapper jsonMapper;
@Value("${xmpp_host:localhost}")
private String xmppHost;
@Value("${xmpp_password:secret}")
@@ -64,7 +73,13 @@ public class WebApp implements DisposableBean {
private String styleUrl;
@PostConstruct
- public void init() {
+ public void init() throws IOException {
+ String manifestString = IOUtils.toString(getClass().getClassLoader().
+ getResourceAsStream("manifest.json"), StandardCharsets.UTF_8);
+ HashMap<String, String> manifest = jsonMapper.readValue(manifestString,
+ new TypeReference<HashMap<String, String>>() {});
+ scriptsUrl = manifest.get("scripts.js");
+ styleUrl = manifest.get("style.css");
if (!isXmppDisabled) {
setupXmppComponent(Jid.of(xmppJid),
xmppPassword, xmppPort);
@@ -128,12 +143,4 @@ public class WebApp implements DisposableBean {
public String getScriptsUrl() {
return scriptsUrl;
}
-
- public void setScriptsUrl(String scriptsUrl) {
- this.scriptsUrl = scriptsUrl;
- }
-
- public void setStyleUrl(String styleUrl) {
- this.styleUrl = styleUrl;
- }
}