vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Render images and 3D models in the browser views
3b2bcc30534f24b4628b6365e69dcb9065115065 · Keenan Nemetz · 13d ago · parent 87bab8e1
Render images and 3D models in the browser views A blob whose name is an image is served as that image, so the <img> a README already emitted works and the source view can show it. An SVG keeps its source view and previews on request. The instance introduction resolves assets/, so a landing-page picture is no longer a broken link. A changed image or model shows both sides in the commit, compare, and change request diffs, where git only says "binary". The 3D viewer is a vendored three.js bundle, loaded only when a page has a model, with a download fallback for a reader without JavaScript or WebGL. closes: 01M7XQ9AKKKFNEX0F679JRRYQD
docs/media.md +59
| @@ -0,0 +1,59 @@ | |||
| 1 | # Media previews | ||
| 2 | |||
| 3 | A repository holds more than source text. Vole shows a picture or a 3D model on | ||
| 4 | the surfaces that read a file: the code browser, a commit or compare diff, and | ||
| 5 | the Files tab of a change request. Markdown files use the same image support. | ||
| 6 | |||
| 7 | Nothing has to be rendered. A format with no useful source view (a PNG, a binary | ||
| 8 | STL) is shown in place of the source table. A text format that is also a model or | ||
| 9 | an image (SVG, OBJ, ASCII STL, glTF) keeps its source view and gains a `preview` | ||
| 10 | toggle, because the bytes are still the file. | ||
| 11 | |||
| 12 | ## Images | ||
| 13 | |||
| 14 | | Extensions | Served as | | ||
| 15 | |---|---| | ||
| 16 | | `.png` | `image/png` | | ||
| 17 | | `.jpg` `.jpeg` | `image/jpeg` | | ||
| 18 | | `.gif` | `image/gif` | | ||
| 19 | | `.webp` | `image/webp` | | ||
| 20 | | `.avif` | `image/avif` | | ||
| 21 | | `.bmp` | `image/bmp` | | ||
| 22 | | `.ico` | `image/x-icon` | | ||
| 23 | | `.svg` | `image/svg+xml` | | ||
| 24 | |||
| 25 | Raw bytes are served with the image's type, so an `<img>` works. Every other | ||
| 26 | extension stays `text/plain` and the response is `nosniff`, so an HTML file in a | ||
| 27 | repository is never rendered on the forge's origin. An SVG opened directly is | ||
| 28 | made inert by a Content-Security-Policy; as an image it renders normally. | ||
| 29 | |||
| 30 | In a Markdown document, an image path is resolved against the document, not the | ||
| 31 | page it is rendered on. A README beside `images/board.png` names that path. The | ||
| 32 | instance introduction resolves `assets/...` to the customization assets; see | ||
| 33 | [Instance customization](reference/instance-customization.md#images-in-the-introduction). | ||
| 34 | |||
| 35 | An image larger than 32 MiB is a download rather than an inline preview. | ||
| 36 | |||
| 37 | ## 3D models | ||
| 38 | |||
| 39 | | Extension | Format | | ||
| 40 | |---|---| | ||
| 41 | | `.stl` | STL, binary or ASCII | | ||
| 42 | | `.obj` | Wavefront OBJ geometry | | ||
| 43 | | `.gltf` | glTF (JSON) | | ||
| 44 | | `.glb` | glTF (binary) | | ||
| 45 | | `.3mf` | 3D Manufacturing Format | | ||
| 46 | |||
| 47 | The viewer runs in the browser and needs only the file: drag to orbit, scroll or | ||
| 48 | pinch to zoom, and use the buttons to reset the view or toggle a wireframe. It is | ||
| 49 | loaded on demand, so a page without a model downloads none of it. Without | ||
| 50 | JavaScript or WebGL, the file's download link stays visible. | ||
| 51 | |||
| 52 | A `.gltf` may name buffers and textures beside it; they are fetched through the | ||
| 53 | same raw path. A companion `.mtl` for an `.obj` is not loaded, so an OBJ arrives | ||
| 54 | as geometry with a plain material. | ||
| 55 | |||
| 56 | Compressed glTF assets are not supported. A model that uses Draco, KTX2, or | ||
| 57 | meshopt reports that it could not be loaded and keeps its download link. | ||
| 58 | |||
| 59 | A model larger than 64 MiB is a download rather than an inline preview. | ||