Skip to content

Commit 3c48f98

Browse files
authored
Merge pull request #8 from luke-b/copilot/explore-codebase-emulation-page
Align GitHub Pages root with the hosted emulator entrypoint
2 parents ae9b0eb + a56ccf7 commit 3c48f98

6 files changed

Lines changed: 182 additions & 110 deletions

File tree

.github/workflows/borland-dos-pipeline.yml

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ jobs:
144144
<meta charset="UTF-8">
145145
<meta name="viewport" content="width=device-width, initial-scale=1.0">
146146
<title>Wolfenstein 3D — build ${SHORT_SHA}</title>
147+
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
147148
<link rel="stylesheet" href="https://js-dos.com/v8/js-dos.css">
148149
<script src="https://js-dos.com/v8/js-dos.js"></script>
149150
<style>
150151
* { box-sizing: border-box; margin: 0; padding: 0; }
151152
body { background: #111; color: #eee; font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 20px; }
152153
h1 { margin-bottom: 12px; font-size: 1.4rem; }
153154
#dos { width: 800px; height: 600px; max-width: 100%; }
155+
#status { margin-top: 10px; min-height: 1.2em; font-size: 0.95rem; color: #b7c4d6; }
156+
#status.error { color: #ff9b9b; }
154157
.meta { margin-top: 10px; font-size: 0.8rem; color: #888; }
155158
button { margin-top: 10px; padding: 6px 16px; background: #333; color: #eee; border: 1px solid #555; cursor: pointer; border-radius: 4px; }
156159
button:hover { background: #444; }
@@ -159,16 +162,51 @@ jobs:
159162
<body>
160163
<h1>Wolfenstein 3D</h1>
161164
<div id="dos"></div>
165+
<p id="status" role="status" aria-live="polite">Loading emulator…</p>
162166
<button onclick="document.getElementById('dos').requestFullscreen && document.getElementById('dos').requestFullscreen()">Full screen</button>
163167
<p class="meta">build ${SHORT_SHA} &mdash; <a href="https://github.com/luke-b/DosTest/commit/${GITHUB_SHA}" style="color:#888">view commit</a></p>
164168
<script>
165-
Dos(document.getElementById("dos"), {
166-
url: "./hra.jsdos",
167-
onprogress: (stage, total, loaded) => {
168-
if (stage === "Resolving DosBox") return;
169-
console.log(stage, loaded, "/", total);
169+
const dosRoot = document.getElementById("dos");
170+
const status = document.getElementById("status");
171+
172+
function updateStatus(message, isError = false) {
173+
status.textContent = message;
174+
status.classList.toggle("error", isError);
175+
}
176+
177+
async function startDemo() {
178+
if (typeof Dos !== "function") {
179+
console.error("js-dos failed to load before initialization.");
180+
updateStatus("The js-dos runtime could not be loaded. Check your connection and try again.", true);
181+
return;
170182
}
171-
});
183+
184+
try {
185+
const dos = Dos(dosRoot, {
186+
url: "./hra.jsdos",
187+
onprogress: (stage, total, loaded) => {
188+
if (stage === "Resolving DosBox") {
189+
return;
190+
}
191+
192+
const suffix = total ? ` (${loaded}/${total})` : "";
193+
console.log(stage, loaded, "/", total);
194+
updateStatus(`${stage}${suffix}`);
195+
}
196+
});
197+
198+
if (dos && typeof dos.then === "function") {
199+
await dos;
200+
}
201+
202+
updateStatus("Ready. Click inside the emulator window to start playing.");
203+
} catch (error) {
204+
console.error("Error initializing DOSBox:", error);
205+
updateStatus("The emulator failed to start. Check the browser console for details.", true);
206+
}
207+
}
208+
209+
startDemo();
172210
</script>
173211
</body>
174212
</html>
@@ -199,19 +237,24 @@ jobs:
199237
cp index.html "staging/demo/build/${SHORT_SHA}/index.html"
200238
cp hra.jsdos "staging/demo/build/${SHORT_SHA}/hra.jsdos"
201239
cp latest-redirect/index.html "staging/demo/build/latest/index.html"
240+
cp ./index.html staging/index.html
241+
cp ./js-dos-test.html staging/js-dos-test.html
242+
cp ./jsdos-demo1.html staging/jsdos-demo1.html
243+
cp ./favicon.svg staging/favicon.svg
244+
touch staging/.nojekyll
202245
203246
- name: Deploy demo to gh-pages
204247
uses: peaceiris/actions-gh-pages@v4
205248
with:
206249
github_token: ${{ secrets.GITHUB_TOKEN }}
207-
publish_dir: ./staging/demo/build
208-
destination_dir: demo/build
250+
publish_dir: ./staging
209251
keep_files: true
210252

211253
- name: Smoke test deployed demo
212254
run: |
213255
SHORT_SHA="${{ steps.sha.outputs.short }}"
214256
for url in \
257+
"https://luke-b.github.io/DosTest/" \
215258
"https://luke-b.github.io/DosTest/demo/build/${SHORT_SHA}/" \
216259
"https://luke-b.github.io/DosTest/demo/build/latest/"
217260
do
@@ -296,7 +339,7 @@ jobs:
296339

297340
- name: Update demo link in README.md
298341
run: |
299-
DEMO_URL="https://luke-b.github.io/DosTest/demo/build/latest/"
342+
DEMO_URL="https://luke-b.github.io/DosTest/"
300343
BADGE_LINE="[![Play latest build](https://img.shields.io/badge/Play-Latest%20Build-brightgreen)](${DEMO_URL})"
301344
BLOCK="<!-- DEMO_LINK -->\n${BADGE_LINE}\n<!-- /DEMO_LINK -->"
302345

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Wolfenstein 3D Build with DOSBox-X and Borland C++ on GitHub Actions
22

33
<!-- DEMO_LINK -->
4-
[![Play latest build](https://img.shields.io/badge/Play-Latest%20Build-brightgreen)](https://luke-b.github.io/DosTest/demo/build/latest/)
4+
[![Play latest build](https://img.shields.io/badge/Play-Latest%20Build-brightgreen)](https://luke-b.github.io/DosTest/)
55
<!-- /DEMO_LINK -->
66

7-
This repository contains a setup to build the classic Wolfenstein 3D shareware source code using DOSBox-X and Borland C++ within a GitHub Actions pipeline. The built executable can then be run using js-dos, making it accessible through a web browser.
7+
This repository contains a setup to build the classic Wolfenstein 3D shareware source code using DOSBox-X and Borland C++ within a GitHub Actions pipeline. The built executable can then be run using js-dos, with the repository Pages root redirecting to the latest hosted browser build.
88

99
## Prerequisites
1010

favicon.svg

Lines changed: 4 additions & 0 deletions
Loading

index.html

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,79 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Play Wolfenstein 3D</title>
7-
<script src="https://js-dos.com/6.22/js-dos.js"></script>
6+
<title>Wolfenstein 3D</title>
7+
<meta http-equiv="refresh" content="0; url=./demo/build/latest/">
8+
<link rel="canonical" href="https://luke-b.github.io/DosTest/">
9+
<link rel="icon" type="image/svg+xml" href="./favicon.svg">
810
<style>
9-
body {
11+
:root {
12+
color-scheme: dark;
1013
font-family: Arial, sans-serif;
11-
display: flex;
12-
justify-content: center;
13-
align-items: center;
14-
height: 100vh;
14+
}
15+
16+
* {
17+
box-sizing: border-box;
18+
}
19+
20+
body {
1521
margin: 0;
16-
background-color: #000;
22+
min-height: 100vh;
23+
display: grid;
24+
place-items: center;
25+
padding: 24px;
26+
background: radial-gradient(circle at top, #25314f 0%, #111 48%, #050505 100%);
27+
color: #f5f5f5;
28+
}
29+
30+
main {
31+
width: min(100%, 42rem);
32+
padding: 28px;
33+
border: 1px solid rgba(255, 255, 255, 0.15);
34+
border-radius: 14px;
35+
background: rgba(0, 0, 0, 0.72);
36+
box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
37+
text-align: center;
38+
}
39+
40+
h1 {
41+
margin: 0 0 12px;
42+
font-size: clamp(1.8rem, 4vw, 2.6rem);
43+
}
44+
45+
p {
46+
margin: 0 0 16px;
47+
line-height: 1.5;
48+
color: #d0d0d0;
49+
}
50+
51+
a {
52+
color: #8fd3ff;
53+
}
54+
55+
.button {
56+
display: inline-block;
57+
margin-top: 8px;
58+
padding: 12px 18px;
59+
border-radius: 999px;
60+
background: #2b84ff;
61+
color: #fff;
62+
text-decoration: none;
63+
font-weight: 700;
1764
}
18-
#dosbox {
19-
width: 80%;
20-
height: 80%;
65+
66+
.button:hover {
67+
background: #4d98ff;
2168
}
2269
</style>
2370
</head>
2471
<body>
25-
<div id="dosbox"></div>
72+
<main>
73+
<h1>Wolfenstein 3D</h1>
74+
<p>Redirecting to the latest browser build.</p>
75+
<p>If you are not redirected automatically, open <a class="button" href="./demo/build/latest/">Play latest build</a>.</p>
76+
</main>
2677
<script>
27-
Dos(document.getElementById("dosbox")).ready(function (fs, main) {
28-
fs.extract("https://github.com/luke-b/DosTest/wolf3d.zip").then(function () {
29-
main(["-c", "wolf3d.exe"]);
30-
});
31-
});
78+
window.location.replace(new URL('./demo/build/latest/', window.location.href).href);
3279
</script>
3380
</body>
3481
</html>

js-dos-test.html

Lines changed: 25 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,34 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Play Wolfenstein 3D</title>
7-
<link rel="stylesheet" href="https://js-dos.com/v8/js-dos.css">
8-
<script src="https://js-dos.com/v8/js-dos.js"></script>
9-
</head>
10-
<body>
11-
<h1>Wolfenstein 3D</h1>
12-
<div id="Dos" style="width: 800px; height: 600px;"></div>
13-
<script>
14-
async function fetchLatestArtifactUrl() {
15-
const owner = "luke-b";
16-
const repo = "DosTest";
17-
const workflow_id = "borland-dos-pipeline.yml";
18-
const artifactName = "build-dos";
19-
20-
// Fetch the latest successful workflow run
21-
let response = await fetch(`https://api.github.com/repos/${owner}/${repo}/actions/workflows/${workflow_id}/runs?status=success&per_page=1`);
22-
let data = await response.json();
23-
if (data.total_count === 0) {
24-
throw new Error("No successful workflow runs found.");
25-
}
26-
27-
const latestRun = data.workflow_runs[0];
28-
29-
// Fetch the artifacts for the latest successful run
30-
response = await fetch(latestRun.artifacts_url);
31-
data = await response.json();
32-
33-
const artifact = data.artifacts.find(a => a.name === artifactName);
34-
if (!artifact) {
35-
throw new Error(`Artifact ${artifactName} not found.`);
36-
}
37-
38-
// Return the download URL for the artifact
39-
return artifact.archive_download_url;
6+
<title>Wolfenstein 3D Legacy Demo Redirect</title>
7+
<meta http-equiv="refresh" content="0; url=./demo/build/latest/">
8+
<link rel="icon" type="image/svg+xml" href="./favicon.svg">
9+
<style>
10+
body {
11+
margin: 0;
12+
min-height: 100vh;
13+
display: grid;
14+
place-items: center;
15+
padding: 24px;
16+
background: #111;
17+
color: #f5f5f5;
18+
font-family: Arial, sans-serif;
19+
text-align: center;
4020
}
4121

42-
async function initDosBox() {
43-
try {
44-
//const artifactUrl = await fetchLatestArtifactUrl();
45-
const artifactUrl = "https://github.com/luke-b/DosTest/actions/runs/9683912806/artifacts/1641429331";
46-
Dos(document.getElementById("Dos"), {
47-
wdosboxUrl: 'https://js-dos.com/v8/build/wdosbox.js',
48-
cycles: 10000,
49-
autolock: true,
50-
zip: artifactUrl,
51-
onprogress: (stage, total, loaded) => {
52-
if (stage === 'unzipping') {
53-
console.log(`Unzipping: ${(loaded / total * 100).toFixed(2)}%`);
54-
}
55-
}
56-
}).then(dosbox => {
57-
dosbox.run('wolf3d.exe');
58-
});
59-
} catch (error) {
60-
console.error('Error initializing DOSBox:', error);
61-
}
22+
a {
23+
color: #8fd3ff;
6224
}
63-
64-
initDosBox();
25+
</style>
26+
</head>
27+
<body>
28+
<main>
29+
<h1>This legacy demo page has moved.</h1>
30+
<p>Redirecting to the canonical hosted build at <a href="./demo/build/latest/">demo/build/latest</a>.</p>
31+
</main>
32+
<script>
33+
window.location.replace(new URL('./demo/build/latest/', window.location.href).href);
6534
</script>
6635
</body>
6736
</html>

jsdos-demo1.html

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
<div id="dosbox" style="width: 640px; height: 400px;">
2-
<div class="dosbox-container">
3-
<canvas class="dosbox-canvas" oncontextmenu="event.preventDefault()"></canvas>
4-
<div class="dosbox-loader">
5-
<div class="st-loader"><span class="equal"></span></div>
6-
<div class="dosbox-loader-message"></div>
7-
</div>
8-
<div class="dosbox-overlay">
9-
<div class="dosbox-powered">Powered by &nbsp;<a href="http://js-dos.com">js-dos.com</a></div>
10-
<div class="dosbox-start">Click to start</div>
11-
</div>
12-
</div>
13-
</div>
14-
<br>
15-
<button onclick="dosbox.requestFullScreen();">Make fullscreen</button>
16-
<script type="text/javascript" src="https://js-dos.com/v8/build/wdosbox.js"></script>
17-
<script type="text/javascript">
18-
var dosbox = new Dosbox({
19-
id: "dosbox",
20-
onload: function (dosbox) {
21-
dosbox.run("https://github.com/luke-b/DosTest/actions/runs/9683912806/artifacts/1641429331", "./WOLF3D.EXE");
22-
},
23-
onrun: function (dosbox, app) {
24-
console.log("App '" + app + "' is runned");
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Wolfenstein 3D Legacy Demo Redirect</title>
7+
<meta http-equiv="refresh" content="0; url=./demo/build/latest/">
8+
<link rel="icon" type="image/svg+xml" href="./favicon.svg">
9+
<style>
10+
body {
11+
margin: 0;
12+
min-height: 100vh;
13+
display: grid;
14+
place-items: center;
15+
padding: 24px;
16+
background: #111;
17+
color: #f5f5f5;
18+
font-family: Arial, sans-serif;
19+
text-align: center;
2520
}
26-
});
27-
</script>
21+
22+
a {
23+
color: #8fd3ff;
24+
}
25+
</style>
26+
</head>
27+
<body>
28+
<main>
29+
<h1>This legacy demo page has moved.</h1>
30+
<p>Redirecting to the canonical hosted build at <a href="./demo/build/latest/">demo/build/latest</a>.</p>
31+
</main>
32+
<script>
33+
window.location.replace(new URL('./demo/build/latest/', window.location.href).href);
34+
</script>
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)