Skip to content

Commit 6c768ac

Browse files
Update GH workflow
1 parent 8a5265b commit 6c768ac

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ jobs:
7777
run: |
7878
rm -rf _site
7979
mkdir -p _site
80-
cp index.html .nojekyll LICENSE README.md _site/
81-
cp -r public examples docs _site/
80+
cp .nojekyll LICENSE README.md _site/
81+
cp -r public/. _site/
82+
cp -r examples docs _site/
8283
8384
- name: Televerser l'artefact Pages
8485
uses: actions/upload-pages-artifact@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Then visit `http://localhost:8788/public/index.html`.
5252

5353
The demo can load bundled presets, edit alphabets/neighborhoods/channels/boundaries/initial states, generate rule tables, validate and apply JSON, import/export configurations, and export the current canvas as PNG.
5454

55-
The repository root also contains `index.html`, so the app can be served from the root URL. This is the recommended shape for GitHub Pages:
55+
GitHub Pages publishes the contents of `public/` at the repository site root, while still copying `examples/` and `docs/` alongside it. That keeps the production URL clean:
5656

5757
```text
5858
https://<owner>.github.io/Automaginarium/

docs/github-pages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Recommended repository settings:
99
3. Set **Source** to `GitHub Actions`.
1010
5. Save.
1111

12-
The root `index.html` redirects to `public/index.html`, where the application runs. The workflow builds generated Multilingual/WASM artifacts at deploy time and uploads a complete Pages artifact.
12+
The workflow builds generated Multilingual/WASM artifacts at deploy time, then publishes the contents of `public/` as the GitHub Pages site root. The `examples/` and `docs/` directories are copied alongside it in the final Pages artifact.
1313

1414
Source files that must be committed for Pages:
1515

@@ -48,5 +48,5 @@ python -m http.server 8788
4848
Open:
4949

5050
```text
51-
http://localhost:8788/
51+
http://localhost:8788/public/index.html
5252
```

public/app.mjs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ const featureModules = {
7777
perturb: null,
7878
gradient: null,
7979
};
80+
const PRESET_BASE_CANDIDATES = [
81+
new URL("examples/", window.location.href),
82+
new URL("../examples/", window.location.href),
83+
];
8084

8185
async function ensureFeatureModule(name) {
8286
if (featureModules[name]) return featureModules[name];
@@ -598,11 +602,17 @@ function applyConfig(config, { source = "Configuration" } = {}) {
598602

599603
async function fetchPreset(id) {
600604
if (presetCache.has(id)) return structuredClone(presetCache.get(id));
601-
const response = await fetch(`../examples/${id}.json`);
602-
if (!response.ok) throw new Error(`Preset introuvable: ${id}`);
603-
const config = await response.json();
604-
presetCache.set(id, config);
605-
return structuredClone(config);
605+
let lastError = null;
606+
for (const baseUrl of PRESET_BASE_CANDIDATES) {
607+
const response = await fetch(new URL(`${id}.json`, baseUrl));
608+
if (response.ok) {
609+
const config = await response.json();
610+
presetCache.set(id, config);
611+
return structuredClone(config);
612+
}
613+
lastError = new Error(`Preset introuvable: ${id} (${response.status})`);
614+
}
615+
throw lastError || new Error(`Preset introuvable: ${id}`);
606616
}
607617

608618
async function loadPreset(id) {

0 commit comments

Comments
 (0)