loading up the forgejo repo on tangled to test page performance

Add svg linter and fix incorrect svgs (#30086)

Fixes https://github.com/go-gitea/gitea/issues/30082.

Adds a new linter that searches for non-existant SVG images in
templates. Output before the fix was:

```
$ make lint-templates
SVG "octicon-warning" not found, used in templates/devtest/flex-list.tmpl
SVG "octicon-warning" not found, used in templates/devtest/flex-list.tmpl
SVG "octicon-markup" not found, used in templates/repo/diff/comment_form.tmpl
make: *** [Makefile:438: lint-templates] Error 1
```

<img width="306" alt="Screenshot 2024-03-25 at 23 31 05"
src="https://github.com/go-gitea/gitea/assets/115237/1052d1a9-bfec-4d5a-9cae-f895f78f7c93">

(cherry picked from commit 2ab5f05f40d93224f73e211e84de50a88a6ecf03)

Conflicts:
.github/workflows/files-changed.yml
.github/workflows/pull-compliance.yml
do not exist in Forgejo and the Forgejo workflows
already contain the changes

authored by silverwind and committed by Earl Warren 72a3a6fd e93e2982

Changed files
+31 -4
templates
devtest
repo
tools
+2 -1
Makefile
··· 458 458 $(GO) run $(ACTIONLINT_PACKAGE) 459 459 460 460 .PHONY: lint-templates 461 - lint-templates: .venv 461 + lint-templates: .venv node_modules 462 + @node tools/lint-templates-svg.js 462 463 @poetry run djlint $(shell find templates -type f -iname '*.tmpl') 463 464 464 465 .PHONY: lint-yaml
+2 -2
templates/devtest/flex-list.tmpl
··· 25 25 </div> 26 26 <div class="flex-item-trailing"> 27 27 <button class="ui tiny red button"> 28 - {{svg "octicon-warning" 14}} CJK文本测试 28 + {{svg "octicon-alert" 14}} CJK文本测试 29 29 </button> 30 30 <button class="ui tiny primary button"> 31 31 {{svg "octicon-info" 14}} Button ··· 54 54 </div> 55 55 <div class="flex-item-trailing"> 56 56 <button class="ui tiny red button"> 57 - {{svg "octicon-warning" 12}} CJK文本测试 <!-- single CJK text test, it shouldn't be horizontal --> 57 + {{svg "octicon-alert" 12}} CJK文本测试 <!-- single CJK text test, it shouldn't be horizontal --> 58 58 </button> 59 59 </div> 60 60 </div>
+1 -1
templates/repo/diff/comment_form.tmpl
··· 26 26 {{end}} 27 27 28 28 <div class="field footer tw-mx-2"> 29 - <span class="markup-info">{{svg "octicon-markup"}} {{ctx.Locale.Tr "repo.diff.comment.markdown_info"}}</span> 29 + <span class="markup-info">{{svg "octicon-markdown"}} {{ctx.Locale.Tr "repo.diff.comment.markdown_info"}}</span> 30 30 <div class="tw-text-right"> 31 31 {{if $.reply}} 32 32 <button class="ui submit primary tiny button btn-reply" type="submit">{{ctx.Locale.Tr "repo.diff.comment.reply"}}</button>
+26
tools/lint-templates-svg.js
··· 1 + #!/usr/bin/env node 2 + import {readdirSync, readFileSync} from 'node:fs'; 3 + import {parse, relative} from 'node:path'; 4 + import {fileURLToPath} from 'node:url'; 5 + import {exit} from 'node:process'; 6 + import fastGlob from 'fast-glob'; 7 + 8 + const knownSvgs = new Set(); 9 + for (const file of readdirSync(new URL('../public/assets/img/svg', import.meta.url))) { 10 + knownSvgs.add(parse(file).name); 11 + } 12 + 13 + const rootPath = fileURLToPath(new URL('..', import.meta.url)); 14 + let hadErrors = false; 15 + 16 + for (const file of fastGlob.sync(fileURLToPath(new URL('../templates/**/*.tmpl', import.meta.url)))) { 17 + const content = readFileSync(file, 'utf8'); 18 + for (const [_, name] of content.matchAll(/svg ["'`]([^"'`]+)["'`]/g)) { 19 + if (!knownSvgs.has(name)) { 20 + console.info(`SVG "${name}" not found, used in ${relative(rootPath, file)}`); 21 + hadErrors = true; 22 + } 23 + } 24 + } 25 + 26 + exit(hadErrors ? 1 : 0);