BlueGit

timfa 66wiki

add support for links to other data pages

timfa Tim · pushed by timfa

Authored 2025-12-20 · 11 months ago

Hash
4c2e68467bcf07522edb7cfa4b0342ea059cf191
Parent
8e22e661
3 files changed +9 −2
web/data/chapters/testchapter copy.json web/data/chapters/magicWords.json renamed +0 −0
web/data/wizardryActionWords/manifest.json +1 −1
@@ -3,5 +3,5 @@
3 3 "name": "Manifest <Energy/Sensory effect>",
4 4 "rank": 1,
5 5 "types": "",
6 "description": "Manifest a magical effect. See the Material list to determine suitable effects."
6 "description": "Manifest a magical effect. See the [data:Material list:chapters/magicWords.json] to determine suitable effects."
7 7 }
@@ -3,5 +3,5 @@
3 "name": "Manifest <Energy/Sensory effect>",
3 "name": "Manifest <Energy/Sensory effect>",
4 "rank": 1,
4 "rank": 1,
5 "types": "",
5 "types": "",
6 "description": "Manifest a magical effect. See the Material list to determine suitable effects."
6 "description": "Manifest a magical effect. See the [data:Material list:chapters/magicWords.json] to determine suitable effects."
7}
7}
web/templateRenderer.php +8 −1
@@ -175,13 +175,20 @@ final class TemplateRenderer
175 175 $template
176 176 );
177 177
178 // 5) Escaped images %%path%%
178 // 5) Escaped images [img:path]
179 179 $template = preg_replace_callback(
180 180 '/\[img:\s*([a-zA-Z0-9_\/.\-]+)\s*\]/',
181 181 fn($m) => '<div class="inlineImage"><img src="images/' . $m[1] . '"/></div>',
182 182 $template
183 183 );
184 184
185 // 6) Escaped data-links [data:text:path]
186 $template = preg_replace_callback(
187 '/\[data:\s*([a-zA-Z0-9_\/.\- ]+)\s*:\s*([a-zA-Z0-9_\/.\-]+)\s*\]/',
188 fn($m) => '<a href="?path=/data/' . $m[2] . '">' . $m[1] . '</a>',
189 $template
190 );
191
185 192 if (isset($data['wikiPath']))
186 193 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
187 194
@@ -175,13 +175,20 @@ final class TemplateRenderer
175 $template
175 $template
176 );
176 );
177
177
178 // 5) Escaped images %%path%%
178 // 5) Escaped images [img:path]
179 $template = preg_replace_callback(
179 $template = preg_replace_callback(
180 '/\[img:\s*([a-zA-Z0-9_\/.\-]+)\s*\]/',
180 '/\[img:\s*([a-zA-Z0-9_\/.\-]+)\s*\]/',
181 fn($m) => '<div class="inlineImage"><img src="images/' . $m[1] . '"/></div>',
181 fn($m) => '<div class="inlineImage"><img src="images/' . $m[1] . '"/></div>',
182 $template
182 $template
183 );
183 );
184
184
185 // 6) Escaped data-links [data:text:path]
186 $template = preg_replace_callback(
187 '/\[data:\s*([a-zA-Z0-9_\/.\- ]+)\s*:\s*([a-zA-Z0-9_\/.\-]+)\s*\]/',
188 fn($m) => '<a href="?path=/data/' . $m[2] . '">' . $m[1] . '</a>',
189 $template
190 );
191
185 if (isset($data['wikiPath']))
192 if (isset($data['wikiPath']))
186 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
193 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
187
194