diff options
author | FChannel <> | 2022-04-23 12:44:38 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 9718d34a757b66917747c1c4acfb9b35d154625b (patch) | |
tree | f1364b982ca9b10777d18bb15bd61ccc29fe1dbb | |
parent | 363952bfdbae19758e0241e438b95da65d084331 (diff) |
added config package since WSJ config is ignored from .gitignore
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | config/config.go | 54 |
3 files changed, 57 insertions, 2 deletions
@@ -3,6 +3,7 @@ *~ #* public/ -config +config$ +config/config-init clientkey pem/ @@ -41,7 +41,7 @@ and to fix errors reported by `go vet` and make your code better with - Ensure you have Golang installed and set a correct `GOPATH` - `git clone` the software -- Copy `config-init` to `config` and change the values appropriately to reflect the instance. +- Copy `config-init` to `config/config-init` and change the values appropriately to reflect the instance. - Create the database, username, and password for psql that is used in the `config` file. - Build the server with `make` - Start the server with `./fchan`. diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..d9e5a94 --- /dev/null +++ b/config/config.go @@ -0,0 +1,54 @@ +package config + +import ( + "bufio" + "log" + "os" + "strconv" + "strings" +) + +var Port = ":" + GetConfigValue("instanceport", "3000") +var TP = GetConfigValue("instancetp", "") +var Domain = GetConfigValue("instance", "") +var InstanceName = GetConfigValue("instancename", "") +var InstanceSummary = GetConfigValue("instancesummary", "") +var SiteEmail = GetConfigValue("emailaddress", "") //contact@fchan.xyz +var SiteEmailPassword = GetConfigValue("emailpass", "") +var SiteEmailServer = GetConfigValue("emailserver", "") //mail.fchan.xyz +var SiteEmailPort = GetConfigValue("emailport", "") //587 +var TorProxy = GetConfigValue("torproxy", "") //127.0.0.1:9050 +var PublicIndexing = strings.ToLower(GetConfigValue("publicindex", "false")) +var Salt = GetConfigValue("instancesalt", "") +var DBHost = GetConfigValue("dbhost", "localhost") +var DBPort, _ = strconv.Atoi(GetConfigValue("dbport", "5432")) +var DBUser = GetConfigValue("dbuser", "postgres") +var DBPassword = GetConfigValue("dbpass", "password") +var DBName = GetConfigValue("dbname", "server") +var Redis = GetConfigValue("redis", "redis://localhost") +var ActivityStreams = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" +var SupportedFiles = []string{"image/gif", "image/jpeg", "image/png", "image/webp", "image/apng", "video/mp4", "video/ogg", "video/webm", "audio/mpeg", "audio/ogg", "audio/wav", "audio/wave", "audio/x-wav"} +var Key string +var Themes []string + +func GetConfigValue(value string, ifnone string) string { + file, err := os.Open("config/config-init") + + if err != nil { + log.Print(err) + return ifnone + } + + defer file.Close() + + lines := bufio.NewScanner(file) + + for lines.Scan() { + line := strings.SplitN(lines.Text(), ":", 2) + if line[0] == value { + return line[1] + } + } + + return ifnone +} |