config

package
v0.0.0-...-deaa16c Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressValid

func AddressValid(addr string) bool

AddressValid reports whether addr is of the form "host:port". If host is missing, it might return true, but if ":port" is missing it will return false.

Types

type Config

type Config struct {
	IsDevelopment bool `yaml:"isDevelopment"`

	Addr    string `yaml:"addr"`
	UIProxy string `yaml:"uiProxy"`

	SiteName        string `yaml:"siteName"`
	SiteDescription string `yaml:"siteDescription"` // Used for meta tags.

	// Primary DB credentials.
	DBAddr     string `yaml:"dbAddr"`
	DBUser     string `yaml:"dbUser"`
	DBPassword string `yaml:"dbPassword"`
	DBName     string `yaml:"dbName"`

	SessionCookieName string `yaml:"sessionCookieName"`

	RedisAddress string `yaml:"redisAddress"`

	HMACSecret string `yaml:"hmacSecret"`

	CSRFOff bool `yaml:"csrfOff"`

	NoLogToFile bool `yaml:"noLogToFile"`

	PaginationLimit    int           `yaml:"paginationLimit"`
	PaginationLimitMax int           `yaml:"paginationLimitMax"`
	DefaultFeedSort    core.FeedSort `yaml:"defaultFeedSort"`

	// Captcha verification is skipped if empty.
	CaptchaSecret string `yaml:"captchaSecret"`

	CertFile string `yaml:"certFile"`
	KeyFile  string `yaml:"keyFile"`

	DisableRateLimits bool `yaml:"disableRateLimits"`
	MaxImageSize      int  `yaml:"maxImageSize"`

	// If API requests have a URL query parameter of the form 'adminKey=value',
	// where value is AdminAPIKey, rate limits are disabled.
	AdminAPIKey string `yaml:"adminAPIKey"`

	DisableImagePosts bool `yaml:"disableImagePosts"`

	DisableForumCreation   bool `yaml:"disableForumCreation"`   // If true, only admins can create communities.
	ForumCreationReqPoints int  `yaml:"forumCreationReqPoints"` // Minimum points required for non-admins to create community, Required non-empty config field.
	MaxForumsPerUser       int  `yaml:"maxForumsPerUser"`       // Max forums one user can moderate, Required non-empty config field.

	// The location where images are saved on disk.
	ImagesFolderPath string `yaml:"imagesFolderPath"`

	MaxImagesPerPost int `yaml:"maxImagesPerPost"`

	// For the front-end:
	CaptchaSiteKey string `yaml:"captchaSiteKey"`
	EmailContact   string `yaml:"emailContact"`
	FacebookURL    string `yaml:"facebookURL"`
	TwitterURL     string `yaml:"twitterURL"`
	InstagramURL   string `yaml:"instagramURL"`
	DiscordURL     string `yaml:"discordURL"`
	GithubURL      string `yaml:"githubURL"`
	SubstackURL    string `yaml:"substackURL"`
}

Config holds all site-wide configuration.

func Parse

func Parse(path string) (*Config, error)

Parse parses the yaml file at path and returns a Config.

func (*Config) Hostname

func (c *Config) Hostname() string

Hostname returns the hostname part of c.Addr. If there's no hostname part, it returns an empty string.

Jump to

Keyboard shortcuts

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