Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download page - Add download suggestion page for Lime3DS releases #27

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions pages/download/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<head>
<script src="/resources/scripts/htmlimporter.js"></script>
<script>
HTMLImporter.import("/resources/templates/generic-head.html");
</script>
<link rel="stylesheet" href="/resources/stylesheets/download.css" />
</head>

<body>
<script>HTMLImporter.import("/resources/templates/generic-nav.html");</script>

<div id="content">
<h1>Latest Lime3DS Downloads</h1>
<div id="release" class="release"></div>
<div class="navigation">
<button id="prev" onclick="navigate(-1)" disabled>Next</button>
<button id="next" onclick="navigate(1)" disabled>Previous</button>
</div>

<script>HTMLImporter.import("/resources/templates/generic-footer.html");</script>
</div>

<script>
let releases = [];
let currentIndex = 0;
document.addEventListener('DOMContentLoaded', () => {
fetchReleases();
});
async function fetchReleases() {
try {
const response = await fetch("https://api.github.com/repos/Lime3DS/Lime3DS/releases");
releases = await response.json();
if (releases.length) {
showRelease(currentIndex);
updateNavigationButtons();
}
} catch (error) {
console.error("Error fetching releases:", error);
}
}

function showRelease(index) {
const releaseDiv = document.getElementById("release");
const release = releases[index];
const classMap = {
windows: "windows",
linux: "linux",
mac: "mac",
android: "android"
};

const assetList = release.assets
.map(asset => {
const className = Object.keys(classMap).find(key => asset.name.includes(key));
return className ? `<li><a href="${asset.browser_download_url}" class="button ${classMap[className]}">${asset.name}</a></li>` : '';
})
.join("");

releaseDiv.innerHTML = `
<h4>Download:</h4>
SrShadowy marked this conversation as resolved.
Show resolved Hide resolved
<ul>
${assetList}
<li>
<a href="https://flathub.org/apps/io.github.lime3ds.Lime3DS" rel="nofollow">
<img width="180" alt="Download on Flathub" src="https://camo.githubusercontent.com/5e88d7b1628407d9c67f8d85ab66e676a61f6c7e0f6d6c35418bbe0ef13d8ec0/68747470733a2f2f646c2e666c61746875622e6f72672f6173736574732f6261646765732f666c61746875622d62616467652d656e2e706e67" data-canonical-src="https://dl.flathub.org/assets/badges/flathub-badge-en.png" style="max-width: 100%;">
</a>
</li>
</ul>
<h2>Changelog:</h2>
<h3>${release.name}</h3>
<div>
${marked(release.body || "No release notes available.")}
</div>
SrShadowy marked this conversation as resolved.
Show resolved Hide resolved
`;
}

function navigate(direction) {
currentIndex = Math.min(Math.max(0, currentIndex + direction), releases.length - 1);
showRelease(currentIndex);
updateNavigationButtons();
}

function updateNavigationButtons() {
document.getElementById('prev').disabled = currentIndex === 0;
document.getElementById('next').disabled = currentIndex === releases.length - 1;
}
</script>

<script async src="https://cdnjs.cloudflare.com/ajax/libs/marked/1.1.1/marked.min.js"></script>
</body>

</html>
51 changes: 51 additions & 0 deletions resources/stylesheets/download.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.button {
display: inline-block;
padding: 15px 30px;
margin: 10px;
border-radius: 5px;
color: white;
text-decoration: none;
font-size: 16px;
transition: background-color 0.3s;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.windows {
background-color: #0078D7;
}

.linux {
background-color: #FCC624;
color: #333;
}

.mac {
background-color: #A4C8E1;
}

.android {
background-color: #A4C639;
}
SrShadowy marked this conversation as resolved.
Show resolved Hide resolved

.button:hover {
filter: brightness(90%);
}

.navigation {
margin-top: 20px;
}

#release {
margin-top: 30px;
}

button {
padding: 10px 20px;
font-size: 14px;
cursor: pointer;
}

button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
2 changes: 1 addition & 1 deletion resources/templates/generic-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</span>

<div id="link_tray">
<a href="https://github.com/Lime3DS/Lime3DS/releases">Releases</a> |
<a href="/pages/download">Download</a> |
<a href="https://github.com/Lime3DS/Lime3DS">GitHub</a> |
<span class="desktop-only">
<a href="https://lime3ds.github.io/pages/compatibility">Compatibility</a> |
Expand Down