config

package
v0.0.0-...-ff8e54b Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 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 (

	// Defaults contains the default server configuration values
	DefaultServerConfig = ServerConfig{
		ServerPublic: ServerPublic{
			MaxSize:    common.DefaultMaxSize,
			MaxFiles:   common.DefaultMaxFiles,
			DefaultCSS: common.DefaultCSS,
		},
	}
)

Functions

func GetAllBoardIDs

func GetAllBoardIDs() (ids []string)

All boards including /all/.

func GetBoardIDs

func GetBoardIDs() (ids []string)

func GetBoardsJSON

func GetBoardsJSON() (data []byte)

func GetJSON

func GetJSON() []byte

func IsBoard

func IsBoard(b string) bool

func IsModOnlyBoard

func IsModOnlyBoard(b string) bool

func IsReadOnlyBoard

func IsReadOnlyBoard(b string) bool

func IsRegisteredOnlyBoard

func IsRegisteredOnlyBoard(b string) bool

func IsWhitelistOnlyBoard

func IsWhitelistOnlyBoard(b string) bool

func RemoveBoard

func RemoveBoard(b string)

RemoveBoard removes a board from the exiting board list and deletes its configurations. To be called, when a board is deleted.

func Set

func Set(c ServerConfig) (err error)

func SetBoardConfig

func SetBoardConfig(conf BoardConfig) (err error)

Set configurations for a specific board as well as pregenerate its public JSON. Return if any changes were made to the configs.

Types

type AccessMode

type AccessMode int
const (
	AccessBypass AccessMode = iota - 1
	AccessViaBlacklist
	AccessViaWhitelist
)

type BoardConfig

type BoardConfig struct {
	BoardPublic
	ModOnly     bool       `json:"modOnly,omitempty"`
	AccessMode  AccessMode `json:"accessMode,omitempty"`
	IncludeAnon bool       `json:"includeAnon,omitempty"`
	// contains filtered or unexported fields
}

Some fields will be duplicated in DB because we need to pass them to JS client but that doesn't matter.

func GetBoardConfig

func GetBoardConfig(b string) BoardConfig

type BoardConfigs

type BoardConfigs []BoardConfig

Implements sort.Interface

func GetBoardConfigs

func GetBoardConfigs() BoardConfigs

func GetBoardConfigsByID

func GetBoardConfigsByID(ids []string) (cs BoardConfigs)

func (BoardConfigs) Len

func (b BoardConfigs) Len() int

func (BoardConfigs) Less

func (b BoardConfigs) Less(i, j int) bool

func (BoardConfigs) Swap

func (b BoardConfigs) Swap(i, j int)

func (*BoardConfigs) TryMarshal

func (cs *BoardConfigs) TryMarshal() []byte

type BoardPublic

type BoardPublic struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	ReadOnly bool   `json:"readOnly,omitempty"`
}

type ServerConfig

type ServerConfig struct {
	ServerPublic
}

func Get

func Get() *ServerConfig

type ServerPublic

type ServerPublic struct {
	MaxSize           int64  `json:"maxSize"`
	MaxFiles          int    `json:"maxFiles"`
	DefaultCSS        string `json:"defaultCSS"`
	ImageRootOverride string `json:"imageRootOverride,omitempty"`
}

Jump to

Keyboard shortcuts

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