diff --git a/internal/httpserver/api/hls.go b/internal/httpserver/api/hls.go new file mode 100644 index 0000000..3f7064b --- /dev/null +++ b/internal/httpserver/api/hls.go @@ -0,0 +1,5 @@ +package api + +func RegisterHlsEndpoints() { + +} diff --git a/internal/httpserver/start.go b/internal/httpserver/start.go index 64ee8a1..65543b0 100644 --- a/internal/httpserver/start.go +++ b/internal/httpserver/start.go @@ -14,6 +14,7 @@ func Start() { api.RegisterMiscEndpoints() api.RegisterAuthEndpoints() api.RegisterLibraryEndpoints() + api.RegisterHlsEndpoints() RegisterWebui() diff --git a/web/js/api/libraries.js b/web/js/api/libraries.js index 581aed1..933f1ae 100644 --- a/web/js/api/libraries.js +++ b/web/js/api/libraries.js @@ -2,6 +2,9 @@ import * as auth from '/web/js/api/auth.js'; import ky from 'https://cdn.jsdelivr.net/npm/ky@1.14.1/+esm' export async function ls(library, path) { + //fix: remove double slashes from path + path = path.replace("//", "/") + try { const response = await ky.get(`/libraries/${library}/${path}`, { headers: { diff --git a/web/js/pages/library_viewer.js b/web/js/pages/library_viewer.js index b7f7a57..80834b3 100644 --- a/web/js/pages/library_viewer.js +++ b/web/js/pages/library_viewer.js @@ -1,4 +1,34 @@ import * as lib from '/web/js/api/libraries.js'; import { url_params } from '/web/js/lib/search_params.js' -console.log(await lib.ls(url_params.get("lib"), url_params.get("path"))) \ No newline at end of file +const library_listing = (await lib.ls(url_params.get("lib"), url_params.get("path"))).Listing + +const container = document.getElementById("library-file-list-container"); +const template = document.getElementById("library-generic-item-template"); + +container.innerHTML = ""; + +//non-fatal error if listing is empty +for (const file_entry of library_listing) { + const clone = template.content.cloneNode(true); + const link = clone.querySelector(".library-generic-item-href"); + + if (file_entry.Type === "directory") { + link.textContent = `