Pass system to template
This commit is contained in:
parent
3adbf11558
commit
a7cb7e3ef1
2 changed files with 16 additions and 7 deletions
20
main.go
20
main.go
|
@ -41,23 +41,31 @@ func main() {
|
|||
defer g.logger.Sync()
|
||||
g.setupEchoLogging()
|
||||
|
||||
w := weather.NewWeatherService(g.logger)
|
||||
b := bookmarks.NewBookmarkService(g.logger)
|
||||
if g.config.LiveSystem {
|
||||
system.NewSystemService(g.logger)
|
||||
}
|
||||
|
||||
g.router.Use(middleware.Recover())
|
||||
g.router.Use(middleware.GzipWithConfig(middleware.GzipConfig{Level: 5}))
|
||||
g.router.Pre(middleware.RemoveTrailingSlash())
|
||||
|
||||
w := weather.NewWeatherService(g.logger)
|
||||
b := bookmarks.NewBookmarkService(g.logger)
|
||||
var s *system.System
|
||||
if g.config.LiveSystem {
|
||||
s = system.NewSystemService(g.logger)
|
||||
}
|
||||
|
||||
g.router.GET("/", func(c echo.Context) error {
|
||||
return c.Render(http.StatusOK, "index.gohtml", map[string]interface{}{
|
||||
"Title": g.config.Title,
|
||||
"Weather": w.CurrentWeather,
|
||||
"Bookmarks": b.Categories,
|
||||
"System": s,
|
||||
})
|
||||
})
|
||||
g.router.Static("/static", "static")
|
||||
g.router.Static("/storage/icons", "storage/icons")
|
||||
|
||||
g.router.GET("/robots.txt", func(c echo.Context) error {
|
||||
return c.String(http.StatusOK, "User-agent: *\nDisallow: /")
|
||||
})
|
||||
|
||||
g.router.Logger.Fatal(g.router.Start(fmt.Sprintf(":%d", g.config.Port)))
|
||||
}
|
||||
|
|
|
@ -5,9 +5,10 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func NewSystemService(logging *zap.SugaredLogger) {
|
||||
func NewSystemService(logging *zap.SugaredLogger) *System {
|
||||
s := System{log: logging}
|
||||
s.Initialize()
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *System) UpdateLiveInformation() {
|
||||
|
|
Loading…
Add table
Reference in a new issue