diff options
| author | Christine Dodrill <me@christine.website> | 2020-03-18 16:45:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-18 16:45:55 -0400 |
| commit | 7dc75b17a4c38c312ef87412273b3d7636746a1b (patch) | |
| tree | 57502a097318be6ef6f24aeb6968ccb6eb51f3fa /cmd | |
| parent | 207f6a32f578f0465af6c2788b4c5cb02d1ad5ba (diff) | |
| download | xesite-7dc75b17a4c38c312ef87412273b3d7636746a1b.tar.xz xesite-7dc75b17a4c38c312ef87412273b3d7636746a1b.zip | |
signal boost page (#128)
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/site/main.go | 24 | ||||
| -rw-r--r-- | cmd/site/signalboost.go | 29 | ||||
| -rw-r--r-- | cmd/site/signalboost_test.go | 28 |
3 files changed, 73 insertions, 8 deletions
diff --git a/cmd/site/main.go b/cmd/site/main.go index 3a534f0..bb7b369 100644 --- a/cmd/site/main.go +++ b/cmd/site/main.go @@ -56,13 +56,14 @@ func main() { // Site is the parent object for https://christine.website's backend. type Site struct { - Posts blog.Posts - Talks blog.Posts - Gallery blog.Posts - Resume template.HTML - Series []string - patrons []string - + Posts blog.Posts + Talks blog.Posts + Gallery blog.Posts + Resume template.HTML + Series []string + SignalBoost []Person + + patrons []string rssFeed *feeds.Feed jsonFeed *jsonfeed.Feed @@ -100,6 +101,11 @@ func Build() (*Site, error) { return nil, err } + people, err := loadPeople("./signalboost.dhall") + if err != nil { + return nil, err + } + smi := sitemap.New() smi.Add(&sitemap.URL{ Loc: "https://christine.website/resume", @@ -162,7 +168,8 @@ func Build() (*Site, error) { mux: http.NewServeMux(), xffmw: xffmw, - patrons: pledges, + patrons: pledges, + SignalBoost: people, } posts, err := blog.LoadPosts("./blog/", "blog") @@ -236,6 +243,7 @@ func Build() (*Site, error) { }) s.mux.Handle("/metrics", promhttp.Handler()) s.mux.Handle("/patrons", middleware.Metrics("patrons", s.renderTemplatePage("patrons.html", s.patrons))) + s.mux.Handle("/signalboost", middleware.Metrics("signalboost", s.renderTemplatePage("signalboost.html", s.SignalBoost))) s.mux.Handle("/resume", middleware.Metrics("resume", s.renderTemplatePage("resume.html", s.Resume))) s.mux.Handle("/blog", middleware.Metrics("blog", s.renderTemplatePage("blogindex.html", s.Posts))) s.mux.Handle("/talks", middleware.Metrics("talks", s.renderTemplatePage("talkindex.html", s.Talks))) diff --git a/cmd/site/signalboost.go b/cmd/site/signalboost.go new file mode 100644 index 0000000..c242711 --- /dev/null +++ b/cmd/site/signalboost.go @@ -0,0 +1,29 @@ +package main + +import ( + "io/ioutil" + + "github.com/philandstuff/dhall-golang" +) + +type Person struct { + Name string `dhall:"name"` + GitLink string `dhall:"gitLink"` + Twitter string `dhall:"twitter"` + Tags []string `dhall:"tags"` +} + +func loadPeople(path string) ([]Person, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + var people []Person + err = dhall.Unmarshal(data, &people) + if err != nil { + return nil, err + } + + return people, nil +} diff --git a/cmd/site/signalboost_test.go b/cmd/site/signalboost_test.go new file mode 100644 index 0000000..7f53943 --- /dev/null +++ b/cmd/site/signalboost_test.go @@ -0,0 +1,28 @@ +package main + +import "testing" + +func TestLoadPeople(t *testing.T) { + people, err := loadPeople("../../signalboost.dhall") + if err != nil {t.Fatal(err)} + + for _, person := range people { + t.Run(person.Name, func(t *testing.T) { + if person.Name == "" { + t.Error("missing name") + } + + if len(person.Tags) == 0 { + t.Error("missing tags") + } + + if person.Twitter == "" { + t.Error("missing twitter") + } + + if person.GitLink == "" { + t.Error("missing git link") + } + }) + } +} |
