Skip to content

Commit

Permalink
add missing method to features
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorsten Marx committed Jun 4, 2024
1 parent 16ba72c commit 917e988
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cms-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-api</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-auth</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-content</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-extensions</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ export const ThemeFeature = Java.type("com.github.thmarx.cms.api.feature.feature
export const $features = {
get : (feature) => {
return requestContext.get(feature)
},
has : (feature) => {
return requestContext.has(feature)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.github.thmarx.cms.api.ServerProperties;
import com.github.thmarx.cms.api.db.DB;
import com.github.thmarx.cms.api.feature.features.AuthFeature;
import com.github.thmarx.cms.api.feature.features.HookSystemFeature;
import com.github.thmarx.cms.api.hooks.HookSystem;
import com.github.thmarx.cms.api.request.RequestContext;
Expand Down Expand Up @@ -80,17 +81,31 @@ public void shutdown () throws Exception {
}

@Test
public void testSomeMethod() throws IOException {
public void test_with_auth() throws IOException {

var requestContext = new RequestContext();
final HookSystem hookSystem = new HookSystem();
requestContext.add(HookSystemFeature.class, new HookSystemFeature(hookSystem));
requestContext.add(AuthFeature.class, new AuthFeature("thorsten"));
extensionManager.newContext(theme, requestContext);

Assertions.assertThat(hookSystem.execute("test").results())
.hasSize(1)
.containsExactly("hallo")
.containsExactly("Hallo thorsten")
;
}

@Test
public void test_without_auth() throws IOException {

var requestContext = new RequestContext();
final HookSystem hookSystem = new HookSystem();
requestContext.add(HookSystemFeature.class, new HookSystemFeature(hookSystem));
extensionManager.newContext(theme, requestContext);

Assertions.assertThat(hookSystem.execute("test").results())
.hasSize(1)
.containsExactly("Guten Tag")
;
}
}
11 changes: 9 additions & 2 deletions cms-extensions/src/test/resources/site/extensions/hook-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@

import { $hooks } from 'system/hooks.mjs';

import { AuthFeature, $features } from 'system/features.mjs';

$hooks.registerAction(
"test",
(context) => {
return 'hallo'

if ($features.has(AuthFeature)) {
return `Hallo ${$features.get(AuthFeature).username()}`
}

return 'Guten Tag'
}
)
)
2 changes: 1 addition & 1 deletion cms-filesystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-filesystem</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-git/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-git</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-media/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-media</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-sandbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-sandbox</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-server</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-template/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>cms-template</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion distribution/build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="distribution" default="distribution" basedir=".">
<property name="cms.version">4.18.0</property>
<property name="cms.version">4.18.1</property>

<property name="pebble.version">v1.1.0</property>
<property name="thymeleaf.version">v1.1.0</property>
Expand Down
2 changes: 1 addition & 1 deletion modules-framework/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms.module.framework</groupId>
<artifactId>module-framework</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>modules-api</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules-framework/manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms.module.framework</groupId>
<artifactId>module-framework</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>modules-manager</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<groupId>com.github.thmarx.cms.module.framework</groupId>
<artifactId>module-framework</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/example-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<artifactId>example-module</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
</parent>
<groupId>com.github.thmarx.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.18.0</version>
<version>4.18.1</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 917e988

Please sign in to comment.