diff options
| author | Fuwn <[email protected]> | 2021-07-15 21:28:23 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-15 21:28:23 +0000 |
| commit | 1588d2eeb29d74e7a70f87d7f8db3bb13da12950 (patch) | |
| tree | 9cb5f3b9fa2079fe6f23aa899cb514c76a8993a9 | |
| parent | feat(skills): add go (diff) | |
| download | space-1588d2eeb29d74e7a70f87d7f8db3bb13da12950.tar.xz space-1588d2eeb29d74e7a70f87d7f8db3bb13da12950.zip | |
feat(templates): poc for a sysinfo footer item
| -rw-r--r-- | go.mod | 1 | ||||
| -rw-r--r-- | route.go | 9 | ||||
| -rw-r--r-- | space.go | 2 | ||||
| -rw-r--r-- | template.go | 7 |
4 files changed, 13 insertions, 6 deletions
@@ -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 ) @@ -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(), }) }) @@ -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 { |