codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

feat(file-icons): serve devicon file icons from our own assets #198

Merged
pat-s merged 1 commit from enh/vendor-devicons into v16.0/forgejo-codefloe 2026-10-01 11:53:21 +00:00
Owner

Serve the default devicon file icons from the instance's own assets instead of jsDelivr, so no visitor IP reaches a third-party CDN and icons no longer change or vanish with devicon's unpinned @latest.

Closes #189

Changes

  • public/assets/img/devicon/: add the 94 SVGs the mappings reference, pinned to devicon v2.17.0 and optimized with svgo (230 KB total), plus devicon's MIT LICENSE.
  • tools/generate-devicons.js and make devicons: vendor exactly the referenced files from the pinned release, plus a VERSION file; needs network, so it is a manual step, not a CI check.
  • web_src/js/features/devicon-map.js: move the mappings out of file-icons.js into a pure data module that the generator, the browser code and the test share, and hold the DEVICON_VERSION pin there.
  • .forgejo/renovate.json: track DEVICON_VERSION with a custom.regex manager (datasource github-tags, devicons/devicon). The shared preset automerges minor and patch updates with ignoreTests: true, and the bot's global config allows no post-upgrade commands, so Renovate can bump the pin but not regenerate the SVGs; this dependency therefore has automerge off and a PR note to run make devicons on the branch.
  • web_src/js/features/file-icons.js: build the <img> URL from assetUrlPrefix and add loading="lazy" and decoding="async".
  • Fix nine mappings that pointed at files devicon never shipped (they 404 on the CDN today): clojure, composer, crystal, gradle, mysql, subversion and yarn now use the -original variant, build.sbt uses the Scala icon, and .v/.vsh fall back to the generic file icon because devicon has no V icon.
  • Add the newly reachable dark crystal, gradle and scala-plain icons to the dark-mode inversion list, and drop the unmapped github-original entry.
  • web_src/js/features/file-icons.test.js: assert that the vendored VERSION matches the pin (so a bump-only Renovate PR fails CI), that every mapped icon exists on disk, that every inverted icon is mapped, and that icons load lazily from /assets/img/devicon/.
  • README.md: extend the "Icons & UI" row.

Behaviour change

  • File trees and diff file trees request icons from /assets/img/devicon/… instead of cdn.jsdelivr.net; the diff tree uses the same module, so it is covered too.
  • Files that showed a broken image (the nine mappings above) now show an icon, or the generic file icon for V.
  • Upgrading devicon is explicit: Renovate opens a PR bumping DEVICON_VERSION, which stays red until someone runs make devicons on it and commits the result.

Validation

  • Ran a local SQLite instance with a public repository holding 16 file types: in light and dark mode the page made no request outside the instance, all 15 icon requests answered 200, and all 16 icons decoded.
  • vitest for file-icons.test.js and DiffFileTreeItem.test.js passes; deleting one vendored SVG makes the coverage test fail and name the file.
  • Renovate 43 (the version crow-plugins/renovate bundles) validates .forgejo/renovate.json with --strict and, in a local run, extracts devicons/devicon at v2.17.0 from the new manager; the release lookup needs the bot's GitHub token, so I could not run it here.
  • Setting the pin to v2.18.0 without regenerating fails the version test; restoring it passes.
  • prek run -a passes (backend lint, swagger, frontend lint and type checking).

Follow-up

  • Several monochrome -plain icons (elixir, haskell, lua, ocaml, svelte, terraform and others) are black and nearly invisible in dark mode; that predates this change and is left for a separate fix.
Serve the default `devicon` file icons from the instance's own assets instead of jsDelivr, so no visitor IP reaches a third-party CDN and icons no longer change or vanish with devicon's unpinned `@latest`. Closes #189 ## Changes - `public/assets/img/devicon/`: add the 94 SVGs the mappings reference, pinned to devicon v2.17.0 and optimized with svgo (230 KB total), plus devicon's MIT `LICENSE`. - `tools/generate-devicons.js` and `make devicons`: vendor exactly the referenced files from the pinned release, plus a `VERSION` file; needs network, so it is a manual step, not a CI check. - `web_src/js/features/devicon-map.js`: move the mappings out of `file-icons.js` into a pure data module that the generator, the browser code and the test share, and hold the `DEVICON_VERSION` pin there. - `.forgejo/renovate.json`: track `DEVICON_VERSION` with a `custom.regex` manager (datasource `github-tags`, `devicons/devicon`). The shared preset automerges minor and patch updates with `ignoreTests: true`, and the bot's global config allows no post-upgrade commands, so Renovate can bump the pin but not regenerate the SVGs; this dependency therefore has automerge off and a PR note to run `make devicons` on the branch. - `web_src/js/features/file-icons.js`: build the `<img>` URL from `assetUrlPrefix` and add `loading="lazy"` and `decoding="async"`. - Fix nine mappings that pointed at files devicon never shipped (they 404 on the CDN today): clojure, composer, crystal, gradle, mysql, subversion and yarn now use the `-original` variant, `build.sbt` uses the Scala icon, and `.v`/`.vsh` fall back to the generic file icon because devicon has no V icon. - Add the newly reachable dark crystal, gradle and scala-plain icons to the dark-mode inversion list, and drop the unmapped `github-original` entry. - `web_src/js/features/file-icons.test.js`: assert that the vendored `VERSION` matches the pin (so a bump-only Renovate PR fails CI), that every mapped icon exists on disk, that every inverted icon is mapped, and that icons load lazily from `/assets/img/devicon/`. - `README.md`: extend the "Icons & UI" row. ## Behaviour change - File trees and diff file trees request icons from `/assets/img/devicon/…` instead of `cdn.jsdelivr.net`; the diff tree uses the same module, so it is covered too. - Files that showed a broken image (the nine mappings above) now show an icon, or the generic file icon for V. - Upgrading devicon is explicit: Renovate opens a PR bumping `DEVICON_VERSION`, which stays red until someone runs `make devicons` on it and commits the result. ## Validation - Ran a local SQLite instance with a public repository holding 16 file types: in light and dark mode the page made no request outside the instance, all 15 icon requests answered 200, and all 16 icons decoded. - `vitest` for `file-icons.test.js` and `DiffFileTreeItem.test.js` passes; deleting one vendored SVG makes the coverage test fail and name the file. - Renovate 43 (the version `crow-plugins/renovate` bundles) validates `.forgejo/renovate.json` with `--strict` and, in a local run, extracts `devicons/devicon` at `v2.17.0` from the new manager; the release lookup needs the bot's GitHub token, so I could not run it here. - Setting the pin to `v2.18.0` without regenerating fails the version test; restoring it passes. - `prek run -a` passes (backend lint, swagger, frontend lint and type checking). ## Follow-up - Several monochrome `-plain` icons (elixir, haskell, lua, ocaml, svelte, terraform and others) are black and nearly invisible in dark mode; that predates this change and is left for a separate fix.
pat-s force-pushed enh/vendor-devicons from 15c1a9c1df
Some checks failed
testing / frontend-checks (pull_request) Successful in 3m8s
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
testing / backend-checks (pull_request) Has been cancelled
to a20ec89d56
Some checks failed
testing / frontend-checks (pull_request) Failing after 2m38s
testing / backend-checks (pull_request) Successful in 18m56s
testing / test-unit (pull_request) Has been skipped
testing / test-pgsql (2/4) (pull_request) Has been skipped
testing / test-pgsql (1/4) (pull_request) Has been skipped
testing / test-e2e (pull_request) Has been skipped
testing / test-pgsql (3/4) (pull_request) Has been skipped
testing / test-pgsql (4/4) (pull_request) Has been skipped
2026-10-01 07:59:17 +00:00
Compare
pat-s force-pushed enh/vendor-devicons from a20ec89d56
Some checks failed
testing / frontend-checks (pull_request) Failing after 2m38s
testing / backend-checks (pull_request) Successful in 18m56s
testing / test-unit (pull_request) Has been skipped
testing / test-pgsql (2/4) (pull_request) Has been skipped
testing / test-pgsql (1/4) (pull_request) Has been skipped
testing / test-e2e (pull_request) Has been skipped
testing / test-pgsql (3/4) (pull_request) Has been skipped
testing / test-pgsql (4/4) (pull_request) Has been skipped
to d8fc78828a
Some checks failed
testing / frontend-checks (pull_request) Successful in 4m16s
testing / backend-checks (pull_request) Successful in 14m21s
testing / test-pgsql (2/4) (pull_request) Failing after 15m54s
testing / test-pgsql (4/4) (pull_request) Successful in 17m4s
testing / test-unit (pull_request) Successful in 17m43s
testing / test-pgsql (1/4) (pull_request) Successful in 18m49s
testing / test-pgsql (3/4) (pull_request) Successful in 19m52s
testing / test-e2e (pull_request) Successful in 1h7m42s
2026-10-01 09:05:42 +00:00
Compare
pat-s force-pushed enh/vendor-devicons from d8fc78828a
Some checks failed
testing / frontend-checks (pull_request) Successful in 4m16s
testing / backend-checks (pull_request) Successful in 14m21s
testing / test-pgsql (2/4) (pull_request) Failing after 15m54s
testing / test-pgsql (4/4) (pull_request) Successful in 17m4s
testing / test-unit (pull_request) Successful in 17m43s
testing / test-pgsql (1/4) (pull_request) Successful in 18m49s
testing / test-pgsql (3/4) (pull_request) Successful in 19m52s
testing / test-e2e (pull_request) Successful in 1h7m42s
to 2111f54830
All checks were successful
testing / test-pgsql (3/4) (pull_request) Successful in 15m19s
testing / test-unit (pull_request) Successful in 16m10s
milestone / set (pull_request_target) Has been skipped
issue-labels / backporting (pull_request_target) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m46s
testing / backend-checks (pull_request) Successful in 4m58s
testing / test-pgsql (2/4) (pull_request) Successful in 9m35s
testing / test-pgsql (4/4) (pull_request) Successful in 18m59s
testing / test-e2e (2/2) (pull_request) Successful in 6m3s
testing / test-pgsql (1/4) (pull_request) Successful in 13m20s
testing / test-e2e (1/2) (pull_request) Successful in 6m15s
2026-10-01 11:20:08 +00:00
Compare
pat-s merged commit db94a9a5fb into v16.0/forgejo-codefloe 2026-10-01 11:53:21 +00:00
pat-s deleted branch enh/vendor-devicons 2026-10-01 11:53:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!198
No description provided.