From f3d3e77f0fbf8026893178c51933af0767747eed Mon Sep 17 00:00:00 2001 From: John Hess Date: Wed, 5 Jun 2024 14:16:00 -0500 Subject: [PATCH] breadcrumbs --- assets/css/butter-dir-listing.css | 31 ++- assets/images/home.svg | 4 + assets/images/next.svg | 4 + assets/js/butter-dir-listing.js | 34 ++- simulated-usb-butter/johns_folder/index.html | 225 +++++++++++++++++++ 5 files changed, 293 insertions(+), 5 deletions(-) create mode 100644 assets/images/home.svg create mode 100644 assets/images/next.svg create mode 100644 simulated-usb-butter/johns_folder/index.html diff --git a/assets/css/butter-dir-listing.css b/assets/css/butter-dir-listing.css index fcd0ccb..e258684 100644 --- a/assets/css/butter-dir-listing.css +++ b/assets/css/butter-dir-listing.css @@ -1,9 +1,12 @@ /* Based on the default lighttpd styles, this butters up the UI */ - - body { font-family: "Poppins", sans-serif; + margin: 0; +} + +a { + text-decoration: none; } body>h2 { @@ -21,6 +24,25 @@ div.foot { display: none; } +.breadcrumbs { + display: flex; + align-items: center; + margin: 10px; + height: 34px; + .path-next { + margin: 0 5px; + height: 12px; + } +} + +.crumb { + align-items: center; + color: black; + display: flex; + font-family: "Poppins", sans-serif; + font-size: 14px; +} + h2 { font-size: 18px; font-weight: 500; @@ -33,6 +55,10 @@ hr { margin: 20px 10px; } +hr.full-width { + margin: 0; +} + .container { display: flex; align-items: center; @@ -41,7 +67,6 @@ hr { margin: 10px; box-sizing: border-box; font-family: "Poppins", sans-serif; - text-decoration: none; } .logo-container { diff --git a/assets/images/home.svg b/assets/images/home.svg new file mode 100644 index 0000000..494c316 --- /dev/null +++ b/assets/images/home.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/assets/images/next.svg b/assets/images/next.svg new file mode 100644 index 0000000..c04632d --- /dev/null +++ b/assets/images/next.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/assets/js/butter-dir-listing.js b/assets/js/butter-dir-listing.js index d90823c..819628d 100644 --- a/assets/js/butter-dir-listing.js +++ b/assets/js/butter-dir-listing.js @@ -96,8 +96,39 @@ window.onload = function () { const { files, folders } = extractDirectoryListing(); console.log('Files:', files); console.log('Folders:', folders); + const listDiv = document.querySelector('div.list'); - // insert a new div before div.list + // Header with breadcrumbs + const usbRoot = "/usb-butter/"; + const h2Path = document.querySelector('h2').textContent; + console.log("H2 Path:", h2Path); + const path = h2Path.replace('Index of ', '').replace(usbRoot, ''); + console.log("Path:", path); + + const breadcrumbs = document.createElement("div"); + breadcrumbs.classList.add('breadcrumbs'); + let breadcrumbHTML = ` + home + Explore + `; + pathSteps = path.split('/'); + let pathToHere = usbRoot; + pathSteps.forEach((step, index) => { + pathToHere += step + '/'; + if (step !== "") { + breadcrumbHTML += ` + ${step}`; + } + }); + breadcrumbs.innerHTML = breadcrumbHTML; + listDiv.parentNode.insertBefore(breadcrumbs, listDiv); + + // hr + const fullWithHR = document.createElement('hr'); + fullWithHR.classList.add('full-width'); + listDiv.parentNode.insertBefore(fullWithHR, listDiv); + + // Create a folder listing const folderListing = document.createElement("div"); folderListing.classList.add('folder-list'); folderListing.innerHTML = '

Folders

'; @@ -111,7 +142,6 @@ window.onload = function () { }); // do the insertion - const listDiv = document.querySelector('div.list'); listDiv.parentNode.insertBefore(folderListing, listDiv); if (folders.length > 0 && files.length > 0) { diff --git a/simulated-usb-butter/johns_folder/index.html b/simulated-usb-butter/johns_folder/index.html new file mode 100644 index 0000000..964eb50 --- /dev/null +++ b/simulated-usb-butter/johns_folder/index.html @@ -0,0 +1,225 @@ +--- +layout: empty +--- + + + + + + + + + + Index of /usb-butter/johns_folder/ + + + + + +

Index of /usb-butter/johns_folder/

+
+ + + + + + + + + +
NameLast ModifiedSizeType
../ -  Directory
johns_subfolder1/2024-Apr-30 17:11:52-  Directory
johns_subfolder2/2024-Apr-30 17:11:54-  Directory
lub.zip2024-May-01 15:38:2230.3Mapplication/zip
test.txt2024-Mar-07 14:55:590.0Ktext/plain;charset=utf-8
+
+
lighttpd/1.4.69
+ + + + + \ No newline at end of file