setting

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package settings provides a framework for adding custom settings to your-revere.com/settings/ page. Add your setting to this package and have it implement the Setting interface. Don't forget to register your setting with addSettingType(SettingType).

Index

Constants

View Source
const (
	SettingDir = "settings"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OutgoingEmail

type OutgoingEmail struct{}

func (OutgoingEmail) Id

func (OutgoingEmail) Name

func (OutgoingEmail) Name() string

func (OutgoingEmail) Scripts

func (OutgoingEmail) Scripts() []string

func (OutgoingEmail) Template

func (OutgoingEmail) Template() string

type OutgoingEmailSetting

type OutgoingEmailSetting struct {
	OutgoingEmail
	FromName          string
	FromEmail         string
	SubjectLinePrefix string
	SmtpServer        string
}

func (*OutgoingEmailSetting) Serialize

func (oe *OutgoingEmailSetting) Serialize() (string, error)

func (*OutgoingEmailSetting) Type

func (*OutgoingEmailSetting) Validate

func (oe *OutgoingEmailSetting) Validate() []string

type OutgoingEmailSettingDBModel

type OutgoingEmailSettingDBModel struct {
	FromName          string
	FromEmail         string
	SubjectLinePrefix string
	SmtpServer        string
}

type Setting

type Setting interface {
	SettingType
	Serialize() (string, error)
	Type() SettingType
	Validate() []string
}

func Blank

func Blank(id db.SettingType) (Setting, error)

func Default

func Default() (Setting, error)

func LoadFromDB

func LoadFromDB(id db.SettingType, sJson string) (Setting, error)

func LoadFromParams

func LoadFromParams(id db.SettingType, sParams string) (Setting, error)

type SettingType

type SettingType interface {
	Id() db.SettingType
	Name() string

	Template() string
	Scripts() []string
	// contains filtered or unexported methods
}

SettingType and Setting define a common display abstraction for all settings.

func AllTypes

func AllTypes() (sts []SettingType)

type Slack

type Slack struct{}

func (Slack) Id

func (Slack) Id() db.SettingType

func (Slack) Name

func (Slack) Name() string

func (Slack) Scripts

func (Slack) Scripts() []string

func (Slack) Template

func (Slack) Template() string

type SlackSetting

type SlackSetting struct {
	Slack
	APIToken   string
	BotName    string
	WebhookURL string
}

func (*SlackSetting) Serialize

func (ss *SlackSetting) Serialize() (string, error)

func (*SlackSetting) Type

func (*SlackSetting) Type() SettingType

func (*SlackSetting) Validate

func (ss *SlackSetting) Validate() []string

type SlackSettingDBModel

type SlackSettingDBModel struct {
	APIToken   string
	BotName    string
	WebhookURL string
}

type VM

type VM struct {
	Setting
	SettingParams string
	SettingType   db.SettingType
	SettingID     db.SettingID
}

The VM struct is practically identical in purpose to its counterparts in the vm package, as it represents the intermediate structure between Revere's DB representation of the Setting and its front end representation of the Setting.

func All

func All(DB *db.DB) ([]*VM, error)

func (*VM) ComponentName

func (*VM) ComponentName() string

func (*VM) Id

func (vm *VM) Id() int64

func (*VM) IsCreate

func (vm *VM) IsCreate() bool

func (*VM) Save

func (vm *VM) Save(tx *db.Tx) error

func (*VM) Validate

func (vm *VM) Validate() (errs []string)

Jump to

Keyboard shortcuts

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