feat(settings): add home content customization and config injection
- Add home_content setting for custom homepage (HTML or iframe URL) - Inject public settings into index.html to eliminate page flash - Support ETag caching with automatic invalidation on settings update - Add Vite plugin for dev mode settings injection - Refactor HomeView to use appStore instead of local API calls
This commit is contained in:
@@ -4,11 +4,38 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// PublicSettingsProvider is an interface to fetch public settings
|
||||
// This stub is needed for compilation when frontend is not embedded
|
||||
type PublicSettingsProvider interface {
|
||||
GetPublicSettingsForInjection(ctx context.Context) (interface{}, error)
|
||||
}
|
||||
|
||||
// FrontendServer is a stub for non-embed builds
|
||||
type FrontendServer struct{}
|
||||
|
||||
// NewFrontendServer returns an error when frontend is not embedded
|
||||
func NewFrontendServer(settingsProvider PublicSettingsProvider) (*FrontendServer, error) {
|
||||
return nil, errors.New("frontend not embedded")
|
||||
}
|
||||
|
||||
// InvalidateCache is a no-op for non-embed builds
|
||||
func (s *FrontendServer) InvalidateCache() {}
|
||||
|
||||
// Middleware returns a handler that returns 404 for non-embed builds
|
||||
func (s *FrontendServer) Middleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.String(http.StatusNotFound, "Frontend not embedded. Build with -tags embed to include frontend.")
|
||||
c.Abort()
|
||||
}
|
||||
}
|
||||
|
||||
func ServeEmbeddedFrontend() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.String(http.StatusNotFound, "Frontend not embedded. Build with -tags embed to include frontend.")
|
||||
|
||||
Reference in New Issue
Block a user