BlueGit

timfa 66wiki

Add gemstones, stub for magic

timfa Tim · pushed by timfa

Authored 2025-12-20 · 11 months ago

Hash
0ccdbe2b880e763efd59b9fce0034f4c2cc41478
Parent
dd360904
29 files changed +306 −17
web/data/chapters/testchapter copy 2.json added +16 −0
@@ -0,0 +1,16 @@
1 {
2 "type": "chapter",
3 "number": 3,
4 "title": "items Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
7 {
8 "name": "Items",
9 "text": "Below is the full list of items available.\n[[[items]]]"
10 },
11 {
12 "name": "Gemstones",
13 "text": "Per 100 grams. Cut gems are worth twice as much as the rough variant of the same grade, with the exception of Astral Crystals not listed here. Gemstones are rated in grades from 1 to 10, where 10 is the best possible quality. Cutting a gem will lose 10% of its weight.\n[[[gemstones]]]"
14 }
15 ]
16 }
@@ -0,0 +1,16 @@
1{
2 "type": "chapter",
3 "number": 3,
4 "title": "items Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
7 {
8 "name": "Items",
9 "text": "Below is the full list of items available.\n[[[items]]]"
10 },
11 {
12 "name": "Gemstones",
13 "text": "Per 100 grams. Cut gems are worth twice as much as the rough variant of the same grade, with the exception of Astral Crystals not listed here. Gemstones are rated in grades from 1 to 10, where 10 is the best possible quality. Cutting a gem will lose 10% of its weight.\n[[[gemstones]]]"
14 }
15 ]
16}
web/data/chapters/testchapter copy.json added +20 −0
@@ -0,0 +1,20 @@
1 {
2 "type": "chapter",
3 "number": 1,
4 "title": "Mage Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
7 {
8 "name": "Material",
9 "text": "Material Words refer to substance.[[[wizardryMaterialWords]]]"
10 },
11 {
12 "name": "Action",
13 "text": "Words of Action describe events. Alone they do little, but they bind the other words together. Words between <brackets> show compatibility with Material words. You can only use the Action on a Material Word if the Material contains the entirety of the compatibility in its type.[[[wizardryActionWords]]]"
14 },
15 {
16 "name": "Alteration",
17 "text": "These words change the spell itself. Larger, Smaller, Quicker or Longer. They mold the Spell closer to the Intent. These words may also indicate an Alteration Level which may affect other words.[[[wizardryAlterationWords]]]"
18 }
19 ]
20 }
@@ -0,0 +1,20 @@
1{
2 "type": "chapter",
3 "number": 1,
4 "title": "Mage Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
7 {
8 "name": "Material",
9 "text": "Material Words refer to substance.[[[wizardryMaterialWords]]]"
10 },
11 {
12 "name": "Action",
13 "text": "Words of Action describe events. Alone they do little, but they bind the other words together. Words between <brackets> show compatibility with Material words. You can only use the Action on a Material Word if the Material contains the entirety of the compatibility in its type.[[[wizardryActionWords]]]"
14 },
15 {
16 "name": "Alteration",
17 "text": "These words change the spell itself. Larger, Smaller, Quicker or Longer. They mold the Spell closer to the Intent. These words may also indicate an Alteration Level which may affect other words.[[[wizardryAlterationWords]]]"
18 }
19 ]
20}
web/data/chapters/testchapter.json added +12 −0
@@ -0,0 +1,12 @@
1 {
2 "type": "chapter",
3 "number": 2,
4 "title": "List Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
7 {
8 "name": "Proficiencies",
9 "text": "The actions your PC can perform depend on your character’s Proficiencies. Each Proficiency has a level, which can be no higher than 6. You can view Proficiencies as abilities your character possesses, which you can use whenever you want. See a lock you want to pick? Tell the GM you’re using your Thievery Proficiency!\n[[[proficiencies]]]"
10 }
11 ]
12 }
@@ -0,0 +1,12 @@
1{
2 "type": "chapter",
3 "number": 2,
4 "title": "List Test",
5 "description": "This is a test chapter. It tests to see if the system works.",
6 "subheaders": [
7 {
8 "name": "Proficiencies",
9 "text": "The actions your PC can perform depend on your character’s Proficiencies. Each Proficiency has a level, which can be no higher than 6. You can view Proficiencies as abilities your character possesses, which you can use whenever you want. See a lock you want to pick? Tell the GM you’re using your Thievery Proficiency!\n[[[proficiencies]]]"
10 }
11 ]
12}
web/data/gemstones/amethyst.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Amethyst",
4 "price": "depends on grade",
5 "description": "An uncommon gemstone with a deep purple color.\n16 Sel at grade 1, +5 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Amethyst",
4 "price": "depends on grade",
5 "description": "An uncommon gemstone with a deep purple color.\n16 Sel at grade 1, +5 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6}
web/data/gemstones/bismuth.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Bismuth",
4 "price": "depends on grade",
5 "description": "An opaque gem, crystallizing in repeating geometric patterns.\n35 Sel at grade 1, +5 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Bismuth",
4 "price": "depends on grade",
5 "description": "An opaque gem, crystallizing in repeating geometric patterns.\n35 Sel at grade 1, +5 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6}
web/data/gemstones/diamond.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Diamond",
4 "price": "depends on grade",
5 "description": "A common transparent gem with dazzling reflections.\n100 Sel at grade 1, +20 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Diamond",
4 "price": "depends on grade",
5 "description": "A common transparent gem with dazzling reflections.\n100 Sel at grade 1, +20 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6}
web/data/gemstones/emerald.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Emerald",
4 "price": "depends on grade",
5 "description": "An uncommon light green gem with dark spots.\n120 Sel at grade 1, +25 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Emerald",
4 "price": "depends on grade",
5 "description": "An uncommon light green gem with dark spots.\n120 Sel at grade 1, +25 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6}
web/data/gemstones/garnet.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Garnet",
4 "price": "depends on grade",
5 "description": "Rare gems ranging from a faded crimson to a deep red.\n250 Sel at grade 1, +20 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Garnet",
4 "price": "depends on grade",
5 "description": "Rare gems ranging from a faded crimson to a deep red.\n250 Sel at grade 1, +20 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6}
web/data/gemstones/jadeite.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Jadeite",
4 "price": "depends on grade",
5 "description": "A rare opaque dark green gem.\n150 Sel at grade 1, +50 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Jadeite",
4 "price": "depends on grade",
5 "description": "A rare opaque dark green gem.\n150 Sel at grade 1, +50 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6}
web/data/gemstones/jet.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Jet",
4 "price": "depends on grade",
5 "description": "An uncommon opaque black gem.\n100 Sel at grade 1, +35 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Jet",
4 "price": "depends on grade",
5 "description": "An uncommon opaque black gem.\n100 Sel at grade 1, +35 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6}
web/data/gemstones/onyx.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Onyx",
4 "price": "depends on grade",
5 "description": "An uncommon opaque black gem with white bands.\n150 Sel at grade 1, +55 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Onyx",
4 "price": "depends on grade",
5 "description": "An uncommon opaque black gem with white bands.\n150 Sel at grade 1, +55 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6}
web/data/gemstones/opal.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Opal",
4 "price": "depends on grade",
5 "description": "A valuable but common milky green/blue colored gem, casting an amber shadow.\n215 Sel at grade 1, +15 at each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Opal",
4 "price": "depends on grade",
5 "description": "A valuable but common milky green/blue colored gem, casting an amber shadow.\n215 Sel at grade 1, +15 at each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6}
web/data/gemstones/ruby.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Ruby",
4 "price": "depends on grade",
5 "description": "An uncommon gem with a vivid dark red color.\n160 Sel at grade 1, +25 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Ruby",
4 "price": "depends on grade",
5 "description": "An uncommon gem with a vivid dark red color.\n160 Sel at grade 1, +25 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6}
web/data/gemstones/sapphire.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Sapphire",
4 "price": "depends on grade",
5 "description": "An uncommon vivid, dark blue gem.\n200 Sel at grade 1, +30 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Sapphire",
4 "price": "depends on grade",
5 "description": "An uncommon vivid, dark blue gem.\n200 Sel at grade 1, +30 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6}
web/data/gemstones/tanzanite.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Tanzanite",
4 "price": "depends on grade",
5 "description": "A very rare vivid blue gem.\n300 Sel at grade 1, +25 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Tanzanite",
4 "price": "depends on grade",
5 "description": "A very rare vivid blue gem.\n300 Sel at grade 1, +25 for each grade above 1.\nMining Difficulty: 6\nMining Batch Size: 1"
6}
web/data/gemstones/topaz.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Topaz",
4 "price": "depends on grade",
5 "description": "A common vivid dark blue gem.\n50 Sel at grade 1, +10 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Topaz",
4 "price": "depends on grade",
5 "description": "A common vivid dark blue gem.\n50 Sel at grade 1, +10 for each grade above 1.\nMining Difficulty: 4\nMining Batch Size: 1"
6}
web/data/gemstones/tourmaline.json added +6 −0
@@ -0,0 +1,6 @@
1 {
2 "type": "item",
3 "name": "Rough Tourmaline",
4 "price": "depends on grade",
5 "description": "A somewhat rare gem with a dark, deep green hue.\n100 Sel at grade 1, +10 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6 }
@@ -0,0 +1,6 @@
1{
2 "type": "item",
3 "name": "Rough Tourmaline",
4 "price": "depends on grade",
5 "description": "A somewhat rare gem with a dark, deep green hue.\n100 Sel at grade 1, +10 for each grade above 1.\nMining Difficulty: 5\nMining Batch Size: 1"
6}
web/data/items/gemstones.json deleted +0 −6
@@ -1,6 +0,0 @@
1 {
2 "type": "item",
3 "name": "Gemstones",
4 "price": "varies",
5 "description": "Various glittering gemstones.\nPrice determined by type \nMining Difficulty: 6\nMining Batch Size: 1"
6 }
@@ -1,6 +0,0 @@
1{
2 "type": "item",
3 "name": "Gemstones",
4 "price": "varies",
5 "description": "Various glittering gemstones.\nPrice determined by type \nMining Difficulty: 6\nMining Batch Size: 1"
6}
web/data/wizardryActionWords/manifest.json added +7 −0
@@ -0,0 +1,7 @@
1 {
2 "type": "magicWord",
3 "name": "Manifest <Energy/Sensory effect>",
4 "rank": 1,
5 "types": "",
6 "description": "Manifest a magical effect. See the Material list to determine suitable effects."
7 }
@@ -0,0 +1,7 @@
1{
2 "type": "magicWord",
3 "name": "Manifest <Energy/Sensory effect>",
4 "rank": 1,
5 "types": "",
6 "description": "Manifest a magical effect. See the Material list to determine suitable effects."
7}
web/data/wizardryAlterationWords/greater.json added +7 −0
@@ -0,0 +1,7 @@
1 {
2 "type": "magicWord",
3 "name": "Greater",
4 "rank": 3,
5 "types": "",
6 "description": "This word greatly increases the effect of a spell. It also increases the Spell Level by two, instead of one. A spell cast using this word will have an Alteration Level of 3."
7 }
@@ -0,0 +1,7 @@
1{
2 "type": "magicWord",
3 "name": "Greater",
4 "rank": 3,
5 "types": "",
6 "description": "This word greatly increases the effect of a spell. It also increases the Spell Level by two, instead of one. A spell cast using this word will have an Alteration Level of 3."
7}
web/data/wizardryMaterialWords/fire.json added +7 −0
@@ -0,0 +1,7 @@
1 {
2 "type": "magicWord",
3 "name": "Fire",
4 "rank": 1,
5 "types": "Elemental Energy",
6 "description": "Refers to any existing fire."
7 }
@@ -0,0 +1,7 @@
1{
2 "type": "magicWord",
3 "name": "Fire",
4 "rank": 1,
5 "types": "Elemental Energy",
6 "description": "Refers to any existing fire."
7}
web/index.php +4 −9
@@ -8,18 +8,13 @@ $renderer = new TemplateRenderer(__DIR__ . DIRECTORY_SEPARATOR . '/templates');
8 8 if (isset($_GET['path'])) {
9 9 $html = $renderer->renderFromJsonFile($_GET['path']);
10 10 } else {
11 $data = loadFolderTree(__DIR__ . DIRECTORY_SEPARATOR . 'data');
11 $data = loadFolderTree(__DIR__ . DIRECTORY_SEPARATOR . 'data/chapters');
12 12
13 if ($data) {
14 // Non-recursive (only proficiencies/*.json):
15 $onlyHere = $data->jsonNonRecursive();
16
17 // Recursive (proficiencies/**/*.json):
18 $allUnder = $data->jsonRecursive();
19 }
13 $chaptersOrdered = $data->jsonRecursive();
14 usort($chaptersOrdered, fn($a, $b) => ($a->number ?? 0) <=> ($b->number ?? 0));
20 15
21 16 try {
22 $html = $renderer->renderAll($allUnder);
17 $html = $renderer->renderAll($chaptersOrdered);
23 18 } catch (Throwable $e) {
24 19 $html = '<pre class="error">' . htmlspecialchars($e->getMessage()) . '</pre>';
25 20 }
@@ -8,18 +8,13 @@ $renderer = new TemplateRenderer(__DIR__ . DIRECTORY_SEPARATOR . '/templates');
8if (isset($_GET['path'])) {
8if (isset($_GET['path'])) {
9 $html = $renderer->renderFromJsonFile($_GET['path']);
9 $html = $renderer->renderFromJsonFile($_GET['path']);
10} else {
10} else {
11 $data = loadFolderTree(__DIR__ . DIRECTORY_SEPARATOR . 'data');
11 $data = loadFolderTree(__DIR__ . DIRECTORY_SEPARATOR . 'data/chapters');
12
12
13 if ($data) {
13 $chaptersOrdered = $data->jsonRecursive();
14 // Non-recursive (only proficiencies/*.json):
14 usort($chaptersOrdered, fn($a, $b) => ($a->number ?? 0) <=> ($b->number ?? 0));
15 $onlyHere = $data->jsonNonRecursive();
16
17 // Recursive (proficiencies/**/*.json):
18 $allUnder = $data->jsonRecursive();
19 }
20
15
21 try {
16 try {
22 $html = $renderer->renderAll($allUnder);
17 $html = $renderer->renderAll($chaptersOrdered);
23 } catch (Throwable $e) {
18 } catch (Throwable $e) {
24 $html = '<pre class="error">' . htmlspecialchars($e->getMessage()) . '</pre>';
19 $html = '<pre class="error">' . htmlspecialchars($e->getMessage()) . '</pre>';
25 }
20 }
web/templateRenderer.php +46 −2
@@ -3,9 +3,12 @@
3 3 final class TemplateRenderer
4 4 {
5 5 private string $templatesDir;
6 private string $dataDir;
6 7
7 public function __construct(?string $templatesDir = null)
8
9 public function __construct(?string $templatesDir = null, ?string $dataDir = null)
8 10 {
11 $this->dataDir = $dataDir ?? (__DIR__ . DIRECTORY_SEPARATOR . 'data');
9 12 $this->templatesDir = $templatesDir ?? (__DIR__ . DIRECTORY_SEPARATOR . 'templates');
10 13 }
11 14
@@ -71,7 +74,7 @@ final class TemplateRenderer
71 74 * 3) resolve escaped {{path}}
72 75 */
73 76 private function renderTemplateString(string $template, array $data): string
74 {
77 {
75 78 // 1) Child-template tags: [[moves:proficiency.move]]
76 79 $template = preg_replace_callback(
77 80 '/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
@@ -132,6 +135,47 @@ final class TemplateRenderer
132 135 $template
133 136 );
134 137
138 $template = preg_replace_callback(
139 '/\[\[\[\s*([a-zA-Z0-9_.-]+)\s*\]\]\]/',
140 function ($m) use ($data) {
141 $folderName = $m[1];
142
143 // Basic hardening: only allow simple folder names
144 if (!preg_match('/^[a-zA-Z0-9_.-]+$/', $folderName)) {
145 return '';
146 }
147
148 $folderPath = $this->dataDir . DIRECTORY_SEPARATOR . $folderName;
149
150 if (!is_dir($folderPath)) {
151 // If you prefer to see errors during authoring, you could return a warning div instead.
152 return '';
153 }
154
155 $files = glob($folderPath . DIRECTORY_SEPARATOR . '*.json');
156 if ($files === false || count($files) === 0) {
157 return '';
158 }
159
160 sort($files, SORT_NATURAL | SORT_FLAG_CASE);
161
162 $out = '';
163 foreach ($files as $jsonFile) {
164 try {
165 $out .= $this->renderFromJsonFile($jsonFile);
166 } catch (\Throwable $e) {
167 // Fail-soft: embed an error block so one bad file doesn't blank the whole page
168 $out .= '<pre class="renderError">' .
169 htmlspecialchars("Render error in {$jsonFile}: " . $e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') .
170 '</pre>';
171 }
172 }
173
174 return $out;
175 },
176 $template
177 );
178
135 179 if (isset($data['wikiPath']))
136 180 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
137 181
@@ -3,9 +3,12 @@
3final class TemplateRenderer
3final class TemplateRenderer
4{
4{
5 private string $templatesDir;
5 private string $templatesDir;
6 private string $dataDir;
6
7
7 public function __construct(?string $templatesDir = null)
8
9 public function __construct(?string $templatesDir = null, ?string $dataDir = null)
8 {
10 {
11 $this->dataDir = $dataDir ?? (__DIR__ . DIRECTORY_SEPARATOR . 'data');
9 $this->templatesDir = $templatesDir ?? (__DIR__ . DIRECTORY_SEPARATOR . 'templates');
12 $this->templatesDir = $templatesDir ?? (__DIR__ . DIRECTORY_SEPARATOR . 'templates');
10 }
13 }
11
14
@@ -71,7 +74,7 @@ final class TemplateRenderer
71 * 3) resolve escaped {{path}}
74 * 3) resolve escaped {{path}}
72 */
75 */
73 private function renderTemplateString(string $template, array $data): string
76 private function renderTemplateString(string $template, array $data): string
74 {
77 {
75 // 1) Child-template tags: [[moves:proficiency.move]]
78 // 1) Child-template tags: [[moves:proficiency.move]]
76 $template = preg_replace_callback(
79 $template = preg_replace_callback(
77 '/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
80 '/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
@@ -132,6 +135,47 @@ final class TemplateRenderer
132 $template
135 $template
133 );
136 );
134
137
138 $template = preg_replace_callback(
139 '/\[\[\[\s*([a-zA-Z0-9_.-]+)\s*\]\]\]/',
140 function ($m) use ($data) {
141 $folderName = $m[1];
142
143 // Basic hardening: only allow simple folder names
144 if (!preg_match('/^[a-zA-Z0-9_.-]+$/', $folderName)) {
145 return '';
146 }
147
148 $folderPath = $this->dataDir . DIRECTORY_SEPARATOR . $folderName;
149
150 if (!is_dir($folderPath)) {
151 // If you prefer to see errors during authoring, you could return a warning div instead.
152 return '';
153 }
154
155 $files = glob($folderPath . DIRECTORY_SEPARATOR . '*.json');
156 if ($files === false || count($files) === 0) {
157 return '';
158 }
159
160 sort($files, SORT_NATURAL | SORT_FLAG_CASE);
161
162 $out = '';
163 foreach ($files as $jsonFile) {
164 try {
165 $out .= $this->renderFromJsonFile($jsonFile);
166 } catch (\Throwable $e) {
167 // Fail-soft: embed an error block so one bad file doesn't blank the whole page
168 $out .= '<pre class="renderError">' .
169 htmlspecialchars("Render error in {$jsonFile}: " . $e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') .
170 '</pre>';
171 }
172 }
173
174 return $out;
175 },
176 $template
177 );
178
135 if (isset($data['wikiPath']))
179 if (isset($data['wikiPath']))
136 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
180 $template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
137
181
web/templates/chapter.subheader.template added +7 −0
@@ -0,0 +1,7 @@
1 <section class="chapterSubheader">
2 <h2 class="subheaderTitle">{{name}}</h2>
3
4 <div class="subheaderText">
5 {{text}}
6 </div>
7 </section>
@@ -0,0 +1,7 @@
1<section class="chapterSubheader">
2 <h2 class="subheaderTitle">{{name}}</h2>
3
4 <div class="subheaderText">
5 {{text}}
6 </div>
7</section>
web/templates/chapter.template added +14 −0
@@ -0,0 +1,14 @@
1 <article class="chapter">
2 <header class="chapterHeader">
3 <div class="chapterNumber">Chapter {{number}}</div>
4 <h1 class="chapterTitle"><a href="<<url>>">{{title}}</a></h1>
5 </header>
6
7 <section class="chapterDescription">
8 {{description}}
9 </section>
10
11 <section class="chapterBody">
12 [[subheaders:chapter.subheader]]
13 </section>
14 </article>
@@ -0,0 +1,14 @@
1<article class="chapter">
2 <header class="chapterHeader">
3 <div class="chapterNumber">Chapter {{number}}</div>
4 <h1 class="chapterTitle"><a href="<<url>>">{{title}}</a></h1>
5 </header>
6
7 <section class="chapterDescription">
8 {{description}}
9 </section>
10
11 <section class="chapterBody">
12 [[subheaders:chapter.subheader]]
13 </section>
14</article>
web/templates/chapter.template.css added +41 −0
@@ -0,0 +1,41 @@
1 .chapter {
2 max-width: 1000px;
3 margin: 1.5rem auto;
4 padding: 1.25rem;
5 border: 1px solid #ddd;
6 border-radius: 12px;
7 }
8
9 .chapterHeader {
10 display: grid;
11 gap: 0.25rem;
12 margin-bottom: 0.75rem;
13 }
14
15 .chapterNumber {
16 font-weight: 600;
17 opacity: 0.8;
18 }
19
20 .chapterTitle {
21 margin: 0;
22 }
23
24 .chapterDescription {
25 line-height: 1.55;
26 margin-bottom: 1rem;
27 }
28
29 .chapterSubheader {
30 margin-top: 1.25rem;
31 padding-top: 1rem;
32 border-top: 1px solid #eee;
33 }
34
35 .subheaderTitle {
36 margin: 0 0 0.5rem;
37 }
38
39 .subheaderText {
40 line-height: 1.55;
41 }
@@ -0,0 +1,41 @@
1.chapter {
2 max-width: 1000px;
3 margin: 1.5rem auto;
4 padding: 1.25rem;
5 border: 1px solid #ddd;
6 border-radius: 12px;
7}
8
9.chapterHeader {
10 display: grid;
11 gap: 0.25rem;
12 margin-bottom: 0.75rem;
13}
14
15.chapterNumber {
16 font-weight: 600;
17 opacity: 0.8;
18}
19
20.chapterTitle {
21 margin: 0;
22}
23
24.chapterDescription {
25 line-height: 1.55;
26 margin-bottom: 1rem;
27}
28
29.chapterSubheader {
30 margin-top: 1.25rem;
31 padding-top: 1rem;
32 border-top: 1px solid #eee;
33}
34
35.subheaderTitle {
36 margin: 0 0 0.5rem;
37}
38
39.subheaderText {
40 line-height: 1.55;
41}
web/templates/item.template web/templates/item copy.template renamed +0 −0
web/templates/magicword.template added +10 −0
@@ -0,0 +1,10 @@
1 <article class="magicWord">
2 <header class="magicWordHeader">
3 <h1 class="magicWordTitle"><a href="<<url>>">{{name}}</a></h1>
4 <div class="magicWordRank">{{types}} - Rank: {{rank}}</div>
5 </header>
6
7 <section class="magicWordDescription">
8 {{description}}
9 </section>
10 </article>
@@ -0,0 +1,10 @@
1<article class="magicWord">
2 <header class="magicWordHeader">
3 <h1 class="magicWordTitle"><a href="<<url>>">{{name}}</a></h1>
4 <div class="magicWordRank">{{types}} - Rank: {{rank}}</div>
5 </header>
6
7 <section class="magicWordDescription">
8 {{description}}
9 </section>
10</article>
web/templates/magicword.template.css added +31 −0
@@ -0,0 +1,31 @@
1 .magicWord {
2 max-width: 900px;
3 margin: 1.5rem auto;
4 padding: 1.25rem 1.25rem;
5 border: 1px solid #ddd;
6 border-radius: 12px;
7 }
8
9 .magicWordHeader {
10 display: flex;
11 align-items: baseline;
12 justify-content: space-between;
13 gap: 1rem;
14 margin-bottom: 0.75rem;
15 }
16
17 .magicWordTitle {
18 margin: 0;
19 font-size: 1.75rem;
20 line-height: 1.2;
21 }
22
23 .magicWordRank {
24 font-size: 1.1rem;
25 font-weight: 600;
26 white-space: nowrap;
27 }
28
29 .magicWordDescription {
30 line-height: 1.5;
31 }
@@ -0,0 +1,31 @@
1.magicWord {
2 max-width: 900px;
3 margin: 1.5rem auto;
4 padding: 1.25rem 1.25rem;
5 border: 1px solid #ddd;
6 border-radius: 12px;
7}
8
9.magicWordHeader {
10 display: flex;
11 align-items: baseline;
12 justify-content: space-between;
13 gap: 1rem;
14 margin-bottom: 0.75rem;
15}
16
17.magicWordTitle {
18 margin: 0;
19 font-size: 1.75rem;
20 line-height: 1.2;
21}
22
23.magicWordRank {
24 font-size: 1.1rem;
25 font-weight: 600;
26 white-space: nowrap;
27}
28
29.magicWordDescription {
30 line-height: 1.5;
31}