Documentation
¶
Index ¶
- Constants
- func AdminHomeURL(r *http.Request) string
- func BlogAdminURL(r *http.Request) string
- func Breadcrumbs(breadcrumbs []Breadcrumb) hb.TagInterface
- func Endpoint(r *http.Request) string
- func ErrorAlert(message string) string
- func ErrorPopup(errorMessage string) hb.TagInterface
- func FileManagerURL(r *http.Request) string
- func Header(store blogstore.StoreInterface, logger *slog.Logger, r *http.Request) hb.TagInterface
- func Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, ...) string
- func PostImageURL(ctx context.Context, store blogstore.StoreInterface, ...) string
- func SuccessPopup(successMessage string) hb.TagInterface
- func SuccessPopupWithRedirect(successMessage string, redirectUrl string, redirectSeconds int) hb.TagInterface
- func URL(endpoint string, controller string, params map[string]string) string
- func URLR(r *http.Request, controller string, params map[string]string) string
- type Breadcrumb
- type Links
- func (l *Links) AiPostContentUpdate(params map[string]string) string
- func (l *Links) AiPostEditor(params map[string]string) string
- func (l *Links) AiPostGenerator(params map[string]string) string
- func (l *Links) AiTest(params map[string]string) string
- func (l *Links) AiTitleGenerator(params map[string]string) string
- func (l *Links) AiTools(params map[string]string) string
- func (l *Links) BlogSettings(params map[string]string) string
- func (l *Links) CategoryManager(params map[string]string) string
- func (l *Links) Dashboard(params map[string]string) string
- func (l *Links) Home(params map[string]string) string
- func (l *Links) PostCreate(params map[string]string) string
- func (l *Links) PostDelete(params map[string]string) string
- func (l *Links) PostManager(params map[string]string) string
- func (l *Links) PostUpdate(params map[string]string) string
- func (l *Links) PostUpdateV1(params map[string]string) string
- func (l *Links) TagManager(params map[string]string) string
- type LlmFactoryFunc
- type UiBase
- func (u UiBase) CustomStore() customstore.StoreInterface
- func (u UiBase) Layout(w http.ResponseWriter, r *http.Request, webpageTitle, webpageHtml string, ...) string
- func (u UiBase) LlmEngine() (llm.LlmInterface, error)
- func (u UiBase) LlmFactory() LlmFactoryFunc
- func (u UiBase) Logger() *slog.Logger
- func (u UiBase) SettingStore() settingstore.StoreInterface
- func (u UiBase) Store() blogstore.StoreInterface
- type UiConfig
- type UiInterface
Constants ¶
const ( CONTROLLER_HOME = "home" CONTROLLER_POST_CREATE = "post-create" CONTROLLER_POST_DELETE = "post-delete" CONTROLLER_POST_MANAGER = "post-manager" CONTROLLER_POST_UPDATE = "post-update" CONTROLLER_POST_UPDATE_V1 = "post-update-v1" CONTROLLER_BLOG_SETTINGS = "blog-settings" CONTROLLER_AI_TOOLS = "ai-tools" CONTROLLER_AI_POST_CONTENT_UPDATE = "ai-post-content-update" CONTROLLER_AI_POST_GENERATOR = "ai-post-generator" CONTROLLER_AI_TITLE_GENERATOR = "ai-title-generator" CONTROLLER_AI_POST_EDITOR = "ai-post-editor" CONTROLLER_AI_TEST = "ai-test" CONTROLLER_DASHBOARD = "dashboard" CONTROLLER_CATEGORY_MANAGER = "category-manager" CONTROLLER_TAG_MANAGER = "tag-manager" )
Controller names used in the ?controller= query parameter
const CatchAll = "/*"
CatchAll is the catch-all route suffix
const ERROR_LOGGER_IS_NIL = "logger cannot be nil"
const ERROR_STORE_IS_NIL = "store cannot be nil"
Error messages
const KeyAdminHomeURL = "admin_home_url"
const KeyBlogAdminURL = "blog_admin_url"
const KeyEndpoint = "endpoint"
Context keys for config values injected by Handle()
const KeyFileManagerURL = "file_manager_url"
Variables ¶
This section is empty.
Functions ¶
func AdminHomeURL ¶
AdminHomeURL returns the admin home URL from request context
func BlogAdminURL ¶
BlogAdminURL returns the blog admin base URL from request context
func Breadcrumbs ¶
func Breadcrumbs(breadcrumbs []Breadcrumb) hb.TagInterface
Breadcrumbs renders a breadcrumb navigation from the given items
func ErrorAlert ¶
ErrorAlert returns an inline HTML error alert for the given message. This replaces the former ToFlashError flash-message pattern, which required a cache store and a /flash route handler that did not exist in the standalone module.
func ErrorPopup ¶
func ErrorPopup(errorMessage string) hb.TagInterface
ErrorPopup returns a SweetAlert2 error popup tag.
func FileManagerURL ¶
FileManagerURL returns the file manager URL from request context
func Header ¶
func Header(store blogstore.StoreInterface, logger *slog.Logger, r *http.Request) hb.TagInterface
Header renders the blog admin navigation header. It is nil-safe for both store and logger.
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 pattern. If a FuncLayout is provided in AdminOptions, it takes precedence over this default.
func PostImageURL ¶
func PostImageURL(ctx context.Context, store blogstore.StoreInterface, post blogstore.PostInterface) string
PostImageURL resolves the image URL for a post. It returns the first media URL (sorted by sequence) if media exists, using the /blog/media/<id>.<ext> route. Otherwise falls back to the post's ImageUrl field.
This replaces the former project/internal/rules.PostImageURL helper, keeping blogadmin decoupled from the host project.
func SuccessPopup ¶
func SuccessPopup(successMessage string) hb.TagInterface
SuccessPopup returns a SweetAlert2 success popup tag.
func SuccessPopupWithRedirect ¶
func SuccessPopupWithRedirect(successMessage string, redirectUrl string, redirectSeconds int) hb.TagInterface
SuccessPopupWithRedirect returns a SweetAlert2 success popup with an optional redirect. If redirectUrl is empty, no redirect is configured.
Types ¶
type Breadcrumb ¶
Breadcrumb represents a single breadcrumb navigation item
type Links ¶
type Links struct {
// contains filtered or unexported fields
}
Links provides URL helpers for blogadmin controllers. The base URL is read from request context (injected by Handle()), not hardcoded. This follows the shopadmin pattern.
func NewLinks ¶
NewLinks creates a Links helper with the given base URL. If baseURL is empty, defaults to "/admin/blog".
func NewLinksFromRequest ¶
NewLinksFromRequest creates a Links helper using the blog admin URL from the request context.
func (*Links) AiPostContentUpdate ¶
AiPostContentUpdate builds the URL for the AI post content update controller
func (*Links) AiPostEditor ¶
AiPostEditor builds the URL for the AI post editor controller
func (*Links) AiPostGenerator ¶
AiPostGenerator builds the URL for the AI post generator controller
func (*Links) AiTitleGenerator ¶
AiTitleGenerator builds the URL for the AI title generator controller
func (*Links) BlogSettings ¶
BlogSettings builds the URL for the blog settings controller
func (*Links) CategoryManager ¶
CategoryManager builds the URL for the category manager controller
func (*Links) PostCreate ¶
PostCreate builds the URL for the post create controller
func (*Links) PostDelete ¶
PostDelete builds the URL for the post delete controller
func (*Links) PostManager ¶
PostManager builds the URL for the post manager controller
func (*Links) PostUpdate ¶
PostUpdate builds the URL for the post update controller
func (*Links) PostUpdateV1 ¶
PostUpdateV1 builds the URL for the post update v1 controller
type LlmFactoryFunc ¶
type LlmFactoryFunc func() (llm.LlmInterface, error)
LlmFactoryFunc creates an LLM engine instance. The host project provides this so blogadmin does not depend on any specific config/auth package. Called by the AI controllers (ai_tools, ai_test, ai_post_generator, ai_title_generator, ai_post_editor, ai_post_content_update, and the regenerate-image flow in post_update).
If nil, AI controllers return an error to the user instead of panicking.
type UiBase ¶
type UiBase struct {
StoreField blogstore.StoreInterface
LoggerField *slog.Logger
CustomStoreField customstore.StoreInterface
SettingStoreField settingstore.StoreInterface
LlmFactoryField LlmFactoryFunc
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 Store(), Logger(), CustomStore(), SettingStore(), LlmFactory(), and Layout() methods for free, following the shopadmin pattern.
func (UiBase) CustomStore ¶
func (u UiBase) CustomStore() customstore.StoreInterface
func (UiBase) LlmFactory ¶
func (u UiBase) LlmFactory() LlmFactoryFunc
func (UiBase) SettingStore ¶
func (u UiBase) SettingStore() settingstore.StoreInterface
func (UiBase) Store ¶
func (u UiBase) Store() blogstore.StoreInterface
type UiConfig ¶
type UiConfig struct {
Store blogstore.StoreInterface
Logger *slog.Logger
CustomStore customstore.StoreInterface
SettingStore settingstore.StoreInterface
LlmFactory LlmFactoryFunc
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 cmsstore/admin and shopadmin exactly, allowing consumers to reuse their existing layout function for blogadmin.
AI controllers require CustomStore, SettingStore, and LlmFactory. Core controllers only need Store and Logger. Nil AI dependencies are safe — AI controllers return an error to the user instead of panicking.
type UiInterface ¶
type UiInterface interface {
Store() blogstore.StoreInterface
Logger() *slog.Logger
CustomStore() customstore.StoreInterface
SettingStore() settingstore.StoreInterface
LlmEngine() (llm.LlmInterface, error)
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 pattern.
AI controllers additionally use CustomStore(), SettingStore(), and LlmEngine(); core controllers only use Store(), Logger(), and Layout().