From 1588d2eeb29d74e7a70f87d7f8db3bb13da12950 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 15 Jul 2021 21:28:23 +0000 Subject: feat(templates): poc for a sysinfo footer item --- go.mod | 1 + route.go | 9 ++++++--- space.go | 2 ++ template.go | 7 ++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 96de27a..c126311 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.16 require ( github.com/pitr/gig v0.9.8 + // github.com/shirou/gopsutil v3.21.6+incompatible github.com/sonyarouje/simdb v0.1.0 github.com/spf13/viper v1.8.1 ) diff --git a/route.go b/route.go index 4d5aacc..f6abef7 100644 --- a/route.go +++ b/route.go @@ -10,11 +10,14 @@ import ( ) func createRoute(route string, template string, content string) { + // hostInformation, _ := host.Info() + g.Handle(route, func(c gig.Context) error { return c.Render(template, IndexTemplate{ - Content: GetContent(content), - Quote: utilities.GetRandomQuote(), - Hits: database.Get(route) + 1, + Content: GetContent(content), + Quote: utilities.GetRandomQuote(), + Hits: database.Get(route) + 1, + // SystemInfo: fmt.Sprintf("Host: %s %s, Uptime: %d seconds, Routes: %d", strings.Title(hostInformation.Platform), strings.Title(hostInformation.OS), int64(time.Since(startTime).Seconds()), len(g.Routes())), Copyright: utilities.GetCopyright(), }) }) diff --git a/space.go b/space.go index 976ae7c..8f6f506 100644 --- a/space.go +++ b/space.go @@ -22,6 +22,8 @@ var g = gig.Default() var hitsTracker = make(map[string]int) +// var startTime = time.Now() + // Initialize templates func init() { templates, _ := fs.Sub(contentFilesystem, "content/templates") diff --git a/template.go b/template.go index 2e992d7..3d5687b 100644 --- a/template.go +++ b/template.go @@ -17,9 +17,10 @@ type Template struct { } type IndexTemplate struct { - Content string - Quote string - Hits int + Content string + Quote string + Hits int + // SystemInfo string Copyright string } type ErrorTemplate struct { -- cgit v1.2.3