diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c23b63b01..f0c47bbc8 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,11 +1,3 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - name: Java CI with Maven on: @@ -16,16 +8,55 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 + - name: Set up JDK 25 uses: actions/setup-java@v5 with: java-version: '25-ea' distribution: 'temurin' cache: maven + + # Playwright-Binaries cachen → automatischer Download beim ersten Playwright.create() + - name: Cache Playwright browsers + uses: actions/cache@v5 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ hashFiles('**/pom.xml') }} + restore-keys: playwright- + + # Systembibliotheken für Chromium direkt via apt – kein Maven-Classpath-Problem + - name: Install Chromium system dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + libglib2.0-0 \ + libnss3 \ + libnspr4 \ + libatk1.0-0 \ + libatk-bridge2.0-0 \ + libcups2 \ + libdrm2 \ + libdbus-1-3 \ + libxkbcommon0 \ + libxcomposite1 \ + libxdamage1 \ + libxfixes3 \ + libxrandr2 \ + libgbm1 \ + libasound2t64 + - name: Build with Maven run: mvn -B package --file pom.xml + + # Test-Reports bei Fehler als Artifact sichern + - name: Upload Surefire Reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: surefire-reports + path: target/surefire-reports/ + retention-days: 7 diff --git a/cms-api/src/main/java/com/condation/cms/api/extensions/HookSystemRegisterExtensionPoint.java b/cms-api/src/main/java/com/condation/cms/api/extensions/HookSystemRegisterExtensionPoint.java index 2147306e5..5b7ab6bda 100644 --- a/cms-api/src/main/java/com/condation/cms/api/extensions/HookSystemRegisterExtensionPoint.java +++ b/cms-api/src/main/java/com/condation/cms/api/extensions/HookSystemRegisterExtensionPoint.java @@ -21,13 +21,10 @@ * #L% */ -import com.condation.cms.api.hooks.HookSystem; - /** * ExtensionPoint for modules to register hooks. * */ public abstract class HookSystemRegisterExtensionPoint extends AbstractExtensionPoint{ - public void register (final HookSystem hookSystem) {} } diff --git a/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterShortCodesExtensionPoint.java b/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterShortCodesExtensionPoint.java index 700325698..4ebbf9e00 100644 --- a/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterShortCodesExtensionPoint.java +++ b/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterShortCodesExtensionPoint.java @@ -32,14 +32,5 @@ * * @author t.marx */ -public abstract class RegisterShortCodesExtensionPoint extends AbstractExtensionPoint { - - @Deprecated(since = "8.1.0", forRemoval = true) - public Map> shortCodes () { - return Collections.emptyMap(); - } - - public List shortCodeDefinitions () { - return Collections.emptyList(); - } +public abstract class RegisterShortCodesExtensionPoint extends AbstractExtensionPoint { } diff --git a/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateComponentExtensionPoint.java b/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateComponentExtensionPoint.java index f49ca6517..1397d8cf3 100644 --- a/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateComponentExtensionPoint.java +++ b/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateComponentExtensionPoint.java @@ -21,25 +21,9 @@ * #L% */ - -import com.condation.cms.api.model.Parameter; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - /** * * @author t.marx */ public abstract class RegisterTemplateComponentExtensionPoint extends AbstractExtensionPoint { - - @Deprecated(since = "8.1.0", forRemoval = true) - public Map> components () { - return Collections.emptyMap(); - } - - public List componentDefinitions () { - return Collections.emptyList(); - } } diff --git a/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateFunctionExtensionPoint.java b/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateFunctionExtensionPoint.java index 170d481be..fca4fbcbf 100644 --- a/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateFunctionExtensionPoint.java +++ b/cms-api/src/main/java/com/condation/cms/api/extensions/RegisterTemplateFunctionExtensionPoint.java @@ -21,25 +21,9 @@ * #L% */ - -import com.condation.cms.api.model.Parameter; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - /** * * @author t.marx */ public abstract class RegisterTemplateFunctionExtensionPoint extends AbstractExtensionPoint { - - @Deprecated(since = "8.1.0", forRemoval = true) - public Map> functions () { - return Collections.emptyMap(); - } - - public List functionDefinitions () { - return Collections.emptyList(); - } } diff --git a/cms-content/src/test/java/com/condation/cms/content/perf/MarkdownPerformanceTest.java b/cms-content/src/test/java/com/condation/cms/content/perf/MarkdownPerformanceTest.java index a0cc0449d..7db751051 100644 --- a/cms-content/src/test/java/com/condation/cms/content/perf/MarkdownPerformanceTest.java +++ b/cms-content/src/test/java/com/condation/cms/content/perf/MarkdownPerformanceTest.java @@ -32,7 +32,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import com.github.noconnor.junitperf.JUnitPerfInterceptor; +import org.junit.jupiter.api.Tag; +@Tag("performance") @ExtendWith(JUnitPerfInterceptor.class) public class MarkdownPerformanceTest { diff --git a/cms-server/src/main/java/com/condation/cms/cli/CMSCli.java b/cms-server/src/main/java/com/condation/cms/cli/CMSCli.java index 6eee612ca..6ed351ccb 100644 --- a/cms-server/src/main/java/com/condation/cms/cli/CMSCli.java +++ b/cms-server/src/main/java/com/condation/cms/cli/CMSCli.java @@ -50,7 +50,7 @@ public static CommandLine getCommandLine() { return new CommandLine(new CLICommand()); } - public static void main(String[] args) { + public static void main(String... args) { CMSCli.getCommandLine().execute(args); } } diff --git a/cms-server/src/main/java/com/condation/cms/request/RequestContextFactory.java b/cms-server/src/main/java/com/condation/cms/request/RequestContextFactory.java index f6a81e82a..8e5f4e3af 100644 --- a/cms-server/src/main/java/com/condation/cms/request/RequestContextFactory.java +++ b/cms-server/src/main/java/com/condation/cms/request/RequestContextFactory.java @@ -156,9 +156,7 @@ private ShortCodes initContentTags(RequestContext requestContext) { injector.getInstance(ModuleManager.class).extensions(RegisterShortCodesExtensionPoint.class) .forEach(extension -> { - builder.register(extension.shortCodes()); - - builder.register(extension.shortCodeDefinitions()); + builder.register(extension); }); var codes = new HashMap>(); @@ -244,7 +242,6 @@ private void initHookSystem(RequestContext requestContext) { var moduleManager = injector.getInstance(ModuleManager.class); moduleManager.extensions(HookSystemRegisterExtensionPoint.class).forEach(extensionPoint -> { - extensionPoint.register(hookSystem); hookSystem.register(extensionPoint); }); diff --git a/cms-templates/src/main/java/com/condation/cms/templates/DynamicConfiguration.java b/cms-templates/src/main/java/com/condation/cms/templates/DynamicConfiguration.java index 0fa6af6e5..311bb1172 100644 --- a/cms-templates/src/main/java/com/condation/cms/templates/DynamicConfiguration.java +++ b/cms-templates/src/main/java/com/condation/cms/templates/DynamicConfiguration.java @@ -91,8 +91,7 @@ public List templateFunctions() { injector.getInstance(ModuleManager.class) .extensions(RegisterTemplateFunctionExtensionPoint.class) .forEach(extension -> { - templateFunctionsModel.register(extension.functions()); - templateFunctionsModel.register(extension.functionDefinitions()); + templateFunctionsModel.register(extension); }); templateFunctionsModel.getFunctionMap().functions().forEach(extFn -> { diff --git a/cms-templates/src/main/java/com/condation/cms/templates/module/CMSModuleTemplateEngine.java b/cms-templates/src/main/java/com/condation/cms/templates/module/CMSModuleTemplateEngine.java index 47c8e4970..c5cadc027 100644 --- a/cms-templates/src/main/java/com/condation/cms/templates/module/CMSModuleTemplateEngine.java +++ b/cms-templates/src/main/java/com/condation/cms/templates/module/CMSModuleTemplateEngine.java @@ -140,8 +140,7 @@ private TemplateComponents createTemplateComponents(RequestContext requestContex injector.getInstance(ModuleManager.class) .extensions(RegisterTemplateComponentExtensionPoint.class) .forEach(extension -> { - templateComponents.register(extension.components()); - templateComponents.register(extension.componentDefinitions()); + templateComponents.register(extension); }); Map> components = new HashMap<>(); diff --git a/cms-templates/src/test/java/com/condation/cms/templates/TemplateEngineFunctionsTest.java b/cms-templates/src/test/java/com/condation/cms/templates/TemplateEngineFunctionsTest.java index 5107e2479..a329e9567 100644 --- a/cms-templates/src/test/java/com/condation/cms/templates/TemplateEngineFunctionsTest.java +++ b/cms-templates/src/test/java/com/condation/cms/templates/TemplateEngineFunctionsTest.java @@ -166,16 +166,11 @@ void param_style_function_invocation_returns_correct_value() { public static class TestFunctions extends RegisterTemplateFunctionExtensionPoint { - @Override - public Map> functions() { - return Map.of("testfn1", (params) -> "hi I'm testfn1"); + @TemplateFunction("testfn1") + public Object testfn1(Parameter params) { + return "hi I'm testfn1"; } - - @Override - public List functionDefinitions() { - return List.of(this); - } - + // context style @TemplateFunction("testfn2") public Object testfn2(Parameter params) { diff --git a/cms-templates/src/test/java/com/condation/cms/templates/perf/TemplatePerformanceTest.java b/cms-templates/src/test/java/com/condation/cms/templates/perf/TemplatePerformanceTest.java index 8dbc11b98..7a8706cdc 100644 --- a/cms-templates/src/test/java/com/condation/cms/templates/perf/TemplatePerformanceTest.java +++ b/cms-templates/src/test/java/com/condation/cms/templates/perf/TemplatePerformanceTest.java @@ -40,7 +40,9 @@ import java.time.Duration; import java.util.Map; +import org.junit.jupiter.api.Tag; +@Tag("performance") @ExtendWith(JUnitPerfInterceptor.class) public class TemplatePerformanceTest { diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 7b63d2403..ad000aec8 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -1,72 +1,86 @@ - 4.0.0 - - com.condation.cms - cms-parent - 8.1.0 - - integration-tests - jar - integration-tests + 4.0.0 + + com.condation.cms + cms-parent + 8.1.0 + + integration-tests + jar + integration-tests - - true - true - + + true + true + - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.4 - - true - - - - + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.4 + + true + + + + - - - com.condation.cms - cms-api - - - com.condation.cms - cms-filesystem - - - com.condation.cms - cms-core - - - com.condation.cms - cms-content - - - com.condation.cms - cms-hooksystem - - - com.condation.cms - cms-media - - - org.projectlombok - lombok - provided - - - org.apache.commons - commons-text - - - com.condation.cms - cms-test - test - - + + + + com.condation.cms + cms-server + ${project.version} + test + + + com.microsoft.playwright + playwright + 1.60.0 + test + + + + com.condation.cms + cms-api + + + com.condation.cms + cms-filesystem + + + com.condation.cms + cms-core + + + com.condation.cms + cms-content + + + com.condation.cms + cms-hooksystem + + + com.condation.cms + cms-media + + + org.projectlombok + lombok + provided + + + org.apache.commons + commons-text + + + com.condation.cms + cms-test + test + + \ No newline at end of file diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/CMSServerExtension.java b/integration-tests/src/test/java/com/condation/cms/e2e/CMSServerExtension.java new file mode 100644 index 000000000..b787418b4 --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/CMSServerExtension.java @@ -0,0 +1,82 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ + +import com.condation.cms.cli.CMSCli; +import com.condation.cms.cli.tools.CLIServerUtils; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * + * @author thmar + */ +public class CMSServerExtension implements BeforeAllCallback, AutoCloseable { + + private static volatile boolean started = false; + private static Thread serverThread; + + @Override + public void beforeAll(ExtensionContext context) throws Exception { + if (!started) { + started = true; + + System.setProperty("cms.home", "../test-server"); + + serverThread = new Thread(() -> { + CMSCli.main("server", "start"); + }); + serverThread.setDaemon(true); + serverThread.start(); + + waitForProcess(10); + + context.getRoot() + .getStore(ExtensionContext.Namespace.GLOBAL) + .put("server", this); + + } + } + + @Override + public void close() throws Exception { + CMSCli.main("server", "stop"); + serverThread.join(10_000); + } + + private static void waitForProcess(int timeoutSeconds) throws Exception { + var deadline = System.currentTimeMillis() + timeoutSeconds * 1000L; + + while (System.currentTimeMillis() < deadline) { + var process = CLIServerUtils.getCMSProcess(); + if (process.isPresent()) { + // Optional: PID auslesen und prüfen ob Prozess wirklich läuft + System.out.println("Server gestartet mit PID: " + process.get().pid()); + return; + } + Thread.sleep(200); + } + throw new IllegalStateException( + "Server-PID-File nicht erschienen nach " + timeoutSeconds + "s" + ); +} +} diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/HTMLPipelineTest.java b/integration-tests/src/test/java/com/condation/cms/e2e/HTMLPipelineTest.java new file mode 100644 index 000000000..8ae83ab29 --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/HTMLPipelineTest.java @@ -0,0 +1,55 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import com.microsoft.playwright.Page; +import com.microsoft.playwright.junit.UsePlaywright; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * + * @author thmar + */ +@ExtendWith({CMSServerExtension.class}) +@UsePlaywright +public class HTMLPipelineTest { + + + @Test + void header(Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains(""); + } + + @Test + void footer (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains(""); + } + + @Test + void say_hello (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains("

Hello, CondationCMS

"); + } +} diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/ShortCodesTest.java b/integration-tests/src/test/java/com/condation/cms/e2e/ShortCodesTest.java new file mode 100644 index 000000000..707522476 --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/ShortCodesTest.java @@ -0,0 +1,55 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import com.microsoft.playwright.Page; +import com.microsoft.playwright.junit.UsePlaywright; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * + * @author thmar + */ +@ExtendWith({CMSServerExtension.class}) +@UsePlaywright +public class ShortCodesTest { + + + @Test + void bold_content(Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains("This content will be bold"); + } + + @Test + void theme_name (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains("Hello, I'm your demo theme."); + } + + @Test + void say_hello (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains("

Hello, CondationCMS

"); + } +} diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/SimpleTest.java b/integration-tests/src/test/java/com/condation/cms/e2e/SimpleTest.java new file mode 100644 index 000000000..f7579b3b1 --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/SimpleTest.java @@ -0,0 +1,48 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import com.condation.cms.cli.tools.CLIServerUtils; +import com.microsoft.playwright.Page; +import com.microsoft.playwright.junit.UsePlaywright; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * + * @author thmar + */ +@ExtendWith({CMSServerExtension.class}) +@UsePlaywright +public class SimpleTest { + + @Test + void server_is_started() throws Exception { + Assertions.assertThat(CLIServerUtils.getCMSProcess()).isPresent(); + } + + @Test + void start_page(Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.locator("title").innerText()).isEqualTo("Startpage"); + } +} diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/TemplateTest.java b/integration-tests/src/test/java/com/condation/cms/e2e/TemplateTest.java new file mode 100644 index 000000000..b9c589f63 --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/TemplateTest.java @@ -0,0 +1,69 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import com.microsoft.playwright.Page; +import com.microsoft.playwright.junit.UsePlaywright; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * + * @author thmar + */ +@ExtendWith({CMSServerExtension.class}) +@UsePlaywright +public class TemplateTest { + + + @Test + void function_fn_message(Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains("
MESSAGE: Hello ConditionCMS
"); + } + + @Test + void component_colored (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).containsIgnoringWhitespaces("
COMPONENT(content): This content should be red!
"); + } + + @Test + void component_component (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).contains("
COMPONENT: its a component
"); + } + + @Test + void component_temp_comp (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.content()).containsIgnoringWhitespaces(""" + rendered: +
+
CondationCMS
+

+ a compontent rendered by a template +

+
+ """); + } +} diff --git a/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleHookSystemRegistration.java b/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleHookSystemRegistration.java index 24f330a91..084cd850c 100644 --- a/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleHookSystemRegistration.java +++ b/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleHookSystemRegistration.java @@ -34,11 +34,11 @@ @Extension(HookSystemRegisterExtensionPoint.class) public class ExampleHookSystemRegistration extends HookSystemRegisterExtensionPoint { - @Override - public void register(HookSystem hookSystem) { - hookSystem.registerAction("example/test", (hookContext) -> "example hook function"); + @Action(value = "example/test") + public String example_test() { + return "example hook function"; } - + @Action(value = "example", scope = Scope.APPLICATION) public String example() { return ""; diff --git a/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java b/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java index dc5ab119b..8d8f2729f 100644 --- a/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java +++ b/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java @@ -24,6 +24,7 @@ import com.condation.cms.api.annotations.Action; import com.condation.cms.api.annotations.Scope; +import com.condation.cms.api.annotations.ShortCode; import com.condation.cms.api.extensions.RegisterShortCodesExtensionPoint; import com.condation.cms.api.model.Parameter; import com.condation.modules.api.annotation.Extension; @@ -37,13 +38,9 @@ */ @Extension(RegisterShortCodesExtensionPoint.class) public class ExampleTagExtension extends RegisterShortCodesExtensionPoint { - - @Override - public Map> shortCodes() { - Map> tags = new HashMap<>(); - - tags.put("example", (params) -> "example from module"); - - return tags; - } + + @ShortCode("example") + public String example () { + return "example from module"; + } } diff --git a/modules/system-modules/src/main/java/com/condation/cms/modules/system/tags/AuthTags.java b/modules/system-modules/src/main/java/com/condation/cms/modules/system/tags/AuthTags.java index dd28fc35b..14811b480 100644 --- a/modules/system-modules/src/main/java/com/condation/cms/modules/system/tags/AuthTags.java +++ b/modules/system-modules/src/main/java/com/condation/cms/modules/system/tags/AuthTags.java @@ -27,7 +27,6 @@ import com.condation.cms.api.model.Parameter; import com.condation.cms.api.request.RequestContext; import com.condation.modules.api.annotation.Extension; -import java.util.List; import java.util.function.Function; import com.condation.cms.api.annotations.ShortCode; @@ -37,11 +36,6 @@ */ @Extension(value = RegisterShortCodesExtensionPoint.class, cached = Extension.Caching.TRUE) public class AuthTags extends RegisterShortCodesExtensionPoint { - - @Override - public List shortCodeDefinitions() { - return List.of(this); - } @ShortCode(value = "username", namespace = "cms") public String username (Parameter params) { diff --git a/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/AuthTemplateFunctionExtensions.java b/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/AuthTemplateFunctionExtensions.java index db1d8f206..809fb094e 100644 --- a/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/AuthTemplateFunctionExtensions.java +++ b/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/AuthTemplateFunctionExtensions.java @@ -37,11 +37,6 @@ @Extension(value = RegisterTemplateFunctionExtensionPoint.class, cached = Extension.Caching.TRUE) public class AuthTemplateFunctionExtensions extends RegisterTemplateFunctionExtensionPoint { - @Override - public List functionDefinitions() { - return List.of(this); - } - @TemplateFunction(value = "username", namespace = "cms") public Object userName() { return (String) getFeatureValueOrDefault( diff --git a/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/HooksTemplateFunctionExtensions.java b/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/HooksTemplateFunctionExtensions.java index 3c58c6465..ba51cd932 100644 --- a/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/HooksTemplateFunctionExtensions.java +++ b/modules/system-modules/src/main/java/com/condation/cms/modules/system/templates/HooksTemplateFunctionExtensions.java @@ -36,11 +36,6 @@ @Extension(value = RegisterTemplateFunctionExtensionPoint.class, cached = Extension.Caching.TRUE) public class HooksTemplateFunctionExtensions extends RegisterTemplateFunctionExtensionPoint { - @Override - public List functionDefinitions() { - return List.of(this); - } - @TemplateFunction(value = "hooks", namespace = "cms") public Object hook(Parameter params){ diff --git a/modules/ui-module/src/main/java/com/condation/cms/modules/ui/extensionpoints/MenuHookExtension.java b/modules/ui-module/src/main/java/com/condation/cms/modules/ui/extensionpoints/MenuHookExtension.java index e701cc49c..66d476913 100644 --- a/modules/ui-module/src/main/java/com/condation/cms/modules/ui/extensionpoints/MenuHookExtension.java +++ b/modules/ui-module/src/main/java/com/condation/cms/modules/ui/extensionpoints/MenuHookExtension.java @@ -20,6 +20,8 @@ * along with this program. If not, see . * #L% */ +import com.condation.cms.api.annotations.Action; +import com.condation.cms.api.annotations.Filter; import com.condation.cms.api.hooks.HookSystem; import com.condation.cms.api.extensions.HookSystemRegisterExtensionPoint; import com.condation.cms.api.ui.action.UIHookAction; @@ -36,12 +38,10 @@ */ //@Extension(HookSystemRegisterExtensionPoint.class) public class MenuHookExtension extends HookSystemRegisterExtensionPoint { - - @Override - public void register(HookSystem hookSystem) { - hookSystem.registerFilter("module/ui/menu", (context) -> { - var menu = context.value(); - menu.addMenuEntry(MenuEntry.builder() + + @Filter("module/ui/menu") + public Menu createDemoMenu (Menu menu) { + menu.addMenuEntry(MenuEntry.builder() .children(new ArrayList<>( List.of(MenuEntry.builder().id("child1").name("ScriptAction") .position(0) @@ -56,13 +56,12 @@ public void register(HookSystem hookSystem) { .name("ExampleMenu") .id("example-menu") .build()); - return menu; - }); - - hookSystem.registerAction("module/ui/demo/menu/action", context -> { - System.out.println("hook action executed"); - System.out.println("hello " + context.arguments().get("name")); - return ""; - }); - } + return menu; + } + + @Action("module/ui/demo/menu/action") + public void demo_menu (String name) { + System.out.println("hook action executed"); + System.out.println("hello " + name); + } } diff --git a/pom.xml b/pom.xml index f0ad5f56b..79b6e7b09 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ cms-test ${project.version} - + com.condation.cms cms-hooksystem ${project.version} @@ -619,5 +619,30 @@ + + ci + + + env.CI + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + --enable-preview + -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar + -Xshare:off + + performance + + + + + diff --git a/test-server/themes/demo/extensions/theme.extension.js b/test-server/themes/demo/extensions/theme.extension.js index 495d91c44..bbf6276d9 100644 --- a/test-server/themes/demo/extensions/theme.extension.js +++ b/test-server/themes/demo/extensions/theme.extension.js @@ -13,7 +13,7 @@ $hooks.registerAction("system/content/shortCodes", ({shortCodes}) => { ) shortCodes.put( "say_hello", - ({name}) => `Hello, ${name}` + ({name}) => `

Hello, ${name}

` ) return null; }) @@ -29,7 +29,7 @@ $hooks.registerAction("system/template/function", ({functions}) => { $hooks.registerAction("system/template/component", ({components}) => { components.put( "colored", - ({color, _content}) => `
COMPONENT: ${_content}
` + ({color, _content}) => `
COMPONENT(content): ${_content}
` ) components.put( "component", diff --git a/test-server/themes/demo/templates/start.html b/test-server/themes/demo/templates/start.html index 8c65dc80b..e31823c2e 100644 --- a/test-server/themes/demo/templates/start.html +++ b/test-server/themes/demo/templates/start.html @@ -42,6 +42,7 @@

simple compontent

Template component

+ --- {[ ext:tempcomp name="CondationCMS" message="a compontent rendered by a template" ]} {[ endext:tempcomp ]} ---