config

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2016 License: AGPL-3.0, AGPL-3.0-or-later Imports: 5 Imported by: 0

Documentation

Overview

Package config stores and exports the configuration for server-side use and the public availability JSON struct, which includes a small subset of the server configuration.

Index

Constants

This section is empty.

Variables

View Source
var (

	// AllBoardConfigs stores board-specific configurations for the /all/
	// metaboard. Constant.
	AllBoardConfigs []byte

	// AllowedOrigin stores the accepted client origin for websocket and file
	// upload requests. Set only on server start.
	AllowedOrigin string

	// Defaults contains the default server configuration values
	Defaults = Configs{
		MaxThreads:    100,
		MaxBump:       1000,
		JPEGQuality:   80,
		PNGQuality:    20,
		MaxSize:       5,
		MaxHeight:     6000,
		MaxWidth:      6000,
		SessionExpiry: 30,
		DefaultCSS:    "moe",
		Salt:          "LALALALALALALALALALALALALALALALALALALALA",
		FeedbackEmail: "admin@email.com",
		FAQ:           defaultFAQ,
		DefaultLang:   "en_GB",
		Boards:        []string{},
		Links:         map[string]string{"4chan": "http://www.4chan.org/"},
	}

	// EightballDefaults contains the default eightball answer set
	EightballDefaults = []string{
		"Yes",
		"No",
		"Maybe",
		"It can't be helped",
		"Hell yeah, motherfucker!",
		"Anta baka?",
	}
)

Functions

func GetClient

func GetClient() ([]byte, string)

GetClient returns punlic availability configuration JSON and a truncated configuration MD5 hash

func Set

func Set(c Configs) error

Set sets the internal configuration struct. To be used only in tests.

func SetClient

func SetClient(json []byte, cHash string)

SetClient sets the client configuration JSON and hash. To be used only in tests.

Types

type BoardConfigs

type BoardConfigs struct {
	PostParseConfigs
	Spoilers  bool                `json:"spoilers" gorethink:"spoilers"`
	CodeTags  bool                `json:"codeTags" gorethink:"codeTags" public:"true"`
	ID        string              `json:"id" gorethink:"id"`
	Spoiler   string              `json:"spoiler" gorethink:"spoiler" public:"true"`
	Title     string              `json:"title" gorethink:"title" public:"true"`
	Notice    string              `json:"notice" gorethink:"notice" public:"true"`
	Rules     string              `json:"rules" gorethink:"rules" public:"true"`
	Eightball []string            `json:"eightball" gorethink:"eightball"`
	Banners   []string            `json:"banners" gorethink:"banners" public:"true"`
	Staff     map[string][]string `json:"staff" gorethink:"staff"`
}

BoardConfigs stores board-specific configuration

func (*BoardConfigs) MarshalPublicJSON

func (b *BoardConfigs) MarshalPublicJSON() ([]byte, error)

MarshalPublicJSON marshals the publically exposed fields of a board-specific configuration

type Configs

type Configs struct {
	Prune             bool   `json:"prune" gorethink:"prune"`
	Radio             bool   `json:"radio" gorethink:"radio" public:"true"`
	Hats              bool   `json:"hats" gorethink:"hats" public:"true"`
	IllyaDance        bool   `json:"illyaDance" gorethink:"illyaDance" public:"true"`
	Pyu               bool   `json:"pyu" gorethink:"pyu"`
	Captcha           bool   `json:"captcha" gorethink:"captcha" public:"true"`
	MaxWidth          uint16 `json:"maxWidth" gorethink:"maxWidth"`
	MaxHeight         uint16 `json:"maxHeight" gorethink:"maxHeight"`
	MaxThreads        int    `json:"maxThreads" gorethink:"maxThreads"`
	MaxBump           int    `json:"maxBump" gorethink:"maxBump"`
	JPEGQuality       int
	PNGQuality        int
	MaxSize           int64             `json:"maxSize" gorethink:"maxSize"`
	DefaultLang       string            `json:"defaultLang" gorethink:"defaultLang" public:"true"`
	DefaultCSS        string            `json:"defaultCSS" gorethink:"defaultCSS" public:"true"`
	Salt              string            `json:"salt" gorethink:"salt"`
	FeedbackEmail     string            `json:"feedbackEmail" gorethink:"feedbackEmail"`
	FAQ               string            `public:"true"`
	CaptchaPublicKey  string            `json:"captchaPublicKey" gorethink:"captchaPublicKey" public:"true"`
	CaptchaPrivateKey string            `json:"captchaPrivateKey" gorethink:"captchaPrivateKey"`
	Boards            []string          `json:"-" gorethink:"boards" public:"true"`
	Links             map[string]string `json:"links" gorethink:"links" public:"true"`
	SessionExpiry     time.Duration     `json:"sessionExpiry" gorethink:"sessionExpiry"`
}

Configs stores the global configuration

func Get

func Get() *Configs

Get returns a pointer to the current server configuration struct. Callers should not modify this struct.

type DatabaseBoardConfigs

type DatabaseBoardConfigs struct {
	BoardConfigs
	Created time.Time `gorethink:"created"`
}

DatabaseBoardConfigs contains extra fields not exposed on database reads

type PostParseConfigs

type PostParseConfigs struct {
	ReadOnly     bool `json:"readOnly" gorethink:"readOnly"`
	TextOnly     bool `json:"textOnly" gorethink:"textOnly"`
	ForcedAnon   bool `json:"forcedAnon" gorethink:"forcedAnon"`
	HashCommands bool `json:"hashCommands" gorethink:"hashCommands"`
}

PostParseConfigs contains board-specific flags for post text parsing

Jump to

Keyboard shortcuts

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