mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-20 23:36:51 +00:00
0426c372de
See https://mycorrhiza.lesarbr.es/hypha/configuration for an example. A copy of this example is stored at assets/config.ini. Use option -config-path to pass the config file. Note that all other CLI options have been removed. Some of them may be returned later. Also note that no real testing has been done.
71 lines
1.3 KiB
Go
71 lines
1.3 KiB
Go
package util
|
|
|
|
import (
|
|
"log"
|
|
"strconv"
|
|
|
|
"github.com/go-ini/ini"
|
|
)
|
|
|
|
type Config struct {
|
|
WikiName string
|
|
NaviTitleIcon string
|
|
Hyphae
|
|
Network
|
|
Authorization
|
|
}
|
|
|
|
type Hyphae struct {
|
|
HomeHypha string
|
|
UserHypha string
|
|
HeaderLinksHypha string
|
|
}
|
|
|
|
type Network struct {
|
|
HTTPPort uint64
|
|
URL string
|
|
GeminiCertificatePath string
|
|
}
|
|
|
|
type Authorization struct {
|
|
UseFixedAuth bool
|
|
FixedAuthCredentialsPath string
|
|
}
|
|
|
|
func ReadConfigFile(path string) {
|
|
log.Println("Loading config at", path)
|
|
cfg := &Config{
|
|
WikiName: "MycorrhizaWiki",
|
|
NaviTitleIcon: "🍄",
|
|
Hyphae: Hyphae{
|
|
HomeHypha: "home",
|
|
UserHypha: "u",
|
|
HeaderLinksHypha: "",
|
|
},
|
|
Network: Network{
|
|
HTTPPort: 1737,
|
|
URL: "",
|
|
GeminiCertificatePath: "",
|
|
},
|
|
Authorization: Authorization{
|
|
UseFixedAuth: false,
|
|
FixedAuthCredentialsPath: "",
|
|
},
|
|
}
|
|
err := ini.MapTo(cfg, path)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
SiteName = cfg.WikiName
|
|
SiteNavIcon = cfg.NaviTitleIcon
|
|
HomePage = cfg.HomeHypha
|
|
UserHypha = cfg.UserHypha
|
|
HeaderLinksHypha = cfg.HeaderLinksHypha
|
|
ServerPort = strconv.FormatUint(cfg.HTTPPort, 10)
|
|
URL = cfg.URL
|
|
GeminiCertPath = cfg.GeminiCertificatePath
|
|
UseFixedAuth = cfg.UseFixedAuth
|
|
FixedCredentialsPath = cfg.FixedAuthCredentialsPath
|
|
}
|