ifcurl/forgejo/go.patch
Bruno Postle 39a2786872 Private repo previews, BCF import, SERVICE_TOKEN support
- GET /preview now accepts a token= query parameter, matching POST /preview
- Forgejo Go: add SERVICE_TOKEN config field; renderer appends it to <img src>
  preview URLs so a machine-user token can authenticate private repos
- Go tests: verify token appears in preview URL when set, absent when unset
- viewer.html: BCF import via drag-and-drop or Import .bcf button in BCF row;
  parses first viewpoint camera/clips/GUIDs and reloads with the viewpoint
  applied to the current model context
- viewer-url.js, viewer.html: unescape %24 → $ in URL building so GlobalIds
  with $ characters are human-readable in ifc:// URLs
- README: document SERVICE_TOKEN and private-repo preview configuration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 14:20:17 +01:00

32 lines
1.2 KiB
Diff

diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go
index 2b19e0f1c9..12be3e1c24 100644
--- a/modules/markup/markdown/markdown.go
+++ b/modules/markup/markdown/markdown.go
@@ -116,6 +116,7 @@ func SpecializedMarkdown() goldmark.Markdown {
math.NewExtension(
math.Enabled(setting.Markdown.EnableMath),
),
+ NewIfcURLExtension(),
),
goldmark.WithParserOptions(
parser.WithAttribute(),
diff --git a/modules/setting/markup.go b/modules/setting/markup.go
index 4ab9e7b2d1..c1fad254b4 100644
--- a/modules/setting/markup.go
+++ b/modules/setting/markup.go
@@ -59,8 +59,14 @@ type MarkupSanitizerRule struct {
AllowDataURIImages bool
}
+// IfcURL holds configuration for the ifcurl preview service integration.
+var IfcURL = struct {
+ PreviewServiceURL string `ini:"PREVIEW_SERVICE_URL"`
+ ServiceToken string `ini:"SERVICE_TOKEN"`
+}{}
+
func loadMarkupFrom(rootCfg ConfigProvider) {
mustMapSetting(rootCfg, "markdown", &Markdown)
+ mustMapSetting(rootCfg, "ifcurl", &IfcURL)
MermaidMaxSourceCharacters = rootCfg.Section("markup").Key("MERMAID_MAX_SOURCE_CHARACTERS").MustInt(50000)
FilePreviewMaxLines = rootCfg.Section("markup").Key("FILEPREVIEW_MAX_LINES").MustInt(50)