1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 03:36:16 +00:00
mycorrhiza/main.go
2021-06-23 21:01:34 +07:00

55 lines
1.3 KiB
Go

//go:generate go get -u github.com/valyala/quicktemplate/qtc
//go:generate qtc -dir=assets
//go:generate qtc -dir=views
//go:generate qtc -dir=tree
// Command mycorrhiza is a program that runs a mycorrhiza wiki.
package main
import (
"log"
"net/http"
"os"
"github.com/bouncepaw/mycorrhiza/cfg"
"github.com/bouncepaw/mycorrhiza/files"
"github.com/bouncepaw/mycorrhiza/history"
"github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/shroom"
"github.com/bouncepaw/mycorrhiza/static"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/web"
)
func main() {
parseCliArgs()
// It is ok if the path is ""
cfg.ReadConfigFile()
if err := files.PrepareWikiRoot(); err != nil {
log.Fatal(err)
}
log.Println("Running Mycorrhiza Wiki 1.2.0 indev")
if err := os.Chdir(files.HyphaeDir()); err != nil {
log.Fatal(err)
}
log.Println("Wiki directory is", cfg.WikiDir)
log.Println("Using Git storage at", files.HyphaeDir())
// Init the subsystems:
hyphae.Index(files.HyphaeDir())
user.InitUserDatabase()
history.Start()
history.InitGitRepo()
shroom.SetHeaderLinks()
// Static files:
static.InitFS(files.StaticFiles())
// Network:
go handleGemini()
web.Init()
log.Fatal(http.ListenAndServe("0.0.0.0:"+cfg.HTTPPort, nil))
}