diff --git a/src/webui/assets/md-uploader.js b/src/webui/assets/md-uploader.js index 26e4abe..d8ec231 100644 --- a/src/webui/assets/md-uploader.js +++ b/src/webui/assets/md-uploader.js @@ -357,7 +357,7 @@ class App { const aside = document.createElement("div"); aside.classList.add("sec-aside"); - aside.appendChild(this.generateTextElement("h3", this.tls.parser)); + aside.appendChild(this.generateTextElement("h3", this.tls.parser + ": " + parser.title)); const div = document.createElement("div"); div.classList.add("parser-desc"); diff --git a/src/webui/server.go b/src/webui/server.go index e74d4b9..d90a0ef 100644 --- a/src/webui/server.go +++ b/src/webui/server.go @@ -4,12 +4,35 @@ import ( "fmt" "log" "net/http" + "os/exec" + "runtime" "gitea.armuli.eu/museum-digital/museum-digital-webdav-uploader/src/configloader" ) var config configloader.MDWebDavUploaderConfig var setupRequired bool +// Opens the application in the default browser. +func openInBrowser(port string) { + + var err error + target := "localhost:" + port + switch runtime.GOOS { + case "linux": + err = exec.Command("xdg-open", target).Start() + case "windows": + err = exec.Command("rundll32", "url.dll,FileProtocolHandler", target).Start() + case "darwin": + err = exec.Command("open", target).Start() + default: + err = fmt.Errorf("unsupported platform") + } + if err != nil { + fmt.Println(err) + } + +} + // Sets up the server and manages routing. func Run() { @@ -29,12 +52,19 @@ func Run() { http.HandleFunc("/logo.svg", serveLogo) // Logo. port := "8080" + go func() { - // Set port to listen on - fmt.Println("Server started at port " + string(port)) - err := http.ListenAndServe(":"+port, nil) - if err != nil { - log.Fatal("ListenAndServe: ", err) - } + // Set port to listen on + fmt.Println("Server started at port " + string(port)) + err := http.ListenAndServe(":"+port, nil) + if err != nil { + log.Fatal("ListenAndServe: ", err) + } + + }(); + go func() { + openInBrowser(port) + }(); + select {} }