diff --git a/cms-content/pom.xml b/cms-content/pom.xml index c8dbd1bc..87ba1cfb 100644 --- a/cms-content/pom.xml +++ b/cms-content/pom.xml @@ -27,10 +27,6 @@ lombok provided - - org.apache.commons - commons-text - com.github.slugify slugify diff --git a/cms-content/src/main/java/com/condation/cms/content/DefaultContentRenderer.java b/cms-content/src/main/java/com/condation/cms/content/DefaultContentRenderer.java index 1495c4f9..94be6b60 100644 --- a/cms-content/src/main/java/com/condation/cms/content/DefaultContentRenderer.java +++ b/cms-content/src/main/java/com/condation/cms/content/DefaultContentRenderer.java @@ -70,7 +70,6 @@ import java.util.function.Supplier; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.text.StringSubstitutor; /** * diff --git a/cms-content/src/main/java/com/condation/cms/content/pipeline/ContentPipeline.java b/cms-content/src/main/java/com/condation/cms/content/pipeline/ContentPipeline.java index 80c74bf5..494106bd 100644 --- a/cms-content/src/main/java/com/condation/cms/content/pipeline/ContentPipeline.java +++ b/cms-content/src/main/java/com/condation/cms/content/pipeline/ContentPipeline.java @@ -23,18 +23,14 @@ */ import com.condation.cms.api.feature.Feature; -import com.condation.cms.api.feature.features.AuthFeature; import com.condation.cms.api.hooks.FilterContext; import com.condation.cms.api.hooks.HookSystem; import com.condation.cms.api.hooks.Hooks; import com.condation.cms.api.request.RequestContext; import com.condation.cms.content.RenderContext; -import java.util.HashMap; -import java.util.Map; import java.util.function.Function; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; -import org.apache.commons.text.StringSubstitutor; /** * @@ -47,7 +43,6 @@ public class ContentPipeline { private final RequestContext requestContext; void init () { - hookSystem.registerFilter(Hooks.CONTENT_FILTER.hook(), this::substitute, 10); hookSystem.registerFilter(Hooks.CONTENT_FILTER.hook(), this::markdown, 20); hookSystem.registerFilter(Hooks.CONTENT_FILTER.hook(), this::shortCodes, 30); } @@ -56,20 +51,6 @@ public String process (String rawContent) { return hookSystem.filter(Hooks.CONTENT_FILTER.hook(), rawContent).value(); } - private String substitute (FilterContext context) { - Map map = new HashMap<>(); - - map.put("USERNAME", getFeatureValueOrDefault( - requestContext, - AuthFeature.class, - (feature) -> feature.username(), - "") - ); - - // replace variables - return StringSubstitutor.replace(context.value(), map); - } - private String markdown (FilterContext context) { return requestContext.get(RenderContext.class).markdownRenderer().render(context.value()); } diff --git a/cms-server/hosts/features/content/search/index.md b/cms-server/hosts/features/content/search/index.md index 369fa7cf..dde8342a 100644 --- a/cms-server/hosts/features/content/search/index.md +++ b/cms-server/hosts/features/content/search/index.md @@ -8,6 +8,4 @@ menu: ## Search -Hallo ${USERNAME} - Hello [[username /]] \ No newline at end of file diff --git a/cms-server/log4j2.xml b/cms-server/log4j2.xml index dc38e756..d99de29b 100644 --- a/cms-server/log4j2.xml +++ b/cms-server/log4j2.xml @@ -47,10 +47,10 @@ - + - + diff --git a/cms-server/modules/example-module/libs/example-module-6.0.0-SNAPSHOT.jar b/cms-server/modules/example-module/libs/example-module-6.0.0-SNAPSHOT.jar index a9400540..ff1130c6 100644 Binary files a/cms-server/modules/example-module/libs/example-module-6.0.0-SNAPSHOT.jar and b/cms-server/modules/example-module/libs/example-module-6.0.0-SNAPSHOT.jar differ diff --git a/cms-server/pom.xml b/cms-server/pom.xml index 64a4ecb7..524cf9b5 100644 --- a/cms-server/pom.xml +++ b/cms-server/pom.xml @@ -115,6 +115,12 @@ stormpot + + org.apache.commons + commons-text + test + + diff --git a/cms-server/src/main/java/com/condation/cms/server/filter/InitRequestContextFilter.java b/cms-server/src/main/java/com/condation/cms/server/filter/InitRequestContextFilter.java index f3dd5f6f..e46e572c 100644 --- a/cms-server/src/main/java/com/condation/cms/server/filter/InitRequestContextFilter.java +++ b/cms-server/src/main/java/com/condation/cms/server/filter/InitRequestContextFilter.java @@ -50,16 +50,22 @@ public InitRequestContextFilter(final RequestContextFactory requestContextFactor @Override public boolean handle(final Request httpRequest, final Response rspns, final Callback clbck) throws Exception { - var requestContext = (RequestContext)httpRequest.getAttribute(REQUEST_CONTEXT); + try { + var requestContext = (RequestContext) httpRequest.getAttribute(REQUEST_CONTEXT); - if (requestContext.has(AlreadyInitialized.class)) { - return false; + if (requestContext.has(AlreadyInitialized.class)) { + return false; + } + requestContextFactory.initContext(requestContext, httpRequest); + requestContext.add(AlreadyInitialized.class, new AlreadyInitialized()); + } catch (Exception e) { + e.printStackTrace(); } - requestContextFactory.initContext(requestContext, httpRequest); - requestContext.add(AlreadyInitialized.class, new AlreadyInitialized()); return false; } - - private record AlreadyInitialized() implements Feature{}; + + private record AlreadyInitialized() implements Feature { + } +; } diff --git a/cms-server/src/main/java/com/condation/cms/server/filter/PooledRequestContextFilter.java b/cms-server/src/main/java/com/condation/cms/server/filter/PooledRequestContextFilter.java index 6a55d863..b6df0dc9 100644 --- a/cms-server/src/main/java/com/condation/cms/server/filter/PooledRequestContextFilter.java +++ b/cms-server/src/main/java/com/condation/cms/server/filter/PooledRequestContextFilter.java @@ -21,8 +21,6 @@ * . * #L% */ - - import com.condation.cms.api.PerformanceProperties; import com.condation.cms.api.ServerContext; import com.condation.cms.api.annotations.Experimental; @@ -64,7 +62,7 @@ public class PooledRequestContextFilter extends Handler.Wrapper { Pool requestContextPool; private final PerformanceProperties properties; - + public PooledRequestContextFilter(final Handler handler, final RequestContextFactory requestContextFactory, final PerformanceProperties properties) { super(handler); @@ -75,7 +73,7 @@ public PooledRequestContextFilter(final Handler handler, final RequestContextFac .setSize(properties.pool_size()) .build(); } - + @Override public boolean handle(Request httpRequest, Response rspns, Callback clbck) throws Exception { var requestContextPoolable = requestContextPool.claim(new Timeout(Duration.ofSeconds(1))); @@ -95,7 +93,9 @@ public boolean handle(Request httpRequest, Response rspns, Callback clbck) throw httpRequest.setAttribute(REQUEST_CONTEXT, requestContext); return super.handle(httpRequest, rspns, clbck); - + } catch (Exception e) { + e.printStackTrace(); + return false; } finally { requestContext.features.remove(RequestFeature.class); requestContext.features.remove(IsPreviewFeature.class); @@ -104,7 +104,6 @@ public boolean handle(Request httpRequest, Response rspns, Callback clbck) throw } } - @RequiredArgsConstructor private static class RequestContextAllocator implements Allocator { diff --git a/cms-server/src/main/java/com/condation/cms/server/handler/cache/CacheHandler.java b/cms-server/src/main/java/com/condation/cms/server/handler/cache/CacheHandler.java index 32afa002..4950124e 100644 --- a/cms-server/src/main/java/com/condation/cms/server/handler/cache/CacheHandler.java +++ b/cms-server/src/main/java/com/condation/cms/server/handler/cache/CacheHandler.java @@ -91,7 +91,6 @@ public boolean handle(Request request, Response response, Callback callback) thr name, value); }); - Content.Sink.write(response, true, cached.body, callback); return true; diff --git a/cms-server/src/main/java/com/condation/cms/server/handler/content/JettyContentHandler.java b/cms-server/src/main/java/com/condation/cms/server/handler/content/JettyContentHandler.java index 7ca92a76..a1a37aa2 100644 --- a/cms-server/src/main/java/com/condation/cms/server/handler/content/JettyContentHandler.java +++ b/cms-server/src/main/java/com/condation/cms/server/handler/content/JettyContentHandler.java @@ -31,6 +31,7 @@ import com.condation.cms.request.RequestContextFactory; import com.condation.cms.server.filter.CreateRequestContextFilter; import com.google.inject.Inject; +import java.nio.charset.StandardCharsets; import java.util.Optional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -91,7 +92,8 @@ public boolean handle(Request request, Response response, Callback callback) thr } } catch (Exception e) { - log.error("", e); + e.printStackTrace(); + log.error("error handling content", e); response.setStatus(500); response.getHeaders().add(HttpHeader.CONTENT_TYPE, "text/html; charset=utf-8"); callback.succeeded(); diff --git a/cms-server/themes/test/templates/search.html b/cms-server/themes/test/templates/search.html index 8cc0b51e..070d226d 100644 --- a/cms-server/themes/test/templates/search.html +++ b/cms-server/themes/test/templates/search.html @@ -23,6 +23,7 @@ Hallo + Hello [(${shortCodes.call('username')})]