aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java5
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java8
-rw-r--r--juick-www/src/test/java/com/juick/www/WebAppTests.java19
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java6
4 files changed, 23 insertions, 15 deletions
diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
index d77bbdad..3a97c4be 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
@@ -19,7 +19,6 @@ package com.juick.www.configuration;
import com.juick.configuration.DataConfiguration;
import com.juick.configuration.SearchConfiguration;
-import com.juick.server.configuration.BaseWebConfiguration;
import org.apache.commons.codec.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -36,7 +35,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[]{
- BaseWebConfiguration.class,
+ WwwServletConfiguration.class,
WwwAppConfiguration.class,
DataConfiguration.class,
SearchConfiguration.class,
@@ -47,7 +46,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni
@Override
protected Class<?>[] getServletConfigClasses() {
- return new Class<?>[]{WwwServletConfiguration.class};
+ return null;
}
@Override
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 7a5de28c..cad8cfdb 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
@@ -29,8 +29,10 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.Ordered;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.ViewResolver;
+import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.resource.PathResourceResolver;
@@ -50,7 +52,7 @@ public class WwwServletConfiguration extends BaseWebConfiguration {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.setOrder(0);
+ registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
registry.addResourceHandler(
"/scripts*.js*",
"/style*.css*",
@@ -65,6 +67,10 @@ public class WwwServletConfiguration extends BaseWebConfiguration {
.addResourceLocations("/static/")
.setCacheControl(CacheControl.maxAge(30, TimeUnit.DAYS).mustRevalidate().cachePublic());
}
+ @Override
+ public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
+ configurer.enable();
+ }
@Inject
private ServletContext servletContext;
diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java
index c5e9eb6a..0aba7e37 100644
--- a/juick-www/src/test/java/com/juick/www/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java
@@ -37,6 +37,7 @@ import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import org.apache.commons.text.StringEscapeUtils;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -101,6 +102,11 @@ public class WebAppTests {
public void setup() {
webClient = MockMvcWebClientBuilder.webAppContextSetup(this.wac).build();
webClient.getOptions().setJavaScriptEnabled(false);
+ webClient.getOptions().setCssEnabled(false);
+ }
+ @After
+ public void teardown() {
+ webClient.close();
}
@Test
@@ -204,7 +210,8 @@ public class WebAppTests {
assertThat(output, equalTo("<a href=\"/ugnich/?tag=%26gt%3B_%26lt%3B\">&gt;_&lt;</a>"));
}
- public DomElement fetchMeta(HtmlPage page, String name) throws IOException {
+ public DomElement fetchMeta(String url, String name) throws IOException {
+ HtmlPage page = webClient.getPage(url);
DomElement emptyMeta = new DomElement("", "meta", null, null);
return page.getElementsByTagName("meta").stream()
.filter(t -> t.getAttribute("name").equals(name)).findFirst().orElse(emptyMeta);
@@ -237,15 +244,13 @@ public class WebAppTests {
when(messagesService.canViewThread(1, 0)).thenReturn(true);
when(messagesService.getMessage(1)).thenReturn(msg);
- HtmlPage threadPage = webClient.getPage("http://localhost:8080/ugnich/1");
-
- assertThat(fetchMeta(threadPage, "twitter:card")
+ assertThat(fetchMeta("http://localhost:8080/ugnich/1", "twitter:card")
.getAttribute("content"), equalTo("summary"));
msg.setAttachmentType("png");
- assertThat(fetchMeta(threadPage, "twitter:card")
+ assertThat(fetchMeta("http://localhost:8080/ugnich/1", "twitter:card")
.getAttribute("content"), equalTo("summary_large_image"));
- assertThat(fetchMeta(threadPage, "og:description")
- .getAttribute("content"),
+ assertThat(fetchMeta("http://localhost:8080/ugnich/1", "og:description")
+ .getAttribute("content"),
startsWith(StringEscapeUtils.escapeHtml4(MessageUtils.getMessageHashTags(msg))));
}
diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java
index ff879bee..a124c461 100644
--- a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java
+++ b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java
@@ -32,9 +32,9 @@ import rocks.xmpp.core.stanza.AbstractIQHandler;
import rocks.xmpp.core.stanza.model.IQ;
import rocks.xmpp.core.stanza.model.Message;
import rocks.xmpp.core.stanza.model.Stanza;
-import rocks.xmpp.core.stanza.model.client.ClientIQ;
import rocks.xmpp.core.stanza.model.client.ClientMessage;
import rocks.xmpp.core.stanza.model.errors.Condition;
+import rocks.xmpp.extensions.caps.model.EntityCapabilities;
import rocks.xmpp.extensions.component.accept.ExternalComponent;
import rocks.xmpp.extensions.filetransfer.FileTransfer;
import rocks.xmpp.extensions.filetransfer.FileTransferManager;
@@ -84,9 +84,7 @@ public class XMPPConnection implements AutoCloseable {
router = ExternalComponent.create(componentName, password, xmpp.getSession().getConfiguration(), "localhost", componentPort);
PingManager pingManager = router.getManager(PingManager.class);
pingManager.setEnabled(true);
- MessageDeliveryReceiptsManager messageDeliveryReceiptsManager =
- router.getManager(MessageDeliveryReceiptsManager.class);
- messageDeliveryReceiptsManager.setEnabled(true);
+ router.disableFeature(EntityCapabilities.NAMESPACE);
VCard vCard = new VCard();
vCard.setFormattedName("Juick");
try {