2020-08-31 17:52:26 +00:00
|
|
|
//go:generate go get -u github.com/valyala/quicktemplate/qtc
|
2021-02-23 14:41:22 +00:00
|
|
|
//go:generate qtc -dir=assets
|
2021-02-20 15:48:51 +00:00
|
|
|
//go:generate qtc -dir=views
|
2021-04-07 17:49:56 +00:00
|
|
|
//go:generate qtc -dir=tree
|
2021-05-11 08:33:00 +00:00
|
|
|
// Command mycorrhiza is a program that runs a mycorrhiza wiki.
|
2020-06-12 16:22:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-05-09 09:36:39 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/cfg"
|
2021-04-28 10:12:05 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/files"
|
2020-08-08 20:10:28 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/history"
|
2021-01-02 21:25:04 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/hyphae"
|
2021-02-20 14:03:54 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/shroom"
|
2020-11-15 12:58:13 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/user"
|
2021-05-09 10:42:12 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/web"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
2020-06-12 16:22:02 +00:00
|
|
|
)
|
|
|
|
|
2020-08-05 15:08:59 +00:00
|
|
|
func main() {
|
2020-10-25 15:06:51 +00:00
|
|
|
parseCliArgs()
|
2021-04-28 10:12:36 +00:00
|
|
|
|
|
|
|
// It is ok if the path is ""
|
2021-05-11 08:33:00 +00:00
|
|
|
cfg.ReadConfigFile()
|
2021-04-28 10:12:36 +00:00
|
|
|
|
2021-04-26 17:25:47 +00:00
|
|
|
if err := files.CalculatePaths(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-05-12 14:08:01 +00:00
|
|
|
log.Println("Running MycorrhizaWiki 1.2.0 indev")
|
2021-05-09 10:42:12 +00:00
|
|
|
if err := os.Chdir(cfg.WikiDir); err != nil {
|
2020-08-19 18:54:23 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2021-05-09 10:42:12 +00:00
|
|
|
log.Println("Wiki storage directory is", cfg.WikiDir)
|
2020-08-05 15:08:59 +00:00
|
|
|
|
2021-05-09 11:09:27 +00:00
|
|
|
// Init the subsystems:
|
|
|
|
hyphae.Index(cfg.WikiDir)
|
2021-04-28 10:12:05 +00:00
|
|
|
user.InitUserDatabase()
|
2021-05-11 10:14:00 +00:00
|
|
|
history.Start()
|
2021-02-20 14:03:54 +00:00
|
|
|
shroom.SetHeaderLinks()
|
2020-08-08 20:10:28 +00:00
|
|
|
|
2021-05-09 11:09:27 +00:00
|
|
|
// Network:
|
2021-02-09 14:35:02 +00:00
|
|
|
go handleGemini()
|
2021-05-09 10:42:12 +00:00
|
|
|
web.Init()
|
2021-05-09 09:36:39 +00:00
|
|
|
log.Fatal(http.ListenAndServe("0.0.0.0:"+cfg.HTTPPort, nil))
|
2020-06-12 16:22:02 +00:00
|
|
|
}
|