From 8b1d8bf26452f3ce8b38228a39755a6b8e18775a Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Thu, 15 Jul 2021 01:10:41 -0400 Subject: Start on the example website. Remove some chunks of code. Fix up author handling in the feeds. --- cmd/server/app.go | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 cmd/server/app.go (limited to 'cmd/server/app.go') 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 +} -- cgit v1.2.3