BlueGit

timfa 66wiki

add image support anywhere in text

timfa Tim · pushed by timfa

Authored 2025-12-20 · 11 months ago

Hash
15b5766185c6403ea06f17358074af5add5747aa
Parent
2e48b967
4 files changed +14 −2
web/data/chapters/testchapter copy.json +1 −1
@@ -2,7 +2,7 @@
2 2 "type": "chapter",
3 3 "number": 1,
4 4 "title": "Mage Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
5 "description": "%%66logo.png%%This is a test chapter. It tests to see if the system works.",
6 6 "subheaders": [
7 7 {
8 8 "name": "Material",
@@ -2,7 +2,7 @@
2 "type": "chapter",
2 "type": "chapter",
3 "number": 1,
3 "number": 1,
4 "title": "Mage Test",
4 "title": "Mage Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
5 "description": "%%66logo.png%%This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
6 "subheaders": [
7 {
7 {
8 "name": "Material",
8 "name": "Material",
web/images/66logo.png added Binary file +0 −0

The contents of this binary file are not shown.

web/main.css +5 −0
@@ -205,6 +205,11 @@ article {
205 205 align-items: center;
206 206 }
207 207
208 .inlineImage {
209 align-content: center;
210 text-align: center;
211 }
212
208 213 .searchResultArticle {
209 214 border: 1px solid #ddd;
210 215 border-radius: 12px;
@@ -205,6 +205,11 @@ article {
205 align-items: center;
205 align-items: center;
206}
206}
207
207
208.inlineImage {
209 align-content: center;
210 text-align: center;
211}
212
208.searchResultArticle {
213.searchResultArticle {
209 border: 1px solid #ddd;
214 border: 1px solid #ddd;
210 border-radius: 12px;
215 border-radius: 12px;
web/templateRenderer.php +8 −1
@@ -75,7 +75,7 @@ final class TemplateRenderer
75 75 * 4) entire lists of a complete folder
76 76 */
77 77 private function renderTemplateString(string $template, array $data): string
78 {
78 {
79 79 // 1) Child-template tags: [[moves:proficiency.move]]
80 80 $template = preg_replace_callback(
81 81 '/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
@@ -175,6 +175,13 @@ final class TemplateRenderer
175 175 $template
176 176 );
177 177
178 // 5) Escaped images %%path%%
179 $template = preg_replace_callback(
180 '/\%\%\s*([a-zA-Z0-9_.-]+)\s*\%\%/',
181 fn($m) => '<div class="inlineImage"><img src="images' . DIRECTORY_SEPARATOR . $m[1] . '"/></div>',
182 $template
183 );
184
178 185 if (isset($data['wikiPath']))
179 186 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
180 187
@@ -75,7 +75,7 @@ final class TemplateRenderer
75 * 4) entire lists of a complete folder
75 * 4) entire lists of a complete folder
76 */
76 */
77 private function renderTemplateString(string $template, array $data): string
77 private function renderTemplateString(string $template, array $data): string
78 {
78 {
79 // 1) Child-template tags: [[moves:proficiency.move]]
79 // 1) Child-template tags: [[moves:proficiency.move]]
80 $template = preg_replace_callback(
80 $template = preg_replace_callback(
81 '/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
81 '/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
@@ -175,6 +175,13 @@ final class TemplateRenderer
175 $template
175 $template
176 );
176 );
177
177
178 // 5) Escaped images %%path%%
179 $template = preg_replace_callback(
180 '/\%\%\s*([a-zA-Z0-9_.-]+)\s*\%\%/',
181 fn($m) => '<div class="inlineImage"><img src="images' . DIRECTORY_SEPARATOR . $m[1] . '"/></div>',
182 $template
183 );
184
178 if (isset($data['wikiPath']))
185 if (isset($data['wikiPath']))
179 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
186 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
180
187