component

package
v0.4.54-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedExtensions = map[string]bool{
	".jpg":  true,
	".jpeg": true,
	".png":  true,
	".gif":  true,
	".svg":  true,
}

Functions

func APIConfigGetName

func APIConfigGetName() string

func APIConfigGetName_test

func APIConfigGetName_test(t *testing.T)

func CssConfigGetName

func CssConfigGetName() string

func FilterAllowedQueryParams

func FilterAllowedQueryParams(req *http.Request, allowedKeys []string) url.Values

FilterAllowedQueryParams returns only the query parameters whose keys are in allowedKeys. If allowedKeys is empty, it returns an empty url.Values (no parameters).

func HTMLConfigGetName

func HTMLConfigGetName() string

func JavaScriptConfigGetName

func JavaScriptConfigGetName() string

func LocalJSONConfigGetName

func LocalJSONConfigGetName() string
func MenuConfigGetName() string

func MultipleImagesConfigGetName

func MultipleImagesConfigGetName() string

func PluginRenderGetName

func PluginRenderGetName() string

func SingleImageConfigGetName

func SingleImageConfigGetName() string

func SortHyperMediasBySection

func SortHyperMediasBySection(pagesBySection map[string][]composite.HyperMediaConfig, options SortOptions) (map[string][]composite.HyperMediaConfig, error)

func StyleConfigGetName

func StyleConfigGetName() string

func TextConfigGetName

func TextConfigGetName() string

Types

type APIConfig

type APIConfig struct {
	shared.Component   `mapstructure:",squash"`
	ApiRenderConfig    `mapstructure:",squash"`
	MetaDocDescription string `mapstructure:"@doc" description:"<API_RENDER> description" example:"{!{api-render-@doc.hyperbricks}}"`
}

func (*APIConfig) Validate

func (api *APIConfig) Validate() []error

type APIRenderer

type APIRenderer struct {
	renderer.ComponentRenderer
}

func (*APIRenderer) Render

func (pr *APIRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*APIRenderer) Types

func (r *APIRenderer) Types() []string

type ApiRenderConfig

type ApiRenderConfig struct {
	Endpoint         string                 `mapstructure:"endpoint" validate:"required" description:"The API endpoint" example:"{!{api-render-endpoint.hyperbricks}}"`
	Method           string                 `` /* 162-byte string literal not displayed */
	Headers          map[string]string      `mapstructure:"headers" description:"Optional HTTP headers for API requests" example:"{!{api-render-headers.hyperbricks}}"`
	Body             string                 `` /* 205-byte string literal not displayed */
	Template         string                 `` /* 152-byte string literal not displayed */
	Inline           string                 `` /* 168-byte string literal not displayed */
	Values           map[string]interface{} `mapstructure:"values" description:"Key-value pairs for template rendering" example:"{!{api-render-values.hyperbricks}}"`
	Username         string                 `mapstructure:"username" description:"Username for basic auth" example:"{!{api-render-username.hyperbricks}}"`
	Password         string                 `mapstructure:"password" description:"Password for basic auth" example:"{!{api-render-password.hyperbricks}}"`
	Status           int                    `mapstructure:"status" exclude:"true"` // This adds {{.Status}} to the root level of the template data
	SetCookie        string                 `mapstructure:"setcookie" description:"Set template for cookie" example:"{!{api-render-setcookie.hyperbricks}}"`
	AllowedQueryKeys []string               `mapstructure:"querykeys" description:"Set allowed proxy query keys" example:"{!{api-render-querykeys.hyperbricks}}"`
	QueryParams      map[string]string      `` /* 131-byte string literal not displayed */
	JwtSecret        string                 `` /* 221-byte string literal not displayed */
	JwtClaims        map[string]string      `mapstructure:"jwtclaims" description:"jwt claim map" example:"{!{api-render-jwt-claims.hyperbricks}}"`
	Debug            bool                   `mapstructure:"debug" description:"Debug the response data" example:"{!{api-render-debug.hyperbricks}}"`
	DebugPanel       bool                   `` /* 190-byte string literal not displayed */
}

type CssConfig

type CssConfig struct {
	shared.Component `mapstructure:",squash"`
	Inline           string `` /* 147-byte string literal not displayed */
	Link             string `mapstructure:"link" description:"Use link for a link tag" example:"{!{css-link.hyperbricks}}"`
	File             string `` /* 160-byte string literal not displayed */
}

func (*CssConfig) Validate

func (css *CssConfig) Validate() []error

type CssRenderer

type CssRenderer struct{}

func (*CssRenderer) Render

func (sr *CssRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*CssRenderer) Types

func (r *CssRenderer) Types() []string

type HTMLConfig

type HTMLConfig struct {
	shared.Component `mapstructure:",squash"`
	Value            string `mapstructure:"value" validate:"required" description:"The raw HTML content" example:"{!{html-value.hyperbricks}}"`
	TrimSpace        bool   `` /* 168-byte string literal not displayed */
}

func (*HTMLConfig) Validate

func (hc *HTMLConfig) Validate() []error

type HTMLRenderer

type HTMLRenderer struct{}

func (*HTMLRenderer) Render

func (hr *HTMLRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*HTMLRenderer) Types

func (r *HTMLRenderer) Types() []string

type HyperMediaConfig

type HyperMediaConfig struct {
	Title string `json:"title"`
	Route string `json:"route"`
	Index int    `json:"index"`
}

type ImageProcessor

type ImageProcessor struct{}

func (*ImageProcessor) ProcessMultipleImages

func (ir *ImageProcessor) ProcessMultipleImages(config MultipleImagesConfig) (string, error)

func (*ImageProcessor) ProcessSingleImage

func (ir *ImageProcessor) ProcessSingleImage(config SingleImageConfig) (string, error)

func (*ImageProcessor) Render

func (ir *ImageProcessor) Render(instance interface{}, ctx context.Context) (string, error)

type JavaScriptConfig

type JavaScriptConfig struct {
	shared.Component `mapstructure:",squash"`
	Inline           string `` /* 168-byte string literal not displayed */
	Link             string `mapstructure:"link" description:"Use link for a script tag with a src attribute" example:"{!{javascript-link.hyperbricks}}"`
	File             string `` /* 168-byte string literal not displayed */
}

func (*JavaScriptConfig) Validate

func (js *JavaScriptConfig) Validate() []error

type JavaScriptRenderer

type JavaScriptRenderer struct{}

func (*JavaScriptRenderer) Render

func (jsr *JavaScriptRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*JavaScriptRenderer) Types

func (r *JavaScriptRenderer) Types() []string

type LocalJSONConfig

type LocalJSONConfig struct {
	shared.Component `mapstructure:",squash"`
	FilePath         string                 `mapstructure:"file" validate:"required" description:"Path to the local JSON file" example:"{!{json-file.hyperbricks}}"`
	Template         string                 `` /* 146-byte string literal not displayed */
	Inline           string                 `` /* 167-byte string literal not displayed */
	Values           map[string]interface{} `mapstructure:"values" description:"Key-value pairs for template rendering" example:"{!{json-values.hyperbricks}}"`
	Debug            bool                   `mapstructure:"debug" description:"Debug the response data" example:"{!{json-debug.hyperbricks}}"`
}

func (*LocalJSONConfig) Validate

func (config *LocalJSONConfig) Validate() []error

type LocalJSONRenderer

type LocalJSONRenderer struct {
	TemplateProvider func(templateName string) (string, bool)
}

func (*LocalJSONRenderer) Render

func (renderer *LocalJSONRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*LocalJSONRenderer) Types

func (r *LocalJSONRenderer) Types() []string
type MenuConfig struct {
	shared.Component     `mapstructure:",squash"`
	Section              string `` /* 132-byte string literal not displayed */
	Order                string `` /* 148-byte string literal not displayed */
	Sort                 string `` /* 169-byte string literal not displayed */
	Active               string `` /* 129-byte string literal not displayed */
	Item                 string `mapstructure:"item" validate:"required" description:"Template for regular menu items." example:"{!{menu-item.hyperbricks}}"`
	Enclose              string `mapstructure:"enclose" description:"Template to enclose the menu items." example:"{!{menu-enclose.hyperbricks}}"`
	HyperMediasBySection map[string][]composite.HyperMediaConfig
}
func (mc *MenuConfig) Validate() []error
type MenuRenderer struct {
	TemplateProvider     func(templateName string) (string, bool)
	HyperMediasBySection map[string][]composite.HyperMediaConfig
	CurrentRoute         string
}
func (mr *MenuRenderer) Render(instance interface{}, ctx context.Context) (string, []error)
func (r *MenuRenderer) Types() []string

type MultipleImagesConfig

type MultipleImagesConfig struct {
	shared.Component `mapstructure:",squash"`
	Directory        string `` /* 143-byte string literal not displayed */
	Width            int    `` /* 147-byte string literal not displayed */
	Height           int    `` /* 150-byte string literal not displayed */
	Id               string `mapstructure:"id" description:"Id of images with a index added to it" example:"{!{images-id.hyperbricks}}"`
	Class            string `mapstructure:"class" description:"CSS class for styling the image" example:"{!{images-class.hyperbricks}}"`
	IsStatic         bool   `mapstructure:"is_static" description:"Flag indicating if the images are static" example:"{!{images-is_static.hyperbricks}}"`
	Alt              string `mapstructure:"alt" description:"Alternative text for the image" example:"{!{images-alt.hyperbricks}}"`
	Title            string `mapstructure:"title" description:"The title attribute of the image" example:"{!{images-title.hyperbricks}}"`
	Quality          int    `mapstructure:"quality" description:"Image quality for optimization" example:"{!{images-quality.hyperbricks}}"`
	Loading          string `mapstructure:"loading" description:"Lazy loading strategy (e.g., 'lazy', 'eager')" example:"{!{images-loading.hyperbricks}}"`
}

func (*MultipleImagesConfig) Validate

func (config *MultipleImagesConfig) Validate() []error

type MultipleImagesRenderer

type MultipleImagesRenderer struct {
	ImageProcessorInstance *ImageProcessor
}

func (*MultipleImagesRenderer) Render

func (mir *MultipleImagesRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*MultipleImagesRenderer) Types

func (r *MultipleImagesRenderer) Types() []string

type PluginConfig

type PluginConfig struct {
	shared.Component `mapstructure:",squash"`
	PluginName       string                 `mapstructure:"plugin"  description:"Name of the plugin for lookup"`
	Classes          []string               `mapstructure:"classes" description:"Optional CSS classes for the link" example:"{!{plugin-classes.hyperbricks}}"`
	Data             map[string]interface{} `mapstructure:"data"`
}

type PluginRenderer

type PluginRenderer struct {
	renderer.CompositeRenderer
}

func (*PluginRenderer) LoadAndRender

func (r *PluginRenderer) LoadAndRender(instance interface{}, ctx context.Context) (string, []error)

func (*PluginRenderer) Render

func (r *PluginRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*PluginRenderer) Types

func (r *PluginRenderer) Types() []string

type RenderImageConfig

type RenderImageConfig struct {
	Single   *SingleImageConfig    `mapstructure:"single"`
	Multiple *MultipleImagesConfig `mapstructure:"multiple"`
}

type SingleImageConfig

type SingleImageConfig struct {
	shared.Component `mapstructure:",squash"`
	Src              string `mapstructure:"src" validate:"required" description:"The source URL of the image" example:"{!{image-src.hyperbricks}}"`
	Width            int    `` /* 145-byte string literal not displayed */
	Height           int    `` /* 148-byte string literal not displayed */
	Alt              string `mapstructure:"alt" description:"Alternative text for the image" example:"{!{image-alt.hyperbricks}}"`
	Title            string `mapstructure:"title" description:"The title attribute of the image" example:"{!{image-title.hyperbricks}}"`
	Id               string `mapstructure:"id" description:"Id of image" example:"{!{image-id.hyperbricks}}"`
	Class            string `mapstructure:"class" description:"CSS class for styling the image" example:"{!{image-class.hyperbricks}}"`
	Quality          int    `mapstructure:"quality" description:"Image quality for optimization" example:"{!{image-quality.hyperbricks}}"`
	Loading          string `mapstructure:"loading" description:"Lazy loading strategy (e.g., 'lazy', 'eager')" example:"{!{image-loading.hyperbricks}}"`
	IsStatic         bool   `mapstructure:"is_static" description:"Flag indicating if the image is static" example:"{!{image-is_static.hyperbricks}}"`
}

func (*SingleImageConfig) Validate

func (config *SingleImageConfig) Validate() []error

type SingleImageRenderer

type SingleImageRenderer struct {
	ImageProcessorInstance *ImageProcessor
}

func (*SingleImageRenderer) Render

func (sir *SingleImageRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*SingleImageRenderer) Types

func (r *SingleImageRenderer) Types() []string

type SortOptions

type SortOptions struct {
	SortBy    string
	Ascending bool
}

type StyleConfig

type StyleConfig struct {
	shared.Component `mapstructure:",squash"`
	File             string `mapstructure:"file" validate:"required" description:"Path to the CSS file" example:"{!{styles-file.hyperbricks}}"`
}

func (*StyleConfig) Validate

func (style *StyleConfig) Validate() []error

type StyleRenderer

type StyleRenderer struct{}

func (*StyleRenderer) Render

func (sr *StyleRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*StyleRenderer) Types

func (r *StyleRenderer) Types() []string

type TextConfig

type TextConfig struct {
	shared.Component `mapstructure:",squash"`
	Value            string `mapstructure:"value" validate:"required" description:"The paragraph content" example:"{!{text-value.hyperbricks}}"`
}

func (*TextConfig) Validate

func (tc *TextConfig) Validate() []error

type TextRenderer

type TextRenderer struct{}

func (*TextRenderer) Render

func (tr *TextRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*TextRenderer) Types

func (r *TextRenderer) Types() []string

Jump to

Keyboard shortcuts

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