component

package
v0.1.41-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 26 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 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"`
	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            `` /* 143-byte string literal not displayed */
	IsTemplate       bool              `mapstructure:"istemplate"`
	User             string            `mapstructure:"user" description:"User for basic auth" example:"{!{api-render-user.hyperbricks}}"`
	Pass             string            `mapstructure:"pass" description:"User for basic auth" example:"{!{api-render-pass.hyperbricks}}"`
	Debug            bool              `mapstructure:"debug" description:"Debug the response data" example:"{!{api-render-debug.hyperbricks}}"`
}

func (*APIConfig) Validate

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

type APIRenderer

type APIRenderer struct {
	renderer.ComponentRenderer
}

func (*APIRenderer) Render

func (ar *APIRenderer) Render(instance interface{}) (string, []error)

func (*APIRenderer) Types

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

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{}) (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{}) (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{}) (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{}) (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 `` /* 128-byte string literal not displayed */
	IsTemplate       bool   `mapstructure:"istemplate"`
	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{}) (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{}) (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{}) (string, []error)

func (*MultipleImagesRenderer) Types

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

type PluginConfig

type PluginConfig struct {
	shared.Component `mapstructure:",squash"`
	PluginName       string                 `mapstructure:"plugin"`
	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{}) (string, []error)

func (*PluginRenderer) Render

func (r *PluginRenderer) Render(instance interface{}) (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{}) (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{}) (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{}) (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