settings

package
v0.0.0-...-d78814b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DB is a reference to the parent app's JsonDB object.

Functions

func RandomKey

func RandomKey() string

RandomKey generates a random string to use for the site's secret key.

Types

type Settings

type Settings struct {
	// Only gets set to true on save(), this determines whether
	// the site has ever been configured before.
	Initialized bool `json:"initialized"`

	Site struct {
		Title       string `json:"title"`
		Description string `json:"description"`
		AdminEmail  string `json:"adminEmail"`
		NSFW        bool   `json:"nsfw"`
		URL         string `json:"url"`
	} `json:"site"`

	// Security-related settings.
	Security struct {
		SecretKey string `json:"secretKey"` // Session cookie secret key
		HashCost  int    `json:"hashCost"`  // Bcrypt hash cost for passwords
	} `json:"security"`

	// Blog settings.
	Blog struct {
		PostsPerPage int `json:"postsPerPage"`
		PostsPerFeed int `json:"postsPerFeed"`
	} `json:"blog"`

	// Redis settings for caching in JsonDB.
	Redis struct {
		Enabled bool   `json:"enabled"`
		Host    string `json:"host"`
		Port    int    `json:"port"`
		DB      int    `json:"db"`
		Prefix  string `json:"prefix"`
	} `json:"redis"`

	// Mail settings
	Mail struct {
		Enabled  bool   `json:"enabled"`
		Sender   string `json:"sender"`
		Host     string `json:"host"`
		Port     int    `json:"port"`
		Username string `json:"username"`
		Password string `json:"password"`
	} `json:"mail,omitempty"`
}

Settings holds the global app settings.

func Defaults

func Defaults() *Settings

Defaults returns default settings. The app initially sets this on startup before reading your site's saved settings (if available). Also this is used as a template when the user first configures their site.

func Load

func Load() (*Settings, error)

Load the settings.

func (*Settings) Save

func (s *Settings) Save() error

Save the site settings.

Jump to

Keyboard shortcuts

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