Skip to content

Commit

Permalink
web, code cleanup for templating
Browse files Browse the repository at this point in the history
  • Loading branch information
BuJo committed Jul 1, 2024
1 parent 4e1abac commit 0accd28
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions pkg/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ func (h *webHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type renderFunc func(w http.ResponseWriter, statusCode int, data webContent)

func (h *webHandler) baseRenderer(req *http.Request, dashboardName string, patterns ...string) renderFunc {
var templateFiles []string
var templateDefinition string

templateFiles = append([]string{"_base.gohtml"}, patterns...)
templateDefinition = "base"
templateFiles := append([]string{"_base.gohtml"}, patterns...)
templateDefinition := "base"

funcs := html.FuncMap{
"niceDuration": niceDuration,
Expand Down Expand Up @@ -139,11 +136,8 @@ func (h *webHandler) baseRenderer(req *http.Request, dashboardName string, patte
}

func (h *webHandler) partialRenderer(req *http.Request, dashboardName string, patterns ...string) renderFunc {
var templateFiles []string
var templateDefinition string

templateFiles = append([]string{"_stream.gohtml"}, patterns...)
templateDefinition = "base"
templateFiles := append([]string{"_stream.gohtml"}, patterns...)
templateDefinition := "base"

funcs := html.FuncMap{
"niceDuration": niceDuration,
Expand Down Expand Up @@ -174,11 +168,8 @@ func (h *webHandler) partialRenderer(req *http.Request, dashboardName string, pa
type sseRenderFunc func(data webContent) error

func (h *webHandler) sseRenderer(w http.ResponseWriter, req *http.Request, patterns ...string) (sseRenderFunc, context.CancelFunc) {
var templateFiles []string
var templateDefinition string

templateFiles = append([]string{"_stream.gohtml"}, patterns...)
templateDefinition = "content-container"
templateFiles := append([]string{"_stream.gohtml"}, patterns...)
templateDefinition := "content-container"

funcs := html.FuncMap{
"niceDuration": niceDuration,
Expand Down Expand Up @@ -260,11 +251,8 @@ func (h *webHandler) sseRenderer(w http.ResponseWriter, req *http.Request, patte
type wsRenderFunc func(data webContent)

func (h *webHandler) wsRenderer(s *websocket.Conn, patterns ...string) wsRenderFunc {
var templateFiles []string
var templateDefinition string

templateFiles = append([]string{"_stream.gohtml"}, patterns...)
templateDefinition = "content-container"
templateFiles := append([]string{"_stream.gohtml"}, patterns...)
templateDefinition := "content-container"

funcs := html.FuncMap{
"niceDuration": niceDuration,
Expand Down

0 comments on commit 0accd28

Please sign in to comment.