}
}
+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) {
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Broadcaster</title>
- <style type="text/css">
- table.radio-status, td.outer {
- border: 1px solid;
- }
- table.inner {
- border-collapse: collapse;
- }
- td.clear {
- width: 5em;
- height: 5em;
- text-align: center;
- }
- .time-table {
- font-size: 90%;
- }
- .playlist-field {
- text-align: right;
- padding-right: 1em;
- width: 5em;
- }
- .playlist-table {
- font-size: 90%;
- width: 30em;
- }
- .stop {
- text-align: center;
- }
- .head {
- text-align: center;
- }
- </style>
<script type="text/javascript">
function connectWebsocket() {
console.log("Attempting to create websocket connection for radio status sync")
// initial connection on page load
connectWebsocket();
</script>
- </head>
- <body>
- <main>
+
<h1>Welcome!</h1>
{{if .LoggedIn}}
<p>Your username is: {{.Username}}.</p>
<div id="connected-radios">
<i>Loading...</i>
</div>
- </main>
- </body>
-</html>