}
}
+type HeaderData struct {
+ SelectedMenu string
+}
+
+func renderHeader(w http.ResponseWriter, selectedMenu string) {
+ tmpl := template.Must(template.ParseFS(content, "templates/header.html"))
+ data := HeaderData{
+ SelectedMenu: selectedMenu,
+ }
+ tmpl.Execute(w, data)
+}
+
+func renderFooter(w http.ResponseWriter) {
+ tmpl := template.Must(template.ParseFS(content, "templates/footer.html"))
+ tmpl.Execute(w, nil)
+}
+
type HomeData struct {
LoggedIn bool
Username string
}
func homePage(w http.ResponseWriter, r *http.Request) {
+ renderHeader(w, "status")
tmpl := template.Must(template.ParseFS(content, "templates/index.html"))
data := HomeData{
LoggedIn: true,
Username: "Bob",
}
tmpl.Execute(w, data)
+ renderFooter(w)
}
type LogInData struct {
data := LogInData{
Error: errText,
}
-
+ renderHeader(w, "")
tmpl := template.Must(template.ParseFS(content, "templates/login.html"))
tmpl.Execute(w, data)
+ renderFooter(w)
}
func playlistSection(w http.ResponseWriter, r *http.Request) {
data.Message = ""
data.ShowForm = true
}
+ renderHeader(w, "change-password")
tmpl := template.Must(template.ParseFS(content, "templates/change_password.html"))
err = tmpl.Execute(w, data)
if err != nil {
log.Fatal(err)
}
+ renderFooter(w)
}
type PlaylistsPageData struct {
}
func playlistsPage(w http.ResponseWriter, _ *http.Request) {
+ renderHeader(w, "playlists")
data := PlaylistsPageData{
Playlists: db.GetPlaylists(),
}
if err != nil {
log.Fatal(err)
}
+ renderFooter(w)
}
type RadiosPageData struct {
}
func radiosPage(w http.ResponseWriter, _ *http.Request) {
+ renderHeader(w, "radios")
data := RadiosPageData{
Radios: db.GetRadios(),
}
if err != nil {
log.Fatal(err)
}
+ renderFooter(w)
}
type EditPlaylistPageData struct {
data.Playlist = playlist
data.Entries = db.GetEntriesForPlaylist(id)
}
+ renderHeader(w, "radios")
tmpl := template.Must(template.ParseFS(content, "templates/playlist.html"))
tmpl.Execute(w, data)
+ renderFooter(w)
}
func submitPlaylist(w http.ResponseWriter, r *http.Request) {
}
data.Radio = radio
}
+ renderHeader(w, "radios")
tmpl := template.Must(template.ParseFS(content, "templates/radio.html"))
tmpl.Execute(w, data)
+ renderFooter(w)
}
func submitRadio(w http.ResponseWriter, r *http.Request) {
}
func filesPage(w http.ResponseWriter, _ *http.Request) {
+ renderHeader(w, "files")
data := FilesPageData{
Files: files.Files(),
}
if err != nil {
log.Fatal(err)
}
+ renderFooter(w)
}
func deleteFile(w http.ResponseWriter, r *http.Request) {
func logOutPage(w http.ResponseWriter, r *http.Request) {
clearSessionCookie(w)
+ renderHeader(w, "logout")
tmpl := template.Must(template.ParseFS(content, "templates/logout.html"))
tmpl.Execute(w, nil)
+ renderFooter(w)
}
func stopPage(w http.ResponseWriter, r *http.Request) {