2022-09-14 07:39:37 +00:00
|
|
|
// Command mycorrhiza is a program that runs a mycorrhiza wiki.
|
|
|
|
//
|
2021-11-10 13:14:39 +00:00
|
|
|
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=tree
|
|
|
|
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=history
|
2022-06-10 15:45:27 +00:00
|
|
|
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=mycoopts
|
2022-08-06 11:35:17 +00:00
|
|
|
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=auth
|
|
|
|
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=hypview
|
2020-06-12 16:22:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-04-02 16:58:57 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/backlinks"
|
2022-04-01 19:52:38 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/categories"
|
2022-05-27 13:43:40 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/interwiki"
|
2022-01-30 21:34:52 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/migration"
|
2022-09-04 18:49:31 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/version"
|
2022-03-29 20:59:36 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/viewutil"
|
2021-06-19 04:51:10 +00:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
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"
|
2021-06-12 13:51:28 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/static"
|
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"
|
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
|
|
|
|
2021-06-19 04:51:10 +00:00
|
|
|
if err := files.PrepareWikiRoot(); err != nil {
|
2021-04-26 17:25:47 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2021-06-19 17:00:28 +00:00
|
|
|
|
|
|
|
if err := cfg.ReadConfigFile(files.ConfigPath()); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2021-04-26 17:25:47 +00:00
|
|
|
|
2022-09-14 07:38:36 +00:00
|
|
|
log.Println("Running Mycorrhiza Wiki", version.Short)
|
2021-06-19 04:51:10 +00:00
|
|
|
if err := os.Chdir(files.HyphaeDir()); err != nil {
|
2020-08-19 18:54:23 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2021-06-19 04:51:10 +00:00
|
|
|
log.Println("Wiki directory is", cfg.WikiDir)
|
2020-08-05 15:08:59 +00:00
|
|
|
|
2021-05-09 11:09:27 +00:00
|
|
|
// Init the subsystems:
|
2022-03-29 20:59:36 +00:00
|
|
|
viewutil.Init()
|
2021-06-19 04:51:10 +00:00
|
|
|
hyphae.Index(files.HyphaeDir())
|
2021-12-20 21:08:21 +00:00
|
|
|
backlinks.IndexBacklinks()
|
|
|
|
go backlinks.RunBacklinksConveyor()
|
2021-04-28 10:12:05 +00:00
|
|
|
user.InitUserDatabase()
|
2021-05-11 10:14:00 +00:00
|
|
|
history.Start()
|
2021-06-19 06:04:04 +00:00
|
|
|
history.InitGitRepo()
|
2022-01-30 21:34:52 +00:00
|
|
|
migration.MigrateRocketsMaybe()
|
2022-05-20 10:17:53 +00:00
|
|
|
migration.MigrateHeadingsMaybe()
|
2021-02-20 14:03:54 +00:00
|
|
|
shroom.SetHeaderLinks()
|
2022-04-01 22:01:54 +00:00
|
|
|
categories.Init()
|
2022-05-27 13:43:40 +00:00
|
|
|
interwiki.Init()
|
2020-08-08 20:10:28 +00:00
|
|
|
|
2021-06-12 13:51:28 +00:00
|
|
|
// Static files:
|
2021-06-19 04:51:10 +00:00
|
|
|
static.InitFS(files.StaticFiles())
|
2021-06-12 13:51:28 +00:00
|
|
|
|
2021-07-15 17:46:35 +00:00
|
|
|
serveHTTP(web.Handler())
|
2020-06-12 16:22:02 +00:00
|
|
|
}
|