Documentation
¶
Index ¶
- Constants
- func AdminHeaderUI(r *http.Request, homeURL string) hb.TagInterface
- func Breadcrumbs(r *http.Request, pageBreadcrumbs []Breadcrumb) hb.TagInterface
- func BreadcrumbsUI(breadcrumbs []Breadcrumb) hb.TagInterface
- func CardUI(title string, body hb.TagInterface) hb.TagInterface
- func HTTPBuildQuery(queryData urlpkg.Values) string
- func NavCardUI(title string, href string, icon string, description string) hb.TagInterface
- func PaginationUI(currentPage int, totalPages int, urlFunc func(page int) string) hb.TagInterface
- func Query(queryData map[string]string) string
- func StatCardUI(title string, value string, icon string, color string) hb.TagInterface
- func StrTruncate(s string, maxLength int) string
- func URL(r *http.Request, path string, params map[string]string) string
- func UrlHome(r *http.Request, params ...map[string]string) string
- func UrlPageViewActivity(r *http.Request, params ...map[string]string) string
- func UrlVisitorActivity(r *http.Request, params ...map[string]string) string
- func UrlVisitorPaths(r *http.Request, params ...map[string]string) string
- type Breadcrumb
- type ContextKey
- type ControllerOptions
- type LayoutInterface
Constants ¶
const ( ControllerHome = "home" ControllerVisitorActivity = "visitor-activity" ControllerVisitorPaths = "visitor-paths" ControllerPageViewActivity = "page-view-activity" )
Controller name constants
const ( PathHome = "/admin/home" PathVisitorActivity = "/admin/visitor-activity" PathVisitorPaths = "/admin/visitor-paths" PathPageViewActivity = "/admin/page-view-activity" )
Path constants for admin routes
Variables ¶
This section is empty.
Functions ¶
func AdminHeaderUI ¶
func AdminHeaderUI(r *http.Request, homeURL string) hb.TagInterface
AdminHeaderUI creates the admin header navigation
func Breadcrumbs ¶
func Breadcrumbs(r *http.Request, pageBreadcrumbs []Breadcrumb) hb.TagInterface
Breadcrumbs creates a breadcrumb navigation component
func BreadcrumbsUI ¶
func BreadcrumbsUI(breadcrumbs []Breadcrumb) hb.TagInterface
BreadcrumbsUI generates the UI for breadcrumbs
func CardUI ¶
func CardUI(title string, body hb.TagInterface) hb.TagInterface
CardUI creates a standard card component
func HTTPBuildQuery ¶
HTTPBuildQuery converts URL values to a query string
func PaginationUI ¶
PaginationUI creates a pagination component
func StatCardUI ¶
StatCardUI creates a card displaying a single statistic
func StrTruncate ¶
StrTruncate truncates a string to the specified length and adds ellipsis if needed
func UrlPageViewActivity ¶ added in v0.7.0
func UrlVisitorActivity ¶
Types ¶
type Breadcrumb ¶
Breadcrumb represents a navigation breadcrumb
type ContextKey ¶
type ContextKey string
ContextKey is a custom type for context keys to avoid collisions
const ( KeyAdminHomeURL ContextKey = "admin_home_url" KeyEndpoint ContextKey = "endpoint" )
Context keys
type ControllerOptions ¶
type ControllerOptions struct {
Logger *slog.Logger
Store statsstore.StoreInterface
Layout LayoutInterface
HomeURL string
WebsiteUrl string
CountryNameByIso2 func(iso2Code string) (string, error)
}
ControllerOptions contains the options for creating a new admin controller
type LayoutInterface ¶
type LayoutInterface interface {
SetTitle(title string)
SetScriptURLs(scripts []string)
SetScripts(scripts []string)
SetStyleURLs(styles []string)
SetStyles(styles []string)
SetBody(string)
// SetCountryNameByIso2 provides country lookup helpers used by the admin UI.
SetCountryNameByIso2(func(iso2Code string) (string, error))
Render(w http.ResponseWriter, r *http.Request) string
}
LayoutInterface defines the layout methods needed by controllers