2.0 KB
dashboard.go
package controllers
import (
"cmp"
"net/http"
"github.com/readysite/readysite/pkg/application"
"github.com/readysite/readysite/website/internal/helpers"
"github.com/readysite/readysite/website/models"
)
// Dashboard returns the dashboard controller.
func Dashboard() (string, *DashboardController) {
return "dashboard", &DashboardController{}
}
// DashboardController handles the admin dashboard.
type DashboardController struct {
application.BaseController
}
// Setup registers routes.
func (c *DashboardController) Setup(app *application.App) {
c.BaseController.Setup(app)
// All routes now handled by WorkspaceController
}
// Handle implements Controller interface with value receiver for request isolation.
func (c DashboardController) Handle(r *http.Request) application.Controller {
c.Request = r
return &c
}
// AIConfigured returns true if AI is configured.
func (c *DashboardController) AIConfigured() bool {
provider := helpers.GetSetting(models.SettingAIProvider)
apiKey := helpers.GetSetting(models.SettingAIAPIKey)
return provider != "" && provider != "mock" && apiKey != ""
}
// AIProvider returns the currently configured AI provider.
func (c *DashboardController) AIProvider() string {
provider := helpers.GetSetting(models.SettingAIProvider)
if provider == "" {
return "mock"
}
return provider
}
// AIModel returns the currently configured AI model.
func (c *DashboardController) AIModel() string {
return cmp.Or(helpers.GetSetting(models.SettingAIModel), "claude-sonnet-4-5-20250929")
}
// SiteName returns the configured site name.
func (c *DashboardController) SiteName() string {
return cmp.Or(helpers.GetSetting(models.SettingSiteName), "My Website")
}
// SiteDescription returns the configured site description.
func (c *DashboardController) SiteDescription() string {
return helpers.GetSetting(models.SettingSiteDescription)
}
// SignupEnabled returns true if public signup is enabled.
func (c *DashboardController) SignupEnabled() bool {
return helpers.GetSetting(models.SettingSignupEnabled) == "true"
}