config

package
v1.0.1-0...-65d85cd Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Key       string `yaml:"key"`
	NotifyKey string `yaml:"notify_key"`

	Basic  BasicAuthConfig  `yaml:"basic"`
	Github GithubAuthConfig `yaml:"github"`
	Google GoogleAuthConfig `yaml:"google"`

	AdminName   string
	AdminEmails []string
}

AuthConfig ...

func DefaultAuthConfig

func DefaultAuthConfig() AuthConfig

DefaultAuthConfig ...

type BasicAuthConfig

type BasicAuthConfig struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

BasicAuthConfig ...

func DefaultBasicBasicAuthConfig

func DefaultBasicBasicAuthConfig() BasicAuthConfig

DefaultBasicBasicAuthConfig ...

type CommentConfig

type CommentConfig struct {
	Author            string                 `yaml:"author"`
	Emails            []string               `yaml:"emails"`
	Notify            bool                   `yaml:"notify"`
	NotAllowedEmails  []string               `yaml:"not_allowed_emails"`
	NotAllowedAuthors []string               `yaml:"not_allowed_authors"`
	Templates         CommentTemplatesConfig `yaml:"templates"`
}

CommentConfig ...

func DefaultCommentConfig

func DefaultCommentConfig() CommentConfig

DefaultCommentConfig ...

type CommentTemplatesConfig

type CommentTemplatesConfig struct {
	Admin string `yaml:"admin"`
	Guest string `yaml:"guest"`
}

CommentTemplatesConfig ...

func DefaultCommentTemplatesConfig

func DefaultCommentTemplatesConfig() CommentTemplatesConfig

DefaultCommentTemplatesConfig ...

type Config

type Config struct {
	Database    DatabaseConfig       `yaml:"database"`
	Server      ServerConfig         `yaml:"server"`
	Data        DataConfig           `yaml:"data"`
	Maintenance MaintenanceConfig    `yaml:"maintenance"`
	Auth        AuthConfig           `yaml:"auth"`
	Menus       Menus                `json:"menus" yaml:"menus"`
	Site        SiteConfig           `yaml:"site"`
	Comment     CommentConfig        `yaml:"comment"`
	Search      search_config.Config `yaml:"search"`
	Others      OthersConfig         `json:"others" yaml:"others"`

	// 尽管站点字体应该由各主题提供,但是为了能跨主题共享字体(减少配置麻烦),
	// 所以我就在这里定义了针对所有站点适用的自定义样式表(或主题)集合。
	Theme ThemeConfig `json:"theme" yaml:"theme"`

	VPS    VpsConfig          `json:"vps" yaml:"vps"`
	Notify NotificationConfig `json:"notify" yaml:"notify"`
}

Config ...

func DefaultConfig

func DefaultConfig() Config

DefaultConfig ...

func LoadFile

func LoadFile(path string) *Config

LoadFile ...

type CurrentVpsConfig

type CurrentVpsConfig string

func (CurrentVpsConfig) CanSave

func (CurrentVpsConfig) CanSave()

type DataConfig

type DataConfig struct {
	File FileDataConfig `yaml:"file"`
}

DataConfig ...

func DefaultDataConfig

func DefaultDataConfig() DataConfig

DefaultDataConfig ...

type DatabaseConfig

type DatabaseConfig struct {
	// 数据库文件路径。
	// 如果不指定,使用内存数据库。
	Path string `yaml:"path"`
}

DatabaseConfig ...

func DefaultDatabaseConfig

func DefaultDatabaseConfig() DatabaseConfig

DefaultDatabaseConfig ...

type FileDataConfig

type FileDataConfig struct {
	// 如果路径为空,使用内存文件系统。
	Path string `yaml:"path"`
}

FileDataConfig ...

func DefaultFileDataConfig

func DefaultFileDataConfig() FileDataConfig

DefaultFileDataConfig ...

type GithubAuthConfig

type GithubAuthConfig struct {
	ClientID     string `yaml:"client_id"`
	ClientSecret string `yaml:"client_secret"`
	UserID       int64  `yaml:"user_id"`
}

GithubAuthConfig ...

func DefaultGithubAuthConfig

func DefaultGithubAuthConfig() GithubAuthConfig

DefaultGithubAuthConfig ...

type GoogleAuthConfig

type GoogleAuthConfig struct {
	ClientID string `yaml:"client_id"`
	UserID   string `yaml:"user_id"`
}

GoogleAuthConfig ...

func DefaultGoogleAuthConfig

func DefaultGoogleAuthConfig() GoogleAuthConfig

DefaultGoogleAuthConfig ...

type HostdareVpsConfig

type HostdareVpsConfig struct {
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

func (HostdareVpsConfig) CanSave

func (HostdareVpsConfig) CanSave()

type MaintenanceConfig

type MaintenanceConfig struct {
	DisableAdmin bool `yaml:"disable_admin"`
	Webhook      struct {
		GitHub struct {
			Secret string `yaml:"secret"`
		} `yaml:"github"`
	} `yaml:"webhook"`
}

MaintenanceConfig ...

func DefaultMainMaintenanceConfig

func DefaultMainMaintenanceConfig() MaintenanceConfig

DefaultMainMaintenanceConfig ...

type MenuItem struct {
	Name  string     `json:"name" yaml:"name"`
	Link  string     `json:"link" yaml:"link"`
	Blank bool       `json:"blank" yaml:"blank"`
	Items []MenuItem `json:"items" yaml:"items"`
}

MenuItem ...

func DefaultMenuConfig

func DefaultMenuConfig() []MenuItem

DefaultMenuConfig ...

type Menus []MenuItem
func (m *Menus) CanSave()

type NotificationChanifyConfig

type NotificationChanifyConfig struct {
	Token string `json:"token" yaml:"token"`
}

func (*NotificationChanifyConfig) BeforeSet

func (c *NotificationChanifyConfig) BeforeSet(paths Segments, obj any) error

func (NotificationChanifyConfig) CanSave

func (NotificationChanifyConfig) CanSave()

type NotificationConfig

type NotificationConfig struct {
	Chanify NotificationChanifyConfig `json:"chanify" yaml:"chanify"`
	Mailer  NotificationMailerConfig  `json:"mailer" yaml:"mailer"`
}

type NotificationMailerConfig

type NotificationMailerConfig struct {
	// 服务器地址。形如:smtp.example.com:465
	Server string `json:"server" yaml:"server"`
	// 帐户名。通常是邮件地址。
	Account string `json:"account" yaml:"account"`
	// 密码。
	Password string `json:"password" yaml:"password"`
}

func (*NotificationMailerConfig) BeforeSet

func (c *NotificationMailerConfig) BeforeSet(paths Segments, obj any) error

func (NotificationMailerConfig) CanSave

func (NotificationMailerConfig) CanSave()

type OthersConfig

type OthersConfig struct {
	Whois WhoisConfig `json:"whois" yaml:"whois"`
}

type Saver

type Saver interface {
	CanSave()
}

type Segment

type Segment struct {
	Key   string
	Index any
}

type Segments

type Segments []Segment

func (Segments) At

func (s Segments) At(i int) Segment

type ServerConfig

type ServerConfig struct {
	HTTPListen string `yaml:"http_listen"`
	GRPCListen string `yaml:"grpc_listen"`
}

ServerConfig ...

func DefaultServerConfig

func DefaultServerConfig() ServerConfig

DefaultServerConfig ...

type Settable

type Settable interface {
	// 设置之前进行校验。
	// paths:如果为空,则表示整体设置。
	//        如果不为空,则表示设置对应名称的字段的值。
	// obj:对象到具体的值(非值的指针)。
	//
	// 注意:
	// - 具体的校验方式自己决定。如果 key 之前不相互依赖/影响,则可以单独判断。
	// - 无需判断 path.Index 是否会对应到普通字段类型(非 struct、map)。
	// - 无需判断值的类型,只要 path 对应,类型一定可强制断言且赋值。
	// - 无需判断 path 是否存在。
	BeforeSet(paths Segments, obj any) error
}

type SiteConfig

type SiteConfig struct {
	Home        string `yaml:"home"`
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Since       _Since `yaml:"since,omitempty"`
}

SiteConfig ...

func DefaultSiteConfig

func DefaultSiteConfig() SiteConfig

DefaultSiteConfig ...

type ThemeConfig

type ThemeConfig struct {
	Stylesheets ThemeStylesheetsConfig `json:"stylesheets" yaml:"stylesheets"`
}

func DefaultThemeConfig

func DefaultThemeConfig() ThemeConfig

func (ThemeConfig) CanSave

func (ThemeConfig) CanSave()

type ThemeStylesheetsConfig

type ThemeStylesheetsConfig struct {
	Template    string `json:"template" yaml:"template"`
	Stylesheets []struct {
		Source string `json:"source" yaml:"source"`
	} `json:"stylesheets" yaml:"stylesheets"`
}

func DefaultThemeStylesheetsConfig

func DefaultThemeStylesheetsConfig() ThemeStylesheetsConfig

func (*ThemeStylesheetsConfig) Render

func (c *ThemeStylesheetsConfig) Render() string

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(ptr any) *Updater

func (*Updater) EachSaver

func (u *Updater) EachSaver(fn func(path string, obj any))

func (*Updater) Find

func (u *Updater) Find(path string) any

func (*Updater) MustApply

func (u *Updater) MustApply(path string, value string, save func(path string, value string))

type VpsConfig

type VpsConfig struct {
	Current  CurrentVpsConfig  `json:"current" yaml:"current"`
	Hostdare HostdareVpsConfig `json:"hostdare" yaml:"hostdare"`
}

type WhoisApiLayerConfig

type WhoisApiLayerConfig struct {
	Key string `json:"key" yaml:"key"`
}

func (*WhoisApiLayerConfig) BeforeSet

func (c *WhoisApiLayerConfig) BeforeSet(paths Segments, obj any) error

func (WhoisApiLayerConfig) CanSave

func (WhoisApiLayerConfig) CanSave()

type WhoisConfig

type WhoisConfig struct {
	ApiLayer WhoisApiLayerConfig `json:"api_layer" yaml:"api_layer"`
}

Jump to

Keyboard shortcuts

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