shared

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTROLLER_FILE_MANAGER = "file-manager"
)

Controller names used in the ?controller= query parameter

View Source
const CatchAll = "/*"

CatchAll is the catch-all route suffix

View Source
const KeyAdminHomeURL = "admin_home_url"
View Source
const KeyEndpoint = "endpoint"

Context keys for config values injected by Handle()

View Source
const KeyFileAdminURL = "file_admin_url"

Variables

This section is empty.

Functions

func AdminHomeURL

func AdminHomeURL(r *http.Request) string

AdminHomeURL returns the admin home URL from request context

func Breadcrumbs(breadcrumbs []Breadcrumb) hb.TagInterface

Breadcrumbs renders a breadcrumb navigation from the given items

func Endpoint

func Endpoint(r *http.Request) string

Endpoint returns the request endpoint URL from context

func ErrorAlert

func ErrorAlert(message string) string

ErrorAlert returns an inline HTML error alert for the given message.

func FileAdminURL

func FileAdminURL(r *http.Request) string

FileAdminURL returns the file admin base URL from request context

func Layout

func Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
	Styles     []string
	StyleURLs  []string
	Scripts    []string
	ScriptURLs []string
}) string

Layout is the default layout renderer. It builds a complete HTML page using hb.NewWebpage() with Bootstrap + Vue CDN, matching the shopadmin/blogadmin/logadmin pattern. If a FuncLayout is provided in AdminOptions, it takes precedence over this default.

func URL

func URL(endpoint string, controller string, params map[string]string) string

URL builds a URL for the given endpoint and controller with params. The controller is placed in the params map under the "controller" key. The params map is copied before mutation (does not modify caller's map).

func URLR

func URLR(r *http.Request, controller string, params map[string]string) string

URLR builds a URL using the endpoint from the request context.

Types

type Breadcrumb struct {
	Name string
	URL  string
}

Breadcrumb represents a single breadcrumb navigation item

type Links struct {
	// contains filtered or unexported fields
}

Links provides URL helpers for fileadmin controllers. The base URL is read from request context (injected by Handle()), not hardcoded. This follows the shopadmin/blogadmin/logadmin pattern.

func NewLinks(baseURL string) *Links

NewLinks creates a Links helper with the given base URL. If baseURL is empty, defaults to "/admin/file-manager".

func NewLinksFromRequest

func NewLinksFromRequest(r *http.Request) *Links

NewLinksFromRequest creates a Links helper using the file admin URL from the request context.

func (*Links) FileManager

func (l *Links) FileManager(params map[string]string) string

FileManager builds the URL for the file manager controller

type UiBase

type UiBase struct {
	StorageField     filesystem.StorageInterface
	RootDirPathField string
	LayoutField      func(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
		Styles     []string
		StyleURLs  []string
		Scripts    []string
		ScriptURLs []string
	}) string
}

UiBase is a base struct that implements shared.UiInterface. Subcontroller ui structs can embed this to get the Storage(), RootDirPath(), and Layout() methods for free, following the shopadmin/blogadmin/logadmin pattern.

func NewUiBase

func NewUiBase(config UiConfig) UiBase

NewUiBase creates a UiBase from a UiConfig

func (UiBase) Layout

func (u UiBase) Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
	Styles     []string
	StyleURLs  []string
	Scripts    []string
	ScriptURLs []string
}) string

func (UiBase) RootDirPath

func (u UiBase) RootDirPath() string

func (UiBase) Storage

func (u UiBase) Storage() filesystem.StorageInterface

type UiConfig

type UiConfig struct {
	Storage     filesystem.StorageInterface
	RootDirPath string
	Layout      func(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
		Styles     []string
		StyleURLs  []string
		Scripts    []string
		ScriptURLs []string
	}) string
}

UiConfig holds the dependencies passed to subcontroller UI factories. The Layout function uses an anonymous struct for options to match shopadmin/blogadmin/logadmin exactly, allowing consumers to reuse their existing layout function for fileadmin.

type UiInterface

type UiInterface interface {
	Storage() filesystem.StorageInterface
	RootDirPath() string

	Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, options struct {
		Styles     []string
		StyleURLs  []string
		Scripts    []string
		ScriptURLs []string
	}) string
}

UiInterface defines the methods every subcontroller UI must implement. This follows the shopadmin/blogadmin/logadmin pattern.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL