Merge some standalone Vite entries into index.js (#37085)

Keep `swagger` and `external-render-helper` as a standalone entries for
external render.

- Move `devtest.ts` to `modules/` as init functions
- Make external renders correctly load its helper JS and Gitea's current theme
- Make external render iframe inherit Gitea's iframe's background color to avoid flicker
- Add e2e tests for external render and OpenAPI iframe

---------

Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-04-05 21:13:34 +02:00
committed by GitHub
parent 5f443184f3
commit a8938115d4
35 changed files with 419 additions and 247 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
<link rel="stylesheet" href="{{AssetURI "css/index.css"}}">
<link rel="stylesheet" href="{{AssetURI (printf "css/theme-%s.css" (PathEscape ctx.CurrentWebTheme.InternalName))}}">
<link rel="stylesheet" href="{{ctx.CurrentWebTheme.PublicAssetURI}}">
-2
View File
@@ -1,3 +1 @@
{{/* TODO: the devtest.js is isolated from index.js, so no module is shared and many index.js functions do not work in devtest.ts */}}
<script type="module" src="{{AssetURI "js/devtest.js"}}"></script>
{{template "base/footer" ctx.RootData}}
+1 -5
View File
@@ -1,8 +1,4 @@
{{template "base/head" ctx.RootData}}
<link rel="stylesheet" href="{{AssetURI "css/devtest.css"}}">
<script>
// must make sure the jQuery is globally loaded
// ref: https://github.com/go-gitea/gitea/issues/35923
if (!window.jQuery) alert('jQuery is missing, user custom plugins may not work');
</script>
<div class="tw-hidden" data-global-init="initDevtestPage"></div>
{{template "base/alert" .}}
@@ -2,13 +2,15 @@
<html lang="en">
<head>
<title>Gitea API</title>
<link href="{{AssetURI "css/swagger.css"}}" rel="stylesheet">
{{/* HINT: SWAGGER-OPENAPI-VIEWER: another place is "modules/markup/external/openapi.go" */}}
<link rel="stylesheet" href="{{ctx.CurrentWebTheme.PublicAssetURI}}">
<link rel="stylesheet" href="{{AssetURI "css/swagger.css"}}">
</head>
<body>
{{/* TODO: add Help & Glossary to help users understand the API, and explain some concepts like "Owner" */}}
<a class="swagger-back-link" href="{{AppSubUrl}}/">{{svg "octicon-reply"}}{{ctx.Locale.Tr "return_to_gitea"}}</a>
<div id="swagger-ui" data-source="{{AppSubUrl}}/swagger.{{.APIJSONVersion}}.json"></div>
<div id="swagger-ui" data-source="{{AppSubUrl}}/swagger.v1.json"></div>
<footer class="page-footer"></footer>
<script type="module" src="{{AssetURI "js/swagger.js"}}"></script>
{{ScriptImport "js/swagger.js" "module"}}
</body>
</html>