44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package ui
|
|
|
|
import (
|
|
"git.ourworld.tf/herocode/heroagent/pkg/servers/ui/routes" // Import the routes package
|
|
"github.com/gofiber/fiber/v2"
|
|
jetadapter "github.com/gofiber/template/jet/v2" // Aliased for clarity
|
|
)
|
|
|
|
// AppConfig holds the configuration for the UI application.
|
|
type AppConfig struct {
|
|
// Any specific configurations can be added here later
|
|
}
|
|
|
|
// NewApp creates and configures a new Fiber application for the UI.
|
|
func NewApp(config AppConfig) *fiber.App {
|
|
// Initialize Jet template engine
|
|
// Using OSFileSystemLoader to load templates from the filesystem.
|
|
// The path is relative to where the application is run.
|
|
// For development, InDevelopmentMode can be true to reload templates on each request.
|
|
engine := jetadapter.New("./pkg/servers/ui/views", ".jet")
|
|
|
|
// Enable template reloading for development.
|
|
// Set to false or remove this line for production.
|
|
engine.Reload(true)
|
|
|
|
// If you need to add custom functions or global variables to Jet:
|
|
// engine.AddFunc("myCustomFunc", func(arg jet.Arguments) reflect.Value { ... })
|
|
// engine.AddGlobal("myGlobalVar", "someValue")
|
|
|
|
// Create a new Fiber app with the configured Jet engine
|
|
app := fiber.New(fiber.Config{
|
|
Views: engine,
|
|
})
|
|
|
|
// Setup static file serving
|
|
// Files in ./pkg/servers/ui/static will be accessible via /static URL path
|
|
app.Static("/static", "./pkg/servers/ui/static")
|
|
|
|
// Setup routes
|
|
routes.SetupRoutes(app)
|
|
|
|
return app
|
|
}
|