shopstoreadmin

package module
v0.0.0-...-f261475 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

shopstoreadmin Open in Gitpod

Tests Status Go Report Card PkgGoDev

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Description

shopstoreadmin provides a UI for the shopstore library.

Usage

ui, err := shopstoreadmin.New(shopstoreadmin.NewUiOptions().
		SetLogger(&config.Logger).
		SetResponseWriter(w).
		SetRequest(r).
		SetLayout(NewShopAdminLayout()).
		SetStore(config.ShopStore))

if err != nil {
    config.Logger.Error("Error", "error", err.Error())
    w.WriteHeader(http.StatusInternalServerError)
    w.Write([]byte(err.Error()))

    return ""
}

return ui.ToHTML()
// ===========================================================================
// == LAYOUT
// ===========================================================================

var _ shopstoreadmin.Layout = (*shopAdminLayout)(nil)

func NewShopAdminLayout() shopstoreadmin.Layout {
	return &shopAdminLayout{}
}

type shopAdminLayout struct {
	title string
	body  string

	scriptURLs []string
	scripts    []string

	styleURLs []string
	styles    []string
}

func (a *shopAdminLayout) SetTitle(title string) {
	a.title = title
}

func (a *shopAdminLayout) SetBody(body string) {
	a.body = body
}

func (a *shopAdminLayout) SetScriptURLs(urls []string) {
	a.scriptURLs = urls
}

func (a *shopAdminLayout) SetScripts(scripts []string) {
	a.scripts = scripts
}

func (a *shopAdminLayout) SetStyleURLs(urls []string) {
	a.styleURLs = urls
}

func (a *shopAdminLayout) SetStyles(styles []string) {
	a.styles = styles
}

func (a *shopAdminLayout) Render(w http.ResponseWriter, r *http.Request) string {
	return layouts.NewAdminLayout(r, layouts.Options{
		Title:      a.title,
		Content:    hb.Raw(a.body),
		ScriptURLs: a.scriptURLs,
		Scripts:    a.scripts,
		StyleURLs:  a.styleURLs,
		Styles:     a.styles,
	}).ToHTML()
}

Documentation

Index

Constants

View Source
const ActionModalDiscountFilterShow = "modal_discount_filter_show"
View Source
const ActionModalProductFilterShow = "modal_product_filter_show"

Variables

This section is empty.

Functions

func New

func New(options UiOptionsInterface) (hb.TagInterface, error)

Types

type Layout

type Layout interface {
	SetTitle(title string)
	SetScriptURLs(scripts []string)
	SetScripts(scripts []string)
	SetStyleURLs(styles []string)
	SetStyles(styles []string)
	SetBody(string)
	Render(w http.ResponseWriter, r *http.Request) string
}

type UiOptionsInterface

type UiOptionsInterface interface {
	GetResponseWriter() http.ResponseWriter
	SetResponseWriter(http.ResponseWriter) UiOptionsInterface

	GetRequest() *http.Request
	SetRequest(*http.Request) UiOptionsInterface

	GetStore() shopstore.StoreInterface
	SetStore(shopstore.StoreInterface) UiOptionsInterface

	GetLogger() *slog.Logger
	SetLogger(*slog.Logger) UiOptionsInterface

	GetLayout() Layout
	SetLayout(Layout) UiOptionsInterface

	GetHomeURL() string
	SetHomeURL(string) UiOptionsInterface

	GetWebsiteUrl() string
	SetWebsiteUrl(string) UiOptionsInterface

	Validate() error
}

func NewUiOptions

func NewUiOptions() UiOptionsInterface

Jump to

Keyboard shortcuts

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