]> git.example.dev Git - binbsis50-sm.git/commitdiff
updated: more song creation
author2weiEmu <saalbach.robert@outlook.de>
Fri, 12 Jun 2026 10:51:59 +0000 (12:51 +0200)
committer2weiEmu <saalbach.robert@outlook.de>
Fri, 12 Jun 2026 10:51:59 +0000 (12:51 +0200)
main.go
public/index.html
public/js/index.js

diff --git a/main.go b/main.go
index 4822ccaeccb4b9c986647d37821e02ad1de2e6f4..81e0af9f26ece177e7f7b11a59738af04a5879c1 100644 (file)
--- a/main.go
+++ b/main.go
@@ -32,11 +32,11 @@ func main() {
 
        mainLogger := log.New(logFile, "", log.LstdFlags | log.Lshortfile | log.Ldate | log.Ltime)
        mainLogger.Println("=== Logging has begun. === ")
-       mainLogger.Println("Given port:", *paramPort)
-       mainLogger.Println("Given binb_location:", *paramBinbLocation)
-       mainLogger.Println("Given songs_location:", *paramSongsLocation)
-       mainLogger.Println("Given redis_location:", *paramRedisLocation)
-       mainLogger.Println("Given container_name:", *paramContainerName)
+       mainLogger.Println("Given port:", *paramPort) // eg: 8000
+       mainLogger.Println("Given binb_location:", *paramBinbLocation) // eg: ~/Documents/binb
+       mainLogger.Println("Given songs_location:", *paramSongsLocation) // eg: ~/Documents/binb/public/songs
+       mainLogger.Println("Given redis_location:", *paramRedisLocation) // eg: localhost:6379
+       mainLogger.Println("Given container_name:", *paramContainerName) // eg: binbsis50
        
 
        DBwrapper := dbhandling.NewDbWrapper(*paramRedisLocation, *paramSongsLocation, *paramContainerName, *paramBinbLocation)
index 97901fae0140d6c84ba39a35d07d3abb35499e0b..5b4185db415ab8bf2ff2170e26652e4e6458c2c9 100644 (file)
                <h1>Song Creation Menu</h1>
                <hr>
                <h2>Create a New Song</h2>
+               <input id="createSongArtistName" placeholder="Artist Name... (as valid answers, ~ separated...)"></input>
+               <input id="createSongTrackName" placeholder="Track Name... (valid answer)"></input>
+               <input id="createSongTrackViewURL" placeholder="Track View URL... can ignore..."></input>
+               <input id="createSongPreviewURL" placeholder="Preview URL (the url for the song... /songs/NAME.m4a)"></input>
+               <input id="createSongArtworkURL60" placeholder="Artwork URL size 60... (not required)"></input>
+               <input id="createSongArtworkURL100" placeholder="Artwork URL size 100... (not required)"></input>
+               <input id="createSongDisplayArtistNames" placeholder="Artist Names as to be shown..."></input>
+               <input id="createSongDisplayTrackName" placeholder="Track Name as to be shown..."></input>
+               <button id="createSongCreateButton" onclick="createNewSong()">Create!</button>
 
                <hr>
                <h2>Upload a New File with a Link (no YT Links)</h2>
index ac65c747ff5d0d5d96fdaf0b3d5bfb3eda63e924..76825fa95374eef25ed488bc8f1a26e14a0eb5db 100644 (file)
@@ -360,6 +360,48 @@ function openCreationMenu() {
        songCreationMenu.style.display = "block"
 }
 
+let createSongArtistName = document.getElementById("createSongArtistName")
+let createSongTrackName = document.getElementById("createSongTrackName")
+let createSongTrackViewURL = document.getElementById("createSongTrackViewURL")
+let createSongPreviewURL = document.getElementById("createSongPreviewURL")
+let createSongArtworkURL60 = document.getElementById("createSongArtworkURL60")
+let createSongArtworkURL100 = document.getElementById("createSongArtworkURL100")
+let createSongDisplayArtistNames = document.getElementById("createSongDisplayArtistNames")
+let createSongDisplayTrackName = document.getElementById("createSongDisplayTrackName")
+let createSongCreateButton = document.getElementById("createSongCreateButton")
+
+// making a song -> I want to make clear that there is a strong lack of formatting checking anywhere
+async function createNewSong() {
+
+       let song = {
+               Key: 0,
+               ArtistName: createSongArtistName.value,
+               TrackName: createSongTrackName.value,
+               TrackViewURL: createSongTrackViewURL.value,
+               PreviewURL: createSongPreviewURL.value,
+               ArtworkURL60: createSongArtworkURL60.value,
+               ArtworkURL100: createSongArtworkURL100.value,
+               DisplayArtistNames: createSongDisplayArtistNames.value,
+               DisplayTrackName: createSongDisplayTrackName.value,
+       }
+
+       let response = await fetch("/api/songs/create", {
+               method: "POST",
+               body: song
+       })
+
+       if (response.status != 200) {
+               alert("Something went wrong creating the song... harass admin")
+       }
+       else {
+               createSongCreateButton.classList = "success"
+
+               await sleep(500)
+
+               createSongCreateButton.classList = ""
+       }
+}
+
 let fileUploadLinkLink = document.getElementById("fileUploadLinkLink")
 let fileUploadLinkName = document.getElementById("fileUploadLinkName")
 let fileUploadLinkUploadButton = document.getElementById("fileUploadLinkUploadButton")