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"
|
method: "GET"
|
||||||
})
|
})
|
||||||
let responseText = await response.text()
|
let responseText = await response.text()
|
||||||
console.log('Response:', responseText);
|
if (response.status === 200) {
|
||||||
try {
|
console.log('Response:', responseText);
|
||||||
const parsedDocument = new DOMParser().parseFromString(responseText, "text/html");
|
try {
|
||||||
const linksNodeList = parsedDocument.querySelectorAll("a");
|
const parsedDocument = new DOMParser().parseFromString(responseText, "text/html");
|
||||||
statusText.remove()
|
const linksNodeList = parsedDocument.querySelectorAll("a");
|
||||||
linksNodeList.forEach((link) => {
|
linksNodeList.forEach((link) => {
|
||||||
const linkText = link.innerHTML.trim();
|
const linkText = link.innerHTML.trim();
|
||||||
const forbiddenLinks = ["Name", "Last modified", "Size", "Description", "Parent Directory"];
|
const forbiddenLinks = ["Name", "Last modified", "Size", "Description", "Parent Directory", "repodata/"];
|
||||||
if (!forbiddenLinks.includes(linkText) && !linkText.endsWith(".html")) {
|
if (!forbiddenLinks.includes(linkText) && !linkText.endsWith(".html")) {
|
||||||
const packageLink = document.createElement("a");
|
const packageLink = document.createElement("a");
|
||||||
const newRedirect = uri + "/" + link.href.split("/").pop();
|
const newRedirect = uri + "/" + link.href.split("/").pop();
|
||||||
packageLink.href = newRedirect;
|
packageLink.href = newRedirect;
|
||||||
packageLink.innerHTML = linkText;
|
packageLink.innerHTML = linkText;
|
||||||
packageLink.className = "package";
|
packageLink.className = "package";
|
||||||
packageLink.target = "_blank";
|
packageLink.target = "_blank";
|
||||||
document.getElementById("packages").appendChild(packageLink);
|
document.getElementById("packages").appendChild(packageLink);
|
||||||
console.log('Original URL:', link.href);
|
console.log('Original URL:', link.href);
|
||||||
console.log('Modified URL:', newRedirect);
|
console.log('Modified URL:', newRedirect);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (document.getElementById("packages").childElementCount === 0) {
|
||||||
|
statusText.innerHTML = "Nothing here yet!";
|
||||||
|
} else {
|
||||||
|
statusText.remove()
|
||||||
}
|
}
|
||||||
});
|
} catch (e) {
|
||||||
} catch (e) {
|
console.error('Parsing error:', 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.";
|
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/mainstream">Mainstream packages</a>
|
||||||
<a class="edit-btn" target="_blank" href="oreonproject/oreon-lime/security">Security packages</a>
|
<a class="edit-btn" target="_blank" href="oreonproject/oreon-lime/security">Security packages</a>
|
||||||
</div>
|
</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>
|
</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