-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thorsten Marx
committed
Nov 3, 2023
1 parent
6ab1b90
commit d65b84d
Showing
23 changed files
with
328 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"modules":{"flexmark-module":{"active":false,"id":"flexmark-module","moduleDir":"flexmark-module"},"thymeleaf-module":{"active":true,"id":"thymeleaf-module","moduleDir":"thymeleaf-module"},"freemarker-module":{"active":false,"id":"freemarker-module","moduleDir":"freemarker-module"},"pug-module":{"active":false,"id":"pug-module","moduleDir":"pug-module"},"pebble-module":{"active":false,"id":"pebble-module","moduleDir":"pebble-module"},"example-module":{"active":true,"id":"example-module","moduleDir":"example-module"},"markedjs-module":{"active":true,"id":"markedjs-module","moduleDir":"markedjs-module"}}} | ||
{"modules":{"flexmark-module":{"active":false,"id":"flexmark-module","moduleDir":"flexmark-module"},"thymeleaf-module":{"active":true,"id":"thymeleaf-module","moduleDir":"thymeleaf-module"},"freemarker-module":{"active":false,"id":"freemarker-module","moduleDir":"freemarker-module"},"pug-module":{"active":false,"id":"pug-module","moduleDir":"pug-module"},"ui-module":{"active":false,"id":"ui-module","moduleDir":"ui-module"},"pebble-module":{"active":false,"id":"pebble-module","moduleDir":"pebble-module"},"example-module":{"active":true,"id":"example-module","moduleDir":"example-module"},"markedjs-module":{"active":true,"id":"markedjs-module","moduleDir":"markedjs-module"}}} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.15 KB
...ver/modules/ui-module/libs/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
id=ui-module | ||
name=ui-module | ||
version=2.5.0-SNAPSHOT | ||
priority=HIGH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
modules/ui-module/src/main/java/com/github/thmarx/cms/modules/ui/assets/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
#%L | ||
ui-module | ||
%% | ||
Copyright (C) 2023 Marx-Software | ||
%% | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
#L% | ||
--> | ||
<!doctype html> | ||
<html> | ||
<head></head> | ||
<body> | ||
UI | ||
</body> | ||
</html> |
68 changes: 68 additions & 0 deletions
68
...dule/src/main/java/com/github/thmarx/cms/modules/ui/http/UIJettyHttpHandlerExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.github.thmarx.cms.modules.ui.http; | ||
|
||
/*- | ||
* #%L | ||
* ui-module | ||
* %% | ||
* Copyright (C) 2023 Marx-Software | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
import com.github.thmarx.cms.api.extensions.JettyHttpHandlerExtensionPoint; | ||
import com.github.thmarx.modules.api.annotation.Extension; | ||
import org.eclipse.jetty.http.pathmap.PathSpec; | ||
import org.eclipse.jetty.server.Handler; | ||
import org.eclipse.jetty.server.handler.PathMappingsHandler; | ||
import org.eclipse.jetty.server.handler.ResourceHandler; | ||
import org.eclipse.jetty.util.resource.PathResource; | ||
import org.eclipse.jetty.util.resource.PathResourceFactory; | ||
import org.eclipse.jetty.util.resource.Resource; | ||
import org.eclipse.jetty.util.resource.ResourceFactory; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
@Extension(JettyHttpHandlerExtensionPoint.class) | ||
public class UIJettyHttpHandlerExtension extends JettyHttpHandlerExtensionPoint { | ||
|
||
@Override | ||
public String getContextPath() { | ||
return "ui"; | ||
} | ||
|
||
@Override | ||
public Handler getHandler() { | ||
|
||
var classLoader = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
Thread.currentThread().setContextClassLoader(UIJettyHttpHandlerExtension.class.getClassLoader()); | ||
|
||
ResourceHandler resourceHandler = new ResourceHandler(); | ||
resourceHandler.setBaseResource( | ||
ResourceFactory.of(resourceHandler) | ||
.newClassLoaderResource("com/github/thmarx/cms/modules/ui/assets/", true) | ||
); | ||
|
||
PathMappingsHandler pathMappingsHandler = new PathMappingsHandler(); | ||
pathMappingsHandler.addMapping(PathSpec.from("/assets/*"), resourceHandler); | ||
|
||
return pathMappingsHandler; | ||
|
||
} finally { | ||
Thread.currentThread().setContextClassLoader(classLoader); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
.../ui-module/src/main/java/com/github/thmarx/cms/modules/ui/services/FileSystemService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.github.thmarx.cms.modules.ui.services; | ||
|
||
/*- | ||
* #%L | ||
* ui-module | ||
* %% | ||
* Copyright (C) 2023 Marx-Software | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import com.github.thmarx.cms.api.ModuleFileSystem; | ||
import com.github.thmarx.cms.modules.ui.utils.PathUtil; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class FileSystemService { | ||
private final ModuleFileSystem fileSystem; | ||
|
||
public List<Node> listContent (String parent) { | ||
|
||
try { | ||
var contentBase = fileSystem.resolve("content"); | ||
|
||
return Files.list(contentBase.resolve(parent)).map((path) -> { | ||
var uri = PathUtil.toUri(path, contentBase); | ||
return new Node(uri, path.getFileName().toString(), getIcon(path), hasChildren(path)); | ||
}).toList(); | ||
} catch (IOException ex) { | ||
log.error(null, ex); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
private boolean hasChildren (Path path) { | ||
try { | ||
return Files.list(path).count() > 0; | ||
} catch (IOException ex) { | ||
log.error(null, ex); | ||
} | ||
return false; | ||
} | ||
|
||
private String getIcon (Path path) { | ||
if (Files.isDirectory(path)) { | ||
return "folder"; | ||
} else { | ||
return "file"; | ||
} | ||
} | ||
|
||
public static record Node (String id, String text, String icon, boolean children){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
modules/ui-module/src/main/java/com/github/thmarx/cms/modules/ui/utils/Helper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
modules/ui-module/src/main/java/com/github/thmarx/cms/modules/ui/utils/PathUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.thmarx.cms.modules.ui.utils; | ||
|
||
/*- | ||
* #%L | ||
* ui-module | ||
* %% | ||
* Copyright (C) 2023 Marx-Software | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
public class PathUtil { | ||
|
||
public static String toUri(final Path contentFile, final Path contentBase) { | ||
Path relativize = contentBase.relativize(contentFile); | ||
if (Files.isDirectory(contentFile)) { | ||
relativize = relativize.resolve("index.md"); | ||
} | ||
var uri = relativize.toString(); | ||
uri = uri.replaceAll("\\\\", "/"); | ||
return uri; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
modules/ui-module/src/main/resources/com/github/thmarx/cms/modules/ui/assets/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
#%L | ||
ui-module | ||
%% | ||
Copyright (C) 2023 Marx-Software | ||
%% | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
#L% | ||
--> | ||
<!doctype html> | ||
<html> | ||
<head></head> | ||
<body> | ||
UI | ||
</body> | ||
</html> |