mycorrhiza/main.go
handlerug 839f8bc2d6
New static files system
assets.qtpl is no more! Now you can just add files to static/ folder,
make sure the extension is registered in static.go (a shortcoming
that'll be addressed in future Go versions), and you're done! It
searches the local file system first, then falls back to the files
embedded with the binary (in the static/ folder).
2021-06-12 20:58:04 +07:00

52 lines
1.2 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 (
"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"
"log"
"net/http"
"os"
)
func main() {
parseCliArgs()
// It is ok if the path is ""
cfg.ReadConfigFile()
if err := files.CalculatePaths(); err != nil {
log.Fatal(err)
}
log.Println("Running MycorrhizaWiki 1.2.0 indev")
if err := os.Chdir(cfg.WikiDir); err != nil {
log.Fatal(err)
}
log.Println("Wiki storage directory is", cfg.WikiDir)
// Init the subsystems:
hyphae.Index(cfg.WikiDir)
user.InitUserDatabase()
history.Start()
shroom.SetHeaderLinks()
// Static files:
static.InitFS(cfg.WikiDir + "/static")
// Network:
go handleGemini()
web.Init()
log.Fatal(http.ListenAndServe("0.0.0.0:"+cfg.HTTPPort, nil))
}