-
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.
#12 add simple template theme support
- Loading branch information
Showing
32 changed files
with
271 additions
and
62 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
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
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
cms-api/src/main/java/com/github/thmarx/cms/api/YamlProperties.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
42 changes: 42 additions & 0 deletions
42
cms-api/src/main/java/com/github/thmarx/cms/api/theme/Theme.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,42 @@ | ||
package com.github.thmarx.cms.api.theme; | ||
|
||
/*- | ||
* #%L | ||
* cms-api | ||
* %% | ||
* 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.ThemeProperties; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* | ||
* @author thmar | ||
*/ | ||
|
||
public interface Theme { | ||
|
||
Path templatePath(); | ||
|
||
ThemeProperties properties(); | ||
|
||
/** | ||
* empty theme is used for sites without configured theme | ||
* @return | ||
*/ | ||
boolean empty(); | ||
} |
File renamed without changes.
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,5 @@ | ||
--- | ||
title: Leider nichts gefunden | ||
template: error.html | ||
--- | ||
Da haben wir leider nichts gefunden! |
5 changes: 5 additions & 0 deletions
5
cms-server/hosts/theme-demo/content/.technical/test/example.md
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,5 @@ | ||
--- | ||
title: Das ist der neue Titel | ||
--- | ||
|
||
Das ist der ganz aktuelle Inhalt |
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,8 @@ | ||
--- | ||
title: Startseite | ||
template: start.html | ||
--- | ||
|
||
# Demo Project | ||
|
||
![TestBild!](/media/images/test.jpg?format=small "Test bild") |
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
cms-server/hosts/theme-demo/modules_data/moduleconfiguration.json
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 @@ | ||
{"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"},"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
hostname: localhost2 | ||
baseurl: "http://localhost2:1010" | ||
language: en | ||
template: | ||
engine: thymeleaf | ||
markdown: | ||
engine: markedjs | ||
theme: default | ||
modules: | ||
active: | ||
- markedjs-module | ||
media: | ||
formats: | ||
- name: small | ||
width: 256 | ||
height: 256 | ||
format: webp | ||
compression: true | ||
- name: big | ||
width: 512 | ||
height: 512 | ||
format: webp | ||
compression: true |
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
78 changes: 78 additions & 0 deletions
78
cms-server/src/main/java/com/github/thmarx/cms/theme/DefaultTheme.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,78 @@ | ||
package com.github.thmarx.cms.theme; | ||
|
||
/*- | ||
* #%L | ||
* cms-server | ||
* %% | ||
* 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.ThemeProperties; | ||
import com.github.thmarx.cms.api.theme.Theme; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
/** | ||
* | ||
* @author thmar | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class DefaultTheme implements Theme { | ||
|
||
public static final Theme EMPTY = new DefaultTheme(null, null, true); | ||
|
||
private final Path themePath; | ||
private final ThemeProperties properties; | ||
private boolean empty = false; | ||
|
||
private DefaultTheme (final Path templatePath, final ThemeProperties themeProperties, final boolean empty) { | ||
this(templatePath, themeProperties); | ||
this.empty = empty; | ||
} | ||
|
||
public static Theme load (Path themePath) throws IOException { | ||
Yaml yaml = new Yaml(); | ||
Path themeYaml = themePath.resolve("theme.yaml"); | ||
|
||
var content = Files.readString(themeYaml, StandardCharsets.UTF_8); | ||
Map<String, Object> config = (Map<String, Object>)yaml.load(content); | ||
|
||
return new DefaultTheme(themePath, new ThemeProperties(config)); | ||
} | ||
|
||
@Override | ||
public Path templatePath() { | ||
return themePath.resolve("templates/"); | ||
} | ||
|
||
@Override | ||
public boolean empty() { | ||
return empty; | ||
} | ||
|
||
@Override | ||
public ThemeProperties properties() { | ||
return properties; | ||
} | ||
} |
Oops, something went wrong.