mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
The Grafana mixin queried gitea_* while modules/metrics/collector.go emits hanzogit_*, so every stat panel rendered empty with no error. All twelve queried names now match names the collector registers. Issue templates sent security reports to [email protected] and help requests to upstream's Discord and forum, which SECURITY.md explicitly tells people not to do; both now point at [email protected] and our docs, and the issue search points at this repository. FUNDING.yml routed sponsorship to upstream's Open Collective, so it is gone. The VS Code build task wrote ./gitea. The Makefile, the README beside it and .gitignore all say gitd. Frontend: initGiteaFomantic, initGiteaAPIViewer and isGiteaError renamed for what they do; the Fomantic hard-fork markers read FORGE-PATCH; base.css named :gitea: as a CUSTOM_EMOJIS example, but the defaults are git, gitlab and github. Container paths are deliberately untouched. /data/gitea is GIT_WORK_DIR's default in docker/root/usr/local/bin/gitd, the deployment does not set GIT_WORK_DIR, and SSH_SERVER_HOST_KEYS is a relative path -- moving the work directory regenerates the host keys and every existing clone reports a changed host identity. /var/lib/gitea, /etc/gitea, gitea.db and gitea-trusted-user-ca-keys.pem keep their names because the matching defaults live in modules/setting, and a path renamed on one side only is a server that starts and then cannot find its own files. Co-authored-by: Hanzo Dev <[email protected]>
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
// AVOID importing other unneeded main site JS modules to prevent unnecessary code and dependencies and chunks.
|
|
// This module is used by both the API page and the frontend external render.
|
|
// It doesn't need any code from main site's modules (at the moment).
|
|
|
|
import SwaggerUI from 'swagger-ui-dist/swagger-ui-es-bundle.js';
|
|
import {load as loadYaml} from 'js-yaml';
|
|
|
|
function syncDarkModeClass(): void {
|
|
// if the viewer is embedded in an iframe (external render), use the parent's theme (passed via query param)
|
|
// otherwise, if it is for our own API, it is a standalone page, use the site's theme (detected from theme CSS variable)
|
|
const url = new URL(window.location.href);
|
|
const darkParam = url.searchParams.get('hanzo-is-dark-theme') ??
|
|
window.getComputedStyle(document.documentElement).getPropertyValue('--is-dark-theme').trim();
|
|
const isDark = darkParam ? darkParam === 'true' : window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
document.documentElement.classList.toggle('dark-mode', isDark);
|
|
}
|
|
|
|
export async function initSwaggerUI(container: HTMLElement, opts: {specText: string}): Promise<void> {
|
|
// swagger-ui has built-in dark mode triggered by html.dark-mode class
|
|
syncDarkModeClass();
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', syncDarkModeClass);
|
|
|
|
let spec: any;
|
|
const specText = opts.specText.trim();
|
|
if (specText.startsWith('{')) {
|
|
spec = JSON.parse(specText);
|
|
} else {
|
|
spec = loadYaml(specText);
|
|
}
|
|
|
|
// Make the page's protocol be at the top of the schemes list
|
|
const proto = window.location.protocol.slice(0, -1);
|
|
if (spec?.schemes) {
|
|
spec.schemes.sort((a: string, b: string) => {
|
|
if (a === proto) return -1;
|
|
if (b === proto) return 1;
|
|
return 0;
|
|
});
|
|
}
|
|
|
|
SwaggerUI({
|
|
spec,
|
|
domNode: container,
|
|
deepLinking: window.location.protocol !== 'about:', // pushState fails inside about:srcdoc iframes
|
|
docExpansion: 'none',
|
|
defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete
|
|
presets: [
|
|
SwaggerUI.presets.apis,
|
|
],
|
|
plugins: [
|
|
SwaggerUI.plugins.DownloadUrl,
|
|
],
|
|
});
|
|
}
|