From 46f7f2a79f12706caa682c52db8fe1bce8e02789 Mon Sep 17 00:00:00 2001 From: butterrobot Date: Wed, 9 Sep 2026 19:21:50 +0000 Subject: [PATCH] FMG-8: link stlview.js to the Codeberg source in the guide A reader got stuck at step 3 because the post never says where the full stlview.js comes from: the only link to it was in the intro paragraph, and the code block in that step is an explanatory excerpt rather than the whole file. Link the source from the footer template step and from step 3 itself, say the snippets are partial, and note where each asset in the file tree comes from. Co-Authored-By: Claude Opus 5 (1M context) --- .../03/15/adding-stl-3d-previews-to-forgejo/index.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/content/blog/2026/03/15/adding-stl-3d-previews-to-forgejo/index.md b/content/blog/2026/03/15/adding-stl-3d-previews-to-forgejo/index.md index fdae74f..2cd8358 100644 --- a/content/blog/2026/03/15/adding-stl-3d-previews-to-forgejo/index.md +++ b/content/blog/2026/03/15/adding-stl-3d-previews-to-forgejo/index.md @@ -80,13 +80,13 @@ The footer loads the viewer script as an ES module: ``` -The `{{AppSubUrl}}` template variable ensures the path works even if Forgejo is served under a subpath. +The `{{AppSubUrl}}` template variable ensures the path works even if Forgejo is served under a subpath. [`stlview.js`](https://codeberg.org/Codeberg-Infrastructure/build-deploy-forgejo/src/branch/codeberg-8/etc/gitea/public/assets/stlview.js) is the viewer itself, which we add in the next step. ## Step 3: The Three.js viewer -The viewer script (`stlview.js`) is based on [Codeberg's implementation](https://codeberg.org/Codeberg-Infrastructure/build-deploy-forgejo/src/branch/codeberg-8/etc/gitea/public/assets/stlview.js). It uses Three.js r160 with ES modules, bundled locally so there's no CDN dependency. +The viewer script is based on [Codeberg's `stlview.js`](https://codeberg.org/Codeberg-Infrastructure/build-deploy-forgejo/src/branch/codeberg-8/etc/gitea/public/assets/stlview.js), so start by copying that file into `custom/public/assets/stlview.js`. It uses Three.js r160 with ES modules, bundled locally so there's no CDN dependency. -Here's the high-level flow: +The snippets below are there to explain what the script does, they are not the complete file. Here's the high-level flow: 1. **URL detection**: Check if the current page path ends with `.stl`. If not, bail out. 2. **Raw URL construction**: Replace `/src/` in the URL with `/raw/` to get the actual file download URL. @@ -134,6 +134,11 @@ custom/public/assets/ └── TrackballControls.js ``` +Where each file comes from: + +- `stlview.js`: [Codeberg's version](https://codeberg.org/Codeberg-Infrastructure/build-deploy-forgejo/src/branch/codeberg-8/etc/gitea/public/assets/stlview.js). +- `three.js/`: the [r160 release](https://github.com/mrdoob/three.js/releases/tag/r160) of Three.js, keeping only the three modules listed above. + ## Result Preview of an STL file in Forgejo -- 2.52.0