X-Git-Url: https://code.octet-stream.net/broadcaster/blobdiff_plain/587f9c5bb84420d9f71fe75e29f54b8319c90064..7423c6c97eb5d6dc063e7185c50137bbb5e25a23:/broadcaster-server/main.go?ds=sidebyside diff --git a/broadcaster-server/main.go b/broadcaster-server/main.go index c44ff76..5a3cbb9 100644 --- a/broadcaster-server/main.go +++ b/broadcaster-server/main.go @@ -2,7 +2,7 @@ package main import ( "bufio" - "embed" + _ "embed" "flag" "fmt" "golang.org/x/net/websocket" @@ -20,8 +20,9 @@ import ( const version = "v1.0.0" const formatString = "2006-01-02T15:04" -//go:embed templates/* -var content embed.FS +// //go:embed templates/* +//var content embed.FS +var content = os.DirFS("../broadcaster-server/") var config ServerConfig = NewServerConfig() @@ -100,19 +101,27 @@ func main() { type HeaderData struct { SelectedMenu string + Username string } func renderHeader(w http.ResponseWriter, selectedMenu string) { tmpl := template.Must(template.ParseFS(content, "templates/header.html")) data := HeaderData{ SelectedMenu: selectedMenu, + Username: "username", + } + err := tmpl.Execute(w, data) + if err != nil { + log.Fatal(err) } - tmpl.Execute(w, data) } func renderFooter(w http.ResponseWriter) { tmpl := template.Must(template.ParseFS(content, "templates/footer.html")) - tmpl.Execute(w, nil) + err := tmpl.Execute(w, nil) + if err != nil { + log.Fatal(err) + } } type HomeData struct { @@ -505,7 +514,7 @@ func uploadFile(w http.ResponseWriter, r *http.Request) { func logOutPage(w http.ResponseWriter, r *http.Request) { clearSessionCookie(w) - renderHeader(w, "logout") + renderHeader(w, "") tmpl := template.Must(template.ParseFS(content, "templates/logout.html")) tmpl.Execute(w, nil) renderFooter(w)