bf851bd9fc
Added support for dyntmpl to the template system. The Account Dashboard now sort of uses dyntmpl, more work needed here. Renamed the pre_render_view_topic hook to pre_render_topic. Added the GetCurrentLangPack() function. Added the alerts_no_new_alerts phrase. Added the account_level_list phrase. Refactored the route rename logic in the patcher to cut down on the amount of boilerplate. Added more route renames to the patcher. You will need to run the patcher / updater in this commit.
108 lines
2.3 KiB
Go
108 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"log"
|
|
|
|
"github.com/Azareal/Gosora/common"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
var stmts *Stmts
|
|
|
|
var db *sql.DB
|
|
var dbAdapter string
|
|
|
|
// ErrNoRows is an alias of sql.ErrNoRows, just in case we end up with non-database/sql datastores
|
|
var ErrNoRows = sql.ErrNoRows
|
|
|
|
var _initDatabase func() error
|
|
|
|
func InitDatabase() (err error) {
|
|
stmts = &Stmts{Mocks: false}
|
|
|
|
// Engine specific code
|
|
err = _initDatabase()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
globs = &Globs{stmts}
|
|
|
|
log.Print("Running the db handlers.")
|
|
err = common.DbInits.Run()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
log.Print("Loading the usergroups.")
|
|
common.Groups, err = common.NewMemoryGroupStore()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
err2 := common.Groups.LoadGroups()
|
|
if err2 != nil {
|
|
return errors.WithStack(err2)
|
|
}
|
|
|
|
// We have to put this here, otherwise LoadForums() won't be able to get the last poster data when building it's forums
|
|
log.Print("Initialising the user and topic stores")
|
|
|
|
var ucache common.UserCache
|
|
if common.Config.UserCache == "static" {
|
|
ucache = common.NewMemoryUserCache(common.Config.UserCacheCapacity)
|
|
}
|
|
|
|
var tcache common.TopicCache
|
|
if common.Config.TopicCache == "static" {
|
|
tcache = common.NewMemoryTopicCache(common.Config.TopicCacheCapacity)
|
|
}
|
|
|
|
common.Users, err = common.NewDefaultUserStore(ucache)
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
common.Topics, err = common.NewDefaultTopicStore(tcache)
|
|
if err != nil {
|
|
return errors.WithStack(err2)
|
|
}
|
|
|
|
log.Print("Loading the forums.")
|
|
common.Forums, err = common.NewMemoryForumStore()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
err = common.Forums.LoadForums()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
log.Print("Loading the forum permissions.")
|
|
common.FPStore, err = common.NewMemoryForumPermsStore()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
err = common.FPStore.Init()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
log.Print("Loading the settings.")
|
|
err = common.LoadSettings()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
log.Print("Loading the plugins.")
|
|
err = common.InitExtend()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
log.Print("Loading the themes.")
|
|
err = common.Themes.LoadActiveStatus()
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
return nil
|
|
}
|