aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/app.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-07-18 16:27:24 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-07-18 16:27:24 -0400
commitbcf6d391f17a193c81ad6643f8d006de6c6abad8 (patch)
treeb8eaec45b02d79f8d51d6726ffbbe34ce5de2ed7 /cmd/server/app.go
parent904e37a88a6a2eab3919f7f2c40bbb2c07544a7c (diff)
downloadgo-website-0.0.13.tar.gz
go-website-0.0.13.tar.xz
Adjust the program a bit, remove clunky "head" templates. Add an example site among other improvementsv0.0.13
Diffstat (limited to 'cmd/server/app.go')
-rw-r--r--cmd/server/app.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/cmd/server/app.go b/cmd/server/app.go
new file mode 100644
index 0000000..743a389
--- /dev/null
+++ b/cmd/server/app.go
@@ -0,0 +1,63 @@
+package main
+
+import (
+ "os"
+
+ "gopkg.in/yaml.v3"
+ "riedstra.dev/mitch/go-website/page"
+)
+
+var FeedPrefixDefault = ".feeds"
+
+type App struct {
+ ReIndexPath string
+ StaticDirectory string
+ BaseTemplate string
+ DocumentSplit string
+ Suffix string
+
+ // Related to the Atom feed
+ Title string
+ Description string // aka, "subtitle"
+ Author Author
+ SiteURL string
+ FeedId string
+ Updated page.PageTime
+ FeedPrefix string
+}
+
+func loadConf(fn string) (*App, error) {
+ fh, err := os.Open(fn)
+ if err != nil {
+ return nil, err
+ }
+ dec := yaml.NewDecoder(fh)
+
+ app := &App{}
+ err = dec.Decode(app)
+ if err != nil {
+ return nil, err
+ }
+
+ if app.StaticDirectory == "" {
+ app.StaticDirectory = "static"
+ }
+ if app.FeedPrefix == "" {
+ app.FeedPrefix = FeedPrefixDefault
+ }
+ if app.BaseTemplate != "" {
+ page.BaseTemplate = app.BaseTemplate
+ }
+ if app.DocumentSplit != "" {
+ page.DocumentSplit = app.DocumentSplit
+ }
+ if app.Suffix != "" {
+ page.Suffix = app.Suffix
+ }
+
+ page.Global = map[string]interface{}{
+ "App": app,
+ }
+
+ return app, nil
+}