Feat v0.6.5 renderer pipeline (#40)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #40.
This commit is contained in:
@@ -104,6 +104,8 @@ type PageData struct {
|
||||
|
||||
ExtensionSurfaces []ExtensionNavItem `json:"-"`
|
||||
|
||||
BrowserExtensions []string `json:"-"` // IDs of enabled browser-tier extensions (for script injection)
|
||||
|
||||
InstanceName string // branding: instance display name
|
||||
LogoURL string // branding: custom logo URL
|
||||
Tagline string // branding: tagline under instance name
|
||||
@@ -178,6 +180,29 @@ func (e *Engine) extensionNavItems() []ExtensionNavItem {
|
||||
return items
|
||||
}
|
||||
|
||||
// browserExtensionIDs returns IDs of enabled browser-tier extensions.
|
||||
// These extensions have JS scripts that should be injected into every page
|
||||
// so they can register renderers with the SDK.
|
||||
func (e *Engine) browserExtensionIDs() []string {
|
||||
if e.stores.Packages == nil {
|
||||
return nil
|
||||
}
|
||||
ctx := context.Background()
|
||||
pkgs, err := e.stores.Packages.List(ctx)
|
||||
if err != nil {
|
||||
log.Printf("[pages] Failed to load browser extensions: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
var ids []string
|
||||
for _, pkg := range pkgs {
|
||||
if pkg.Enabled && pkg.Type == "extension" && pkg.Tier == "browser" {
|
||||
ids = append(ids, pkg.ID)
|
||||
}
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// UserContext is the authenticated user's info available to templates.
|
||||
type UserContext struct {
|
||||
ID string `json:"id"`
|
||||
@@ -370,6 +395,7 @@ func (e *Engine) RenderSurface(surfaceID string) gin.HandlerFunc {
|
||||
Manifest: e.GetSurface(surfaceID),
|
||||
EnabledSurfaces: e.EnabledSurfaceIDs(),
|
||||
ExtensionSurfaces: e.extensionNavItems(),
|
||||
BrowserExtensions: e.browserExtensionIDs(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -431,6 +457,7 @@ func (e *Engine) RenderExtensionSurface() gin.HandlerFunc {
|
||||
Manifest: manifest,
|
||||
EnabledSurfaces: e.EnabledSurfaceIDs(),
|
||||
ExtensionSurfaces: e.extensionNavItems(),
|
||||
BrowserExtensions: e.browserExtensionIDs(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user