Removed the repodata/ subdirectory appearing in the list, added oreon blue package listing, added handling for empty repositories and other HTTP status codes
This commit is contained in:
parent
781aaafcf1
commit
d7abeab800
4 changed files with 136 additions and 21 deletions
|
@ -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.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,11 @@
|
|||
<a class="edit-btn" target="_blank" href="oreonproject/oreon-lime/mainstream">Mainstream packages</a>
|
||||
<a class="edit-btn" target="_blank" href="oreonproject/oreon-lime/security">Security packages</a>
|
||||
</div>
|
||||
<div class="edition">
|
||||
<h2>Oreon blue</h2>
|
||||
<a class="edit-btn" target="_blank" href="oreonproject/oreon-blue/mainstream">Mainstream packages</a>
|
||||
<a class="edit-btn" target="_blank" href="#">Security not yet available</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
49
oreonproject/oreon-blue/mainstream/index.html
Normal file
49
oreonproject/oreon-blue/mainstream/index.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="../../../assets/css/style.css">
|
||||
<!-- Fonts -->
|
||||
<link rel="stylesheet" href="../../../assets/fonts/montserrat.css">
|
||||
<!-- JS -->
|
||||
<script src="../../../assets/js/fetchPackages.js"></script>
|
||||
<!-- font awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
|
||||
</head>
|
||||
<body>
|
||||
<header class="hdr">
|
||||
<div class="dropdown">
|
||||
<button class="dropButton"><i class="fa-solid fa-caret-down"></i></button>
|
||||
<div class="dropdown-content">
|
||||
<a href="https://oreonproject.org">Oreon</a>
|
||||
<a href="https://oreonproject.org/help">Help</a>
|
||||
<a href="https://forums.oreonproject.org/">Forum</a>
|
||||
</div>
|
||||
</div>
|
||||
<h2>BCPackage</h2>
|
||||
<nav>
|
||||
<a href="https://oreonproject.org">Oreon</a>
|
||||
<a href="https://oreonproject.org/help">Help</a>
|
||||
<a href="https://forums.oreonproject.org/">Forum</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="main">
|
||||
<div style="text-align: center;">
|
||||
<h1>Oreon blue</h1>
|
||||
<h2>Mainstream packages</h2>
|
||||
<p id="statusText"></p>
|
||||
<div id="packages" class="packages"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
fetchPackages("https://packages.boostyconnect.com/oreon-9/mainstream/")
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
49
oreonproject/oreon-blue/security/index.html
Normal file
49
oreonproject/oreon-blue/security/index.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="../../../assets/css/style.css">
|
||||
<!-- Fonts -->
|
||||
<link rel="stylesheet" href="../../../assets/fonts/montserrat.css">
|
||||
<!-- JS -->
|
||||
<script src="../../../assets/js/fetchPackages.js"></script>
|
||||
<!-- font awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
|
||||
</head>
|
||||
<body>
|
||||
<header class="hdr">
|
||||
<div class="dropdown">
|
||||
<button class="dropButton"><i class="fa-solid fa-caret-down"></i></button>
|
||||
<div class="dropdown-content">
|
||||
<a href="https://oreonproject.org">Oreon</a>
|
||||
<a href="https://oreonproject.org/help">Help</a>
|
||||
<a href="https://forums.oreonproject.org/">Forum</a>
|
||||
</div>
|
||||
</div>
|
||||
<h2>BCPackage</h2>
|
||||
<nav>
|
||||
<a href="https://oreonproject.org">Oreon</a>
|
||||
<a href="https://oreonproject.org/help">Help</a>
|
||||
<a href="https://forums.oreonproject.org/">Forum</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="main">
|
||||
<div style="text-align: center;">
|
||||
<h1>Oreon blue</h1>
|
||||
<h2>Security packages</h2>
|
||||
<p id="statusText"></p>
|
||||
<div id="packages" class="packages"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
fetchPackages("https://packages.boostyconnect.com/oreon-9/security/")
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue