diff --git a/Dockerfile b/Dockerfile index 32e92bf..29dea3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,10 @@ RUN npm ci --omit=dev && mkdir /app/screenshot-cache && chown node:node /app/scr COPY server.mjs ./server.mjs COPY screenshot-cache.mjs ./screenshot-cache.mjs COPY public ./public +RUN mkdir -p public/vendor/prism \ + && cp node_modules/prismjs/components/prism-core.min.js public/vendor/prism/ \ + && cp node_modules/prismjs/components/prism-asm6502.min.js public/vendor/prism/ \ + && cp node_modules/prismjs/LICENSE public/vendor/prism/LICENSE COPY . /programs ENV PORT=8080 diff --git a/package-lock.json b/package-lock.json index d1421b3..10660ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,6 +6,7 @@ "": { "name": "c64-program-collection", "dependencies": { + "prismjs": "1.30.0", "sharp": "0.35.5" } }, @@ -528,6 +529,15 @@ "node": ">=8" } }, + "node_modules/prismjs": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", + "integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/semver": { "version": "7.8.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", diff --git a/package.json b/package.json index 5c00031..c56c2d5 100644 --- a/package.json +++ b/package.json @@ -2,5 +2,5 @@ "name": "c64-program-collection", "private": true, "type": "module", - "dependencies": { "sharp": "0.35.5" } + "dependencies": { "sharp": "0.35.5", "prismjs": "1.30.0" } } diff --git a/public/app.js b/public/app.js index af0eab6..a19e7dc 100644 --- a/public/app.js +++ b/public/app.js @@ -207,7 +207,7 @@ async function showSource(program) { try { const response = await fetch(`/api/source?path=${encodeURIComponent(program.path)}`, { cache: 'no-store' }); if (!response.ok) throw new Error('The program source could not be loaded.'); - sourceCode.querySelector('code').textContent = await response.text(); + highlightSource(sourceCode.querySelector('code'), program, await response.text()); sourceStatus.hidden = true; sourceCode.hidden = false; } catch (error) { @@ -273,7 +273,7 @@ async function loadInlineSource(program) { try { const response = await fetch(`/api/source?path=${encodeURIComponent(program.path)}`, { cache: 'no-store' }); if (!response.ok) throw new Error('The program source could not be loaded.'); - listing.querySelector('code').textContent = await response.text(); + highlightSource(listing.querySelector('code'), program, await response.text()); message.hidden = true; listing.hidden = false; } catch (error) { diff --git a/public/index.html b/public/index.html index edf8098..b97c23a 100644 --- a/public/index.html +++ b/public/index.html @@ -90,6 +90,9 @@
Loading sourceā¦
+
+
+