{"modulePath":"github.com/codenomdev/viona","version":"v0.0.0-20260712053131-1c7db091e4ae","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugins\n\n## Variables\n\n```go\nvar (\n\t// CallBase is a function that calls all registered base plugins\n\tCallBase, _ = MakePlugin[Base](true)\n)\n```\n\n```go\nvar (\n\t// CallCDN is a function that calls all registered parsers\n\tCallCDN, _ = MakePlugin[CDN](false)\n)\n```\n\n```go\nvar (\n\t// CallCache is a function that calls all registered cache\n\tCallCache, _ = MakePlugin[Cache](false)\n)\n```\n\n```go\nvar (\n\t// CallConfig is a function that calls all registered config plugins\n\tCallConfig, _ = MakePlugin[Config](true)\n)\n```\n\n```go\nvar (\n\t// CallConnector is a function that calls all registered connectors\n\tCallConnector, _ = MakePlugin[Connector](false)\n)\n```\n\n```go\nvar (\n\t// CallEmbed is a function that calls all registered parsers\n\tCallEmbed, _ = MakePlugin[Embed](false)\n)\n```\n\n```go\nvar (\n\t// CallRender is a function that calls all registered parsers\n\tCallRender, _ = MakePlugin[Render](false)\n)\n```\n\n```go\nvar (\n\t// CallRender is a function that calls all registered parsers\n\tCallSidebar, _ = MakePlugin[Sidebar](false)\n)\n```\n\n```go\nvar (\n\tDefaultCDNFileType = map[string]bool{\n\t\t\".ico\":   true,\n\t\t\".json\":  true,\n\t\t\".css\":   true,\n\t\t\".js\":    true,\n\t\t\".webp\":  true,\n\t\t\".woff2\": true,\n\t\t\".woff\":  true,\n\t\t\".jpg\":   true,\n\t\t\".svg\":   true,\n\t\t\".png\":   true,\n\t\t\".map\":   true,\n\t\t\".txt\":   true,\n\t}\n)\n```\n\n```go\nvar StatusManager = statusManager{\n\t// contains filtered or unexported fields\n}\n```\nStatusManager is a manager that manages the status of plugins Init Plugins: json.Unmarshal(\\[]byte(\\`{\"plugin1\": true, \"plugin2\": false}\\`), \u0026plugin.StatusManager) Dump Status: json.Marshal(plugin.StatusManager)\n\n## Functions\n\n```go\nfunc MakePlugin[T Base](super bool) (CallFn[T], RegisterFn[T])\n```\nMakePlugin creates a plugin caller and register stack manager The parameter super presents if the plugin can be disabled. It returns a register function and a caller function The register function is used to register a plugin, it will be called in the plugin's init function The caller function is used to call all registered plugins\n\n```go\nfunc Register(p Base)\n```\nRegister registers a plugin\n\n```go\nfunc Translate(ctx EchoContext, key string) string\n```\nTranslate translates the key to the current language of the context\n\n```go\nfunc TranslateWithData(lang i18n.Language, key string, data any) string\n```\nTranslateWithData translates the key to the language with data\n\n## Types\n\n```go\ntype Base interface {\n\t// Info returns the plugin information\n\tInfo() Info\n}\n```\nBase is the base plugin\n\n```go\ntype CDN interface {\n\tBase\n\tGetStaticPrefix() string\n}\n```\n\n```go\ntype Cache interface {\n\tBase\n\n\tGetString(ctx context.Context, key string) (data string, exist bool, err error)\n\tSetString(ctx context.Context, key, value string, ttl time.Duration) (err error)\n\tGetInt64(ctx context.Context, key string) (data int64, exist bool, err error)\n\tSetInt64(ctx context.Context, key string, value int64, ttl time.Duration) (err error)\n\tIncrease(ctx context.Context, key string, value int64) (data int64, err error)\n\tDecrease(ctx context.Context, key string, value int64) (data int64, err error)\n\tDel(ctx context.Context, key string) (err error)\n\tFlush(ctx context.Context) (err error)\n}\n```\n\n```go\ntype CallFn[T Base] func(fn Caller[T]) error\n```\n\n```go\ntype Caller[T Base] func(p T) error\n```\n\n```go\ntype Config interface {\n\tBase\n\n\t// ConfigFields returns the list of config fields\n\tConfigFields() []ConfigField\n\n\t// ConfigReceiver receives the config data, it calls when the config is saved or initialized.\n\t// We recommend to unmarshal the data to a struct, and then use the struct to do something.\n\t// The config is encoded in JSON format.\n\t// It depends on the definition of ConfigFields.\n\tConfigReceiver(config []byte) error\n}\n```\n\n```go\ntype ConfigField struct {\n\tName        string               `json:\"name\"`\n\tType        ConfigType           `json:\"type\"`\n\tTitle       Translator           `json:\"title\"`\n\tDescription Translator           `json:\"description\"`\n\tRequired    bool                 `json:\"required\"`\n\tValue       any                  `json:\"value\"`\n\tUIOptions   ConfigFieldUIOptions `json:\"ui_options\"`\n\tOptions     []ConfigFieldOption  `json:\"options,omitempty\"`\n}\n```\n\n```go\ntype ConfigFieldOption struct {\n\tLabel Translator `json:\"label\"`\n\tValue string     `json:\"value\"`\n}\n```\n\n```go\ntype ConfigFieldUIOptions struct {\n\tPlaceholder    Translator      `json:\"placeholder\"`\n\tRows           string          `json:\"rows,omitempty\"`\n\tInputType      InputType       `json:\"input_type,omitempty\"`\n\tLabel          Translator      `json:\"label\"`\n\tAction         *UIOptionAction `json:\"action,omitempty\"`\n\tVariant        string          `json:\"variant,omitempty\"`\n\tText           Translator      `json:\"text\"`\n\tClassName      string          `json:\"class_name,omitempty\"`\n\tFieldClassName string          `json:\"field_class_name,omitempty\"`\n}\n```\n\n```go\ntype ConfigType string\n```\n\n```go\nconst (\n\tConfigTypeInput       ConfigType = \"input\"\n\tConfigTypeTextarea    ConfigType = \"textarea\"\n\tConfigTypeCheckbox    ConfigType = \"checkbox\"\n\tConfigTypeRadio       ConfigType = \"radio\"\n\tConfigTypeSelect      ConfigType = \"select\"\n\tConfigTypeUpload      ConfigType = \"upload\"\n\tConfigTypeTimezone    ConfigType = \"timezone\"\n\tConfigTypeSwitch      ConfigType = \"switch\"\n\tConfigTypeButton      ConfigType = \"button\"\n\tConfigTypeLegend      ConfigType = \"legend\"\n\tConfigTypeTagSelector ConfigType = \"tag_selector\"\n)\n```\n\n```go\ntype Connector interface {\n\tBase\n\n\t// ConnectorLogoSVG presents the logo in svg format\n\tConnectorLogoSVG() string\n\n\t// ConnectorName presents the name of the connector\n\t// e.g. Facebook, Twitter, Instagram\n\tConnectorName() Translator\n\n\t// ConnectorSlugName presents the slug name of the connector\n\t// Please use lowercase and hyphen as the separator\n\t// e.g. facebook, twitter, instagram\n\tConnectorSlugName() string\n\n\t// ConnectorSender presents the sender of the connector\n\t// It handles the start endpoint of the connector\n\t// receiverURL is the whole URL of the receiver\n\tConnectorSender(ctx *echo.Context, receiverURL string) (redirectURL string)\n\n\t// ConnectorReceiver presents the receiver of the connector\n\t// It handles the callback endpoint of the connector, and returns the\n\tConnectorReceiver(ctx *echo.Context, receiverURL string) (userInfo ExternalLoginUserInfo, err error)\n}\n```\n\n```go\ntype Data struct {\n\tDB    *gorm.DB\n\tCache cache.Cache\n}\n```\n\n```go\ntype EchoContext = echo.Context\n```\n\n```go\ntype Embed interface {\n\tBase\n\tGetEmbedConfigs(ctx echo.Context) (embedConfigs []*EmbedConfig, err error)\n}\n```\n\n```go\ntype EmbedConfig struct {\n\tPlatform string `json:\"platform\"`\n\tEnable   bool   `json:\"enable\"`\n}\n```\n\n```go\ntype ExternalLoginUserInfo struct {\n\t// required. The unique user ID provided by the third-party login\n\tExternalID string\n\t// optional. This name is used preferentially during registration\n\tDisplayName string\n\t// optional. This username is used preferentially during registration\n\tUsername string\n\t// optional. If email exist will bind the existing user\n\t// IMPORTANT: The email must have been verified. If the plugin can't guarantee the email is verified, please leave it empty.\n\tEmail string\n\t// optional. The avatar URL provided by the third-party login platform\n\tAvatar string\n\t// optional. The original user information provided by the third-party login platform\n\tMetaInfo string\n}\n```\nExternalLoginUserInfo external login user info\n\n```go\ntype Info struct {\n\tName        Translator\n\tSlugName    string\n\tDescription Translator\n\tAuthor      string\n\tVersion     string\n\tLink        string\n}\n```\nInfo presents the plugin information\n\n```go\ntype InputType string\n```\n\n```go\nconst (\n\tInputTypeText     InputType = \"text\"\n\tInputTypeColor    InputType = \"color\"\n\tInputTypeDate     InputType = \"date\"\n\tInputTypeDatetime InputType = \"datetime-local\"\n\tInputTypeEmail    InputType = \"email\"\n\tInputTypeMonth    InputType = \"month\"\n\tInputTypeNumber   InputType = \"number\"\n\tInputTypePassword InputType = \"password\"\n\tInputTypeRange    InputType = \"range\"\n\tInputTypeSearch   InputType = \"search\"\n\tInputTypeTel      InputType = \"tel\"\n\tInputTypeTime     InputType = \"time\"\n\tInputTypeUrl      InputType = \"url\"\n\tInputTypeWeek     InputType = \"week\"\n)\n```\n\n```go\ntype LoadingAction struct {\n\tText  Translator        `json:\"text\"`\n\tState LoadingActionType `json:\"state\"`\n}\n```\n\n```go\ntype LoadingActionType string\n```\n\n```go\nconst (\n\tLoadingActionStateNone     LoadingActionType = \"none\"\n\tLoadingActionStatePending  LoadingActionType = \"pending\"\n\tLoadingActionStateComplete LoadingActionType = \"completed\"\n)\n```\n\n```go\ntype OnCompleteAction struct {\n\tToastReturnMessage bool `json:\"toast_return_message\"`\n\tRefreshFormConfig  bool `json:\"refresh_form_config\"`\n}\n```\n\n```go\ntype RegisterFn[T Base] func(p T)\n```\n\n```go\ntype Render interface {\n\tBase\n\tGetRenderConfig(ctx echo.Context) (renderConfig *RenderConfig)\n}\n```\n\n```go\ntype RenderConfig struct {\n\tSelectTheme string `json:\"select_theme\"`\n}\n```\n\n```go\ntype Sidebar interface {\n\tBase\n\tGetSidebarConfig() (sidebarConfig *SidebarConfig, err error)\n}\n```\n\n```go\ntype SidebarConfig struct {\n\tTags      []*TagSelectorOption `json:\"tags\"`\n\tLinksText string               `json:\"links_text\"`\n}\n```\n\n```go\ntype Stack[T Base] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype TagSelectorOption struct {\n\tTagID       string `json:\"tag_id\"`\n\tSlugName    string `json:\"slug_name\"`\n\tDisplayName string `json:\"display_name\"`\n\tRecommend   bool   `json:\"recommend\"`\n\tReserved    bool   `json:\"reserved\"`\n}\n```\nTagSelectorOption represents a tag option in the tag selector config value field\n\n```go\ntype TranslateFn func(ctx EchoContext) string\n```\nTranslateFn presents a generator of translated string. We use it to delegate the translation work outside the plugin.\n\n```go\ntype Translator struct {\n\tFn TranslateFn\n}\n```\nTranslator contains a function that translates the key to the current language of the context\n\n```go\nfunc MakeTranslator(key string) Translator\n```\nMakeTranslator generates a translator from the key\n\n```go\nfunc (t Translator) Translate(ctx EchoContext) string\n```\nTranslate translates the key to the current language of the context\n\n```go\ntype UIOptionAction struct {\n\tUrl        string            `json:\"url\"`\n\tMethod     string            `json:\"method,omitempty\"`\n\tLoading    *LoadingAction    `json:\"loading,omitempty\"`\n\tOnComplete *OnCompleteAction `json:\"on_complete,omitempty\"`\n}\n```\n\n","path":"github.com/codenomdev/viona/plugins","name":"plugins","synopsis":"","isRedistributable":true}
