config

package
v1.0.1-0...-39f75b5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveFile

func SaveFile(config *Config, path string)

Types

type AuthConfig

type AuthConfig struct {
	Key    string           `yaml:"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 CommentChanifyPushConfig

type CommentChanifyPushConfig struct {
	Token string `yaml:"token"`
}

CommentChanifyPushConfig ...

func DefaultCommentChanifyPushConfig

func DefaultCommentChanifyPushConfig() CommentChanifyPushConfig

DefaultCommentChanifyPushConfig ...

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"`
	Push              CommentPushConfig      `yaml:"push"`
}

CommentConfig ...

func DefaultCommentConfig

func DefaultCommentConfig() CommentConfig

DefaultCommentConfig ...

type CommentPushConfig

type CommentPushConfig struct {
	Chanify CommentChanifyPushConfig `yaml:"chanify"`
}

CommentPushConfig ...

func DefaultCommentPushConfig

func DefaultCommentPushConfig() CommentPushConfig

DefaultCommentPushConfig ...

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       []MenuItem           `yaml:"menus"`
	Site        SiteConfig           `yaml:"site"`
	Comment     CommentConfig        `yaml:"comment"`
	Search      search_config.Config `yaml:"search"`
	// contains filtered or unexported fields
}

Config ...

func DefaultConfig

func DefaultConfig() Config

DefaultConfig ...

func LoadFile

func LoadFile(path string) *Config

LoadFile ...

func (*Config) Save

func (c *Config) Save()

type DataConfig

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

DataConfig ...

func DefaultDataConfig

func DefaultDataConfig() DataConfig

DefaultDataConfig ...

type DatabaseConfig

type DatabaseConfig struct {
	// 只支持 sqlite3
	Engine string               `yaml:"engine"`
	SQLite DatabaseSQLiteConfig `yaml:"sqlite"`
}

DatabaseConfig ...

func DefaultDatabaseConfig

func DefaultDatabaseConfig() DatabaseConfig

DefaultDatabaseConfig ...

type DatabaseSQLiteConfig

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

DatabaseSQLiteConfig ...

func DefaultDatabaseSQLiteConfig

func DefaultDatabaseSQLiteConfig() DatabaseSQLiteConfig

DefaultDatabaseSQLiteConfig ...

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 MailerServerConfig

type MailerServerConfig struct {
	Server   string `yaml:"server"`
	Account  string `yaml:"account"`
	Password string `yaml:"password"`
}

MailerServerConfig ...

func DefaultMaiMailerServerConfig

func DefaultMaiMailerServerConfig() MailerServerConfig

DefaultMaiMailerServerConfig ...

type MaintenanceConfig

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

MaintenanceConfig ...

func DefaultMainMaintenanceConfig

func DefaultMainMaintenanceConfig() MaintenanceConfig

DefaultMainMaintenanceConfig ...

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

MenuItem ...

func DefaultMenuConfig

func DefaultMenuConfig() []MenuItem

DefaultMenuConfig ...

type RSSConfig

type RSSConfig struct {
	Enabled      bool `yaml:"enabled"`
	ArticleCount int  `yaml:"article_count"`
}

RSSConfig ...

func DefaultRSSConfig

func DefaultRSSConfig() RSSConfig

DefaultRSSConfig ...

type SearchConfig

type SearchConfig struct {
	Show bool `yaml:"show"`
}

SearchConfig ...

func DefaultSearchConfig

func DefaultSearchConfig() SearchConfig

DefaultSearchConfig ...

type Segment

type Segment struct {
	Key   string
	Index any
}

type ServerConfig

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

ServerConfig ...

func DefaultServerConfig

func DefaultServerConfig() ServerConfig

DefaultServerConfig ...

type SiteConfig

type SiteConfig struct {
	Home             string        `yaml:"home"`
	Name             string        `yaml:"name"`
	Description      string        `yaml:"description"`
	Since            _Since        `yaml:"since,omitempty"`
	ShowDescription  bool          `yaml:"show_description"`
	ShowStatus       bool          `yaml:"show_status"`
	ShowRelatedPosts bool          `yaml:"show_related_posts"`
	Search           SearchConfig  `yaml:"search"`
	RSS              RSSConfig     `yaml:"rss"`
	Sitemap          SitemapConfig `yaml:"sitemap"`

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

SiteConfig ...

func DefaultSiteConfig

func DefaultSiteConfig() SiteConfig

DefaultSiteConfig ...

type SitemapConfig

type SitemapConfig struct {
	Enabled bool `yaml:"enabled"`
}

SitemapConfig ...

func DefaultSitemapConfig

func DefaultSitemapConfig() SitemapConfig

DefaultSitemapConfig ...

type ThemeConfig

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

func DefaultThemeConfig

func DefaultThemeConfig() ThemeConfig

type ThemeStylesheetsConfig

type ThemeStylesheetsConfig struct {
	Template    string `yaml:"template"`
	Stylesheets []struct {
		Source string `yaml:"source"`
	} `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) Apply

func (u *Updater) Apply(path string, value string) (err error)

func (*Updater) Find

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

func (*Updater) MustApply

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

Jump to

Keyboard shortcuts

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