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