2017-07-17 10:23:42 +00:00
package main
2017-09-23 19:57:13 +00:00
import (
"errors"
"net/http"
"strings"
)
2017-07-17 10:23:42 +00:00
2017-09-13 15:09:13 +00:00
var site = & Site { Name : "Magical Fairy Land" , Language : "english" }
var dbConfig = DBConfig { Host : "localhost" }
2017-07-17 10:23:42 +00:00
var config Config
var dev DevConfig
2017-09-10 16:57:22 +00:00
type Site struct {
2017-09-23 19:57:13 +00:00
Name string // ? - Move this into the settings table? Should we make a second version of this for the abbreviation shown in the navbar?
2017-09-13 15:09:13 +00:00
Email string // ? - Move this into the settings table?
URL string
2017-09-10 16:57:22 +00:00
Port string
EnableSsl bool
2017-07-17 10:23:42 +00:00
EnableEmails bool
2017-09-10 16:57:22 +00:00
HasProxy bool
2017-09-13 15:09:13 +00:00
Language string // ? - Move this into the settings table?
2017-07-17 10:23:42 +00:00
}
2017-09-13 15:09:13 +00:00
type DBConfig struct {
2017-09-10 16:57:22 +00:00
Host string
2017-07-17 10:23:42 +00:00
Username string
Password string
2017-09-10 16:57:22 +00:00
Dbname string
Port string
2017-07-17 10:23:42 +00:00
}
2017-09-10 16:57:22 +00:00
type Config struct {
SslPrivkey string
2017-07-17 10:23:42 +00:00
SslFullchain string
2017-09-10 16:57:22 +00:00
MaxRequestSize int
CacheTopicUser int
UserCacheCapacity int
2017-07-17 10:23:42 +00:00
TopicCacheCapacity int
2017-09-18 17:03:52 +00:00
SMTPServer string
SMTPUsername string
SMTPPassword string
SMTPPort string
2017-07-17 10:23:42 +00:00
2017-09-23 19:57:13 +00:00
DefaultRoute func ( http . ResponseWriter , * http . Request , User )
DefaultGroup int
ActivationGroup int
StaffCSS string // ? - Move this into the settings table? Might be better to implement this as Group CSS
DefaultForum int // The forum posts go in by default, this used to be covered by the Uncategorised Forum, but we want to replace it with a more robust solution. Make this a setting?
MinifyTemplates bool
MultiServer bool
2017-07-17 10:23:42 +00:00
2017-09-13 15:09:13 +00:00
Noavatar string // ? - Move this into the settings table?
ItemsPerPage int // ? - Move this into the settings table?
2017-07-17 10:23:42 +00:00
}
2017-09-10 16:57:22 +00:00
type DevConfig struct {
DebugMode bool
2017-07-17 10:23:42 +00:00
SuperDebug bool
2017-09-10 16:57:22 +00:00
Profiling bool
2017-07-17 10:23:42 +00:00
}
2017-09-23 19:57:13 +00:00
func processConfig ( ) {
config . Noavatar = strings . Replace ( config . Noavatar , "{site_url}" , site . URL , - 1 )
if site . Port != "80" && site . Port != "443" {
site . URL = strings . TrimSuffix ( site . URL , "/" )
site . URL = strings . TrimSuffix ( site . URL , "\\" )
site . URL = strings . TrimSuffix ( site . URL , ":" )
site . URL = site . URL + ":" + site . Port
}
}
func verifyConfig ( ) error {
if ! fstore . Exists ( config . DefaultForum ) {
return errors . New ( "Invalid default forum" )
}
return nil
}