a845b744b7
HTML files now render in an iframe served from S3 (tinqs-git-preview bucket) instead of Gitea's raw endpoint which forces text/plain. SWR flow: first request uploads blob to S3 synchronously, subsequent requests redirect to presigned S3 URL instantly. When the blob SHA changes (new commit), the stale version is served immediately while the new version uploads in the background. Security: iframe uses sandbox="allow-scripts" only (no allow-same-origin). S3 is a different origin from git.arikigame.com, so even if JS runs in the iframe it cannot access Gitea session cookies or API tokens. Config: [html_preview] section in app.ini, disabled by default. Release pipeline auto-adds config on first deploy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
671 B
Go
30 lines
671 B
Go
// Copyright 2026 The Tinqs Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
// HTMLPreview represents the configuration for HTML file preview via S3.
|
|
// Configured via [html_preview] section in app.ini.
|
|
var HTMLPreview = struct {
|
|
Enabled bool
|
|
|
|
Storage *Storage
|
|
}{}
|
|
|
|
func loadHTMLPreviewFrom(rootCfg ConfigProvider) error {
|
|
sec, _ := rootCfg.GetSection("html_preview")
|
|
if sec == nil {
|
|
HTMLPreview.Enabled = false
|
|
return nil
|
|
}
|
|
|
|
HTMLPreview.Enabled = sec.Key("ENABLED").MustBool(false)
|
|
if !HTMLPreview.Enabled {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
HTMLPreview.Storage, err = getStorage(rootCfg, "html_preview", "", sec)
|
|
return err
|
|
}
|