From d7abeab8009ab6fbb115f561211dab876cdcd3cb Mon Sep 17 00:00:00 2001 From: Arzumify Date: Tue, 6 Aug 2024 16:16:01 +0100 Subject: [PATCH] Removed the repodata/ subdirectory appearing in the list, added oreon blue package listing, added handling for empty repositories and other HTTP status codes --- assets/js/fetchPackages.js | 54 +++++++++++-------- index.html | 5 ++ oreonproject/oreon-blue/mainstream/index.html | 49 +++++++++++++++++ oreonproject/oreon-blue/security/index.html | 49 +++++++++++++++++ 4 files changed, 136 insertions(+), 21 deletions(-) create mode 100644 oreonproject/oreon-blue/mainstream/index.html create mode 100644 oreonproject/oreon-blue/security/index.html diff --git a/assets/js/fetchPackages.js b/assets/js/fetchPackages.js index c7838ca..1609753 100644 --- a/assets/js/fetchPackages.js +++ b/assets/js/fetchPackages.js @@ -5,28 +5,40 @@ async function fetchPackages(uri) { method: "GET" }) let responseText = await response.text() - console.log('Response:', responseText); - try { - const parsedDocument = new DOMParser().parseFromString(responseText, "text/html"); - const linksNodeList = parsedDocument.querySelectorAll("a"); - statusText.remove() - linksNodeList.forEach((link) => { - const linkText = link.innerHTML.trim(); - const forbiddenLinks = ["Name", "Last modified", "Size", "Description", "Parent Directory"]; - if (!forbiddenLinks.includes(linkText) && !linkText.endsWith(".html")) { - const packageLink = document.createElement("a"); - const newRedirect = uri + "/" + link.href.split("/").pop(); - packageLink.href = newRedirect; - packageLink.innerHTML = linkText; - packageLink.className = "package"; - packageLink.target = "_blank"; - document.getElementById("packages").appendChild(packageLink); - console.log('Original URL:', link.href); - console.log('Modified URL:', newRedirect); + if (response.status === 200) { + console.log('Response:', responseText); + try { + const parsedDocument = new DOMParser().parseFromString(responseText, "text/html"); + const linksNodeList = parsedDocument.querySelectorAll("a"); + linksNodeList.forEach((link) => { + const linkText = link.innerHTML.trim(); + const forbiddenLinks = ["Name", "Last modified", "Size", "Description", "Parent Directory", "repodata/"]; + if (!forbiddenLinks.includes(linkText) && !linkText.endsWith(".html")) { + const packageLink = document.createElement("a"); + const newRedirect = uri + "/" + link.href.split("/").pop(); + packageLink.href = newRedirect; + packageLink.innerHTML = linkText; + packageLink.className = "package"; + packageLink.target = "_blank"; + document.getElementById("packages").appendChild(packageLink); + console.log('Original URL:', link.href); + console.log('Modified URL:', newRedirect); + } + }); + if (document.getElementById("packages").childElementCount === 0) { + statusText.innerHTML = "Nothing here yet!"; + } else { + statusText.remove() } - }); - } catch (e) { - console.error('Parsing error:', e); + } catch (e) { + console.error('Parsing error:', e); + statusText.innerHTML = "Failed to fetch packages. Please try again later."; + } + } else if (response.status === 404) { + console.error('Response:', responseText); + statusText.innerHTML = "Nothing here yet!"; + } else { + console.error('Response:', responseText); statusText.innerHTML = "Failed to fetch packages. Please try again later."; } } diff --git a/index.html b/index.html index e137cbc..b3a21e1 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,11 @@ Mainstream packages Security packages +
+

Oreon blue

+ Mainstream packages + Security not yet available +
diff --git a/oreonproject/oreon-blue/mainstream/index.html b/oreonproject/oreon-blue/mainstream/index.html new file mode 100644 index 0000000..12d31c1 --- /dev/null +++ b/oreonproject/oreon-blue/mainstream/index.html @@ -0,0 +1,49 @@ + + + + + + Document + + + + + + + + + + +
+ +

BCPackage

+ +
+ +
+
+

Oreon blue

+

Mainstream packages

+

+
+
+
+ + + + \ No newline at end of file diff --git a/oreonproject/oreon-blue/security/index.html b/oreonproject/oreon-blue/security/index.html new file mode 100644 index 0000000..5c522c3 --- /dev/null +++ b/oreonproject/oreon-blue/security/index.html @@ -0,0 +1,49 @@ + + + + + + Document + + + + + + + + + + +
+ +

BCPackage

+ +
+ +
+
+

Oreon blue

+

Security packages

+

+
+
+
+ + + + \ No newline at end of file