config

package
v0.0.0-...-56103b5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MySQL indicates to use the MySQL database driver.
	MySQL = iota
	// SQLite indicates to use the SQLite database driver.
	SQLite
)

Variables

View Source
var (
	// WorkingDir is the current working directory of the project.
	WorkingDir string
	// ConfigPath is the configuration file name.
	ConfigPath = "config.toml"
	// Config is where the current configuration is loaded.
	Config Configuration
	// StartTime is the time when the server started.
	StartTime = time.Now()
	// LoadedDegrees is a list of degrees discovered in the config.
	LoadedDegrees []string
)

Functions

func LoadConfig

func LoadConfig()

LoadConfig loads the configuration file from disk. It will also generate one if it doesn't exist.

func SaveConfig

func SaveConfig() error

SaveConfig saves the configuration from memory to disk.

Types

type ClassRepresentative

type ClassRepresentative struct {
	Name, Email, Course, DegreeCode string
}

ClassRepresentative holds the details of a class representative

type Configuration

type Configuration struct {
	SiteName        string                // SiteName is the name of the site.
	SiteScope       string                // SiteScope is the campus, department, and university year of the site.
	SitePort        string                // SitePort is the port to run the web server on.
	VoterPepper     string                // VoterPepper is the salt used in the voter ID hash.
	DevMode         bool                  // DevMode is whether to disable authentication for development.
	UniEmailDomain  string                // UniEmailDomain is the university domain for login.
	EmailAddress    string                // EmailAddress is the email address which sends the OTPs.
	EmailPassword   string                // EmailPassword is the password of the email used to send OTPs.
	EmailSMTPServer string                // EmailSMTPServer is the SMTP server including the port.
	DBConfig        DatabaseConfiguration // DBConfig is the database configuration.
	InstanceConfig  InstanceSettings      // InstanceSettings is instance-specific configuration.
}

Configuration represents the configuration file format.

type Course

type Course struct {
	Code, Name string
	DegreeCode []string
}

type DBType

type DBType int

DBType represents the type of the database driver which will be used.

type DatabaseConfiguration

type DatabaseConfiguration struct {
	Type     DBType // Type refers to which database driver to use.
	Host     string // Host refers to the host of the database (MySQL only).
	Name     string // Name refers to the name of the database (MySQL only).
	User     string // User refers to the user of the database (MySQL only).
	Password string // Password refers to the database passsword (MySQL only).
	Path     string // Path refers to the database file path (SQLite only).
}

DatabaseConfiguration represents the general database configuration for all database drivers.

type ExternalResource

type ExternalResource struct {
	Name, Link string
}

ExternalResource holds the information to a hyperlink

type InstanceSettings

type InstanceSettings struct {
	ShowNotice       bool
	NoticeText       string
	NoticeLink       string
	NoticeTitle      string
	NoticeColour     string
	RequestChatEmail string
	Links            []ExternalResource
	ClassReps        []ClassRepresentative
	Courses          []Course
	Lecturers        []Lecturer
}

type Lecturer

type Lecturer struct {
	Name, Email, Office, Updated string
}

Jump to

Keyboard shortcuts

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