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
server/web/static/vole.css +100−1
| @@ -1181,6 +1181,83 @@ pre code { background: none; border: 0; padding: 0; font-size: inherit; } | |||
| 1181 | 1181 | .inline-comment-form .form-actions { margin-top: 0; } | |
| 1182 | 1182 | .diff .binary { padding: 10px 12px; color: var(--fg-muted); font-size: calc(13.2px * var(--font-scale)); margin: 0; } | |
| 1183 | 1183 | ||
| 1184 | /* The two sides of a picture change. Each side is its own figure so a deletion | ||
| 1185 | or an addition can show the one that exists, and the pair wraps rather than | ||
| 1186 | shrinking below a readable width. */ | ||
| 1187 | .media-diff { | ||
| 1188 | display: flex; | ||
| 1189 | flex-wrap: wrap; | ||
| 1190 | gap: 12px; | ||
| 1191 | padding: 12px; | ||
| 1192 | border-bottom: 1px solid var(--border); | ||
| 1193 | } | ||
| 1194 | .media-diff figure { flex: 1 1 240px; margin: 0; min-width: 0; text-align: center; } | ||
| 1195 | .media-diff img { | ||
| 1196 | max-width: 100%; | ||
| 1197 | max-height: 50vh; | ||
| 1198 | border-radius: var(--radius); | ||
| 1199 | background: var(--bg-raised); | ||
| 1200 | } | ||
| 1201 | .media-diff figcaption { margin-top: 4px; font-size: calc(12.1px * var(--font-scale)); } | ||
| 1202 | |||
| 1203 | /* A 3D preview owns a fixed box, because the canvas is sized from its element. | ||
| 1204 | The server writes a download link inside the box; the viewer removes it once | ||
| 1205 | the mesh is drawn, and leaves it for a reader without JavaScript or WebGL. */ | ||
| 1206 | .model-viewer { | ||
| 1207 | position: relative; | ||
| 1208 | height: min(64vh, 560px); | ||
| 1209 | min-height: 260px; | ||
| 1210 | margin: 12px 0 20px; | ||
| 1211 | border: 1px solid var(--border); | ||
| 1212 | border-radius: var(--radius-lg); | ||
| 1213 | background: var(--bg-raised); | ||
| 1214 | overflow: hidden; | ||
| 1215 | } | ||
| 1216 | .model-canvas { | ||
| 1217 | position: absolute; | ||
| 1218 | inset: 0; | ||
| 1219 | display: block; | ||
| 1220 | width: 100%; | ||
| 1221 | height: 100%; | ||
| 1222 | touch-action: none; | ||
| 1223 | } | ||
| 1224 | .model-fallback { | ||
| 1225 | position: absolute; | ||
| 1226 | inset: 0; | ||
| 1227 | margin: 0; | ||
| 1228 | padding: 16px; | ||
| 1229 | display: grid; | ||
| 1230 | place-content: center; | ||
| 1231 | text-align: center; | ||
| 1232 | color: var(--fg-muted); | ||
| 1233 | } | ||
| 1234 | .model-fallback a { color: var(--accent); } | ||
| 1235 | .model-status { | ||
| 1236 | position: absolute; | ||
| 1237 | left: 12px; | ||
| 1238 | right: 12px; | ||
| 1239 | bottom: 10px; | ||
| 1240 | margin: 0; | ||
| 1241 | text-align: center; | ||
| 1242 | font-size: calc(12.65px * var(--font-scale)); | ||
| 1243 | pointer-events: none; | ||
| 1244 | } | ||
| 1245 | .model-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; } | ||
| 1246 | .model-tool { | ||
| 1247 | font: inherit; | ||
| 1248 | font-size: calc(12.65px * var(--font-scale)); | ||
| 1249 | padding: 4px 10px; | ||
| 1250 | border: 1px solid var(--border-strong); | ||
| 1251 | border-radius: var(--radius); | ||
| 1252 | background: var(--bg-panel); | ||
| 1253 | color: var(--fg-muted); | ||
| 1254 | cursor: pointer; | ||
| 1255 | } | ||
| 1256 | .model-tool:hover { color: var(--fg); border-color: var(--accent); } | ||
| 1257 | .model-tool.active { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); } | ||
| 1258 | /* A diff pane is narrower and there may be two of them, so the box is shorter. */ | ||
| 1259 | .media-diff .model-viewer { height: 320px; min-height: 220px; margin: 0; } | ||
| 1260 | |||
| 1184 | 1261 | /* ---------- shared responsive rules ---------- */ | |
| 1185 | 1262 | ||
| 1186 | 1263 | @media (max-width: 720px) { | |
| @@ -1378,7 +1455,9 @@ td.fit { width: 1%; white-space: nowrap; } | |||
| 1378 | 1455 | .code-tabbar + .panel, | |
| 1379 | 1456 | .code-tabbar + .filebody, | |
| 1380 | 1457 | .code-tabbar + .card, | |
| 1381 | .code-tabbar + .readme { | ||
| 1458 | .code-tabbar + .readme, | ||
| 1459 | .code-tabbar + .media-preview, | ||
| 1460 | .code-tabbar + .model-viewer { | ||
| 1382 | 1461 | margin-top: 0; | |
| 1383 | 1462 | border-top: 0; | |
| 1384 | 1463 | border-top-left-radius: 0; | |
| @@ -1545,6 +1624,24 @@ details[open] > summary .tree-chevron { transform: rotate(90deg); } | |||
| 1545 | 1624 | .blob td.code { padding-left: 12px; } | |
| 1546 | 1625 | .blob tr:hover { background: none; } | |
| 1547 | 1626 | ||
| 1627 | /* A blob that is a picture is the picture. The raised background makes a | ||
| 1628 | transparent image readable against either theme, and the height cap keeps a | ||
| 1629 | tall render from pushing the download link off the page. */ | ||
| 1630 | .media-preview { | ||
| 1631 | margin: 12px 0 20px; | ||
| 1632 | padding: 12px; | ||
| 1633 | border: 1px solid var(--border); | ||
| 1634 | border-radius: var(--radius-lg); | ||
| 1635 | background: var(--bg-panel); | ||
| 1636 | text-align: center; | ||
| 1637 | } | ||
| 1638 | .media-preview img { | ||
| 1639 | max-width: 100%; | ||
| 1640 | max-height: 70vh; | ||
| 1641 | border-radius: var(--radius); | ||
| 1642 | background: var(--bg-raised); | ||
| 1643 | } | ||
| 1644 | |||
| 1548 | 1645 | /* ---------- syntax highlighting ---------- */ | |
| 1549 | 1646 | ||
| 1550 | 1647 | /* static/prism-worker.js writes Prism token classes into blob and diff cells | |
| @@ -3009,6 +3106,7 @@ textarea:focus-visible { | |||
| 3009 | 3106 | .tree-icon.lang-text, .dirlist a.file.lang-text .icon { color: #519aba; } | |
| 3010 | 3107 | .tree-icon.lang-sql, .dirlist a.file.lang-sql .icon { color: #e38c00; } | |
| 3011 | 3108 | .tree-icon.lang-image, .dirlist a.file.lang-image .icon { color: #a074c4; } | |
| 3109 | .tree-icon.lang-model, .dirlist a.file.lang-model .icon { color: #59b8a8; } | ||
| 3012 | 3110 | .tree-icon.lang-lock, .dirlist a.file.lang-lock .icon { color: var(--fg-muted); } | |
| 3013 | 3111 | .tree-icon.lang-build, .dirlist a.file.lang-build .icon { color: var(--fg-muted); } | |
| 3014 | 3112 | ||
| @@ -3031,6 +3129,7 @@ textarea:focus-visible { | |||
| 3031 | 3129 | .lang-dot.lang-text { background: #519aba; } | |
| 3032 | 3130 | .lang-dot.lang-sql { background: #e38c00; } | |
| 3033 | 3131 | .lang-dot.lang-image { background: #a074c4; } | |
| 3132 | .lang-dot.lang-model { background: #59b8a8; } | ||
| 3034 | 3133 | .lang-dot.lang-lock, .lang-dot.lang-build { background: var(--fg-muted); } | |
| 3035 | 3134 | ||
| 3036 | 3135 | /* ---------- profiles and the account directory ---------- */ | |