Skip to content

Commit

Permalink
A lot of work in one commit, Adapted with the new dark mode, Some cod…
Browse files Browse the repository at this point in the history
…e formatting too, Used <svg> from a recommendation
  • Loading branch information
UltimatChamp committed Oct 10, 2023
1 parent f614229 commit 80dce55
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 70 deletions.
3 changes: 3 additions & 0 deletions assets/img/content/installer_icons/CREDITS.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A big thanks to [**IconFinder**](https://www.iconfinder.com/) for providing _[these images](https://github.com/neoforged/websites/tree/main/assets/img/content/links)_ for free, under the **_[CC0 1.0 Universal (CC0 1.0) Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/) License_**!

##### Make sure to check their website to download free stock images.
1 change: 1 addition & 0 deletions assets/img/content/installer_icons/changelog.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/content/installer_icons/history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/content/installer_icons/installer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 70 additions & 29 deletions assets/js/neoforge.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,77 @@
const VERSIONS_ENDPOINT = 'https://maven.neoforged.net/api/maven/versions/releases/'
const FORGE_GAV = 'net/neoforged/forge'
const LATEST_ENDPOINT = 'https://maven.neoforged.net/api/maven/latest/version/releases/'
const DOWNLOAD_URL = 'https://maven.neoforged.net/net/neoforged/forge'
const VERSIONS_ENDPOINT =
"https://maven.neoforged.net/api/maven/versions/releases/";
const FORGE_GAV = "net/neoforged/forge";
const LATEST_ENDPOINT =
"https://maven.neoforged.net/api/maven/latest/version/releases/";
const DOWNLOAD_URL = "https://maven.neoforged.net/net/neoforged/forge";
//https://maven.neoforged.net/api/maven/latest/version/releases/net%2Fneoforged%2Fforge?filter=1.20.1
async function loadLatestVersions(minecraftVersions) {
for (const mcVersion of minecraftVersions) {
let currentMcVersionUrl = new URL(LATEST_ENDPOINT + encodeURIComponent(FORGE_GAV) + '?filter=' + encodeURIComponent(mcVersion));
let versionJson;
for (const mcVersion of minecraftVersions) {
let currentMcVersionUrl = new URL(
LATEST_ENDPOINT +
encodeURIComponent(FORGE_GAV) +
"?filter=" +
encodeURIComponent(mcVersion)
);
let versionJson;

try {
const response = await fetch(currentMcVersionUrl);
versionJson = await response.json();
} catch (error) {
if (error instanceof SyntaxError) {
console.log('There was a SyntaxError parsing the JSON response from the maven server.', error);
} else {
console.log('There was an error processing the request for a new version.', error);
}
}
try {
const response = await fetch(currentMcVersionUrl);
versionJson = await response.json();
} catch (error) {
if (error instanceof SyntaxError) {
console.log(
"There was a SyntaxError parsing the JSON response from the maven server.",
error
);
} else {
console.log(
"There was an error processing the request for a new version.",
error
);
}
}

if (versionJson) {
const { version } = versionJson;

if (versionJson) {
const {version} = versionJson;

const installerUrl = `${DOWNLOAD_URL}/${encodeURIComponent(version)}/forge-${encodeURIComponent(version)}-installer.jar`;
const changelogUrl = `${DOWNLOAD_URL}/${encodeURIComponent(version)}/forge-${encodeURIComponent(version)}-changelog.txt`;
document.querySelector("#filelist").innerHTML = `
<div class="fileinfo__header">NeoForge ${version}</div>
<div class="fileinfo__body">
<a href="${installerUrl}"><span>Latest <em>NeoForge</em> Installer</span><span>neoforge-${version}-installer.jar</span></a>
<a href="${changelogUrl}"><span>Latest Changelog</span><span>${version}</span></a>
</div>
const installerUrl = `${DOWNLOAD_URL}/${encodeURIComponent(
version
)}/forge-${encodeURIComponent(version)}-installer.jar`;
const changelogUrl = `${DOWNLOAD_URL}/${encodeURIComponent(
version
)}/forge-${encodeURIComponent(version)}-changelog.txt`;
document.querySelector("#filelist").innerHTML = `
<div class="fileinfo">
<div class="fileinfo__header">
<i aria-hidden="true"></i><b>Download (Latest)</b><br />
<small></small><br />
</div>
<div class="fileinfo__body">
<div class="link link-boosted">
<a href="${installerUrl}" title="Installer..."
><svg class="installer_icon" height="128px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" xml:space="preserve"><path d="M35 2H17a1 1 0 0 0-.707.293l-8 8A1 1 0 0 0 8 11v30c0 2.757 2.243 5 5 5h22c2.757 0 5-2.243 5-5V7c0-2.757-2.243-5-5-5zm3 39c0 1.654-1.346 3-3 3H13c-1.654 0-3-1.346-3-3V11.414L17.414 4H35c1.654 0 3 1.346 3 3v34zM17 14h-5a1 1 0 1 1 0-2h5c.551 0 1-.448 1-1V6a1 1 0 1 1 2 0v5c0 1.654-1.346 3-3 3zm7 3c-4.962 0-9 4.037-9 9s4.038 9 9 9 9-4.037 9-9-4.038-9-9-9zm0 16c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7zm3.707-6.707a1 1 0 0 1 0 1.414l-3 3a.997.997 0 0 1-1.414 0l-3-3a1 1 0 1 1 1.414-1.414L23 27.586V22a1 1 0 1 1 2 0v5.586l1.293-1.293a1 1 0 0 1 1.414 0z" fill="#26303d" class="fill-000000"></path></svg>
<br /><span>Latest <em>NeoForge</em> Installer</span>
<p id="file-name">(neo)forge--installer.jar</p></a
>
</div>
<div class="link">
<a href="${changelogUrl}" title="Changelog..."
><svg class="changelog_icon" height="64px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" xml:space="preserve"><path d="M35 2H17a1 1 0 0 0-.707.293l-8 8A1 1 0 0 0 8 11v30c0 2.757 2.243 5 5 5h22c2.757 0 5-2.243 5-5V7c0-2.757-2.243-5-5-5zm-7 2h4v13.936l-1.13-1.547a1.001 1.001 0 0 0-.798-.41c-.285.019-.614.144-.805.394L28 18.037V4zm10 37c0 1.654-1.346 3-3 3H13c-1.654 0-3-1.346-3-3V11.414L17.414 4H26v17a1 1 0 0 0 1.796.606l2.25-2.955 2.146 2.939A1.002 1.002 0 0 0 34 21V4h1c1.654 0 3 1.346 3 3v34zM20 6v5c0 1.654-1.346 3-3 3h-5a1 1 0 0 1 0-2h5c.551 0 1-.449 1-1V6a1 1 0 0 1 2 0z" fill="#26303d" class="fill-000000"></path></svg>
<br /><span>Latest Changelog</span><br /><span></span
></a>
</div>
<div class="link">
<a
href="https://maven.neoforged.net/#/releases/net/neoforged/forge"
title="Older Versions..."
><svg class="history_icon" height="64px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2Zm0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1Z" fill="#26303d" class="fill-6563ff"></path></svg>
<br /><span>Older Versions -></span></a
>
</div>
</div>
</div>
`;
}
}
}
}
77 changes: 68 additions & 9 deletions layouts/shortcodes/files.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,75 @@
{{ $js:= resources.Get "js/neoforge.js" }}
<script src="{{ $js.RelPermalink }}"></script>
<div id="filelist" class="fileinfo">
<div class="fileinfo__header">NeoForge (loading version...)</div>
<div id="filelist">
<div class="fileinfo">
<div class="fileinfo__header">
<i aria-hidden="true"></i><b>Download (Latest)</b><br />
<small></small><br />
</div>
<div class="fileinfo__body">
<a><span>Latest <em>NeoForge</em> Installer</span><span class="fileinfo__placeholder">neoforge-0.00.00-00.00.00-installer.jar</span></a>
<a><span>Latest Changelog</span><span class="fileinfo__placeholder">0.00.00-00.00.00</span></a>
<div class="link link-boosted">
<a href="${installerUrl}" title="Installer..."
><svg
class="installer_icon"
height="128px"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 48 48"
xml:space="preserve"
>
<path
d="M35 2H17a1 1 0 0 0-.707.293l-8 8A1 1 0 0 0 8 11v30c0 2.757 2.243 5 5 5h22c2.757 0 5-2.243 5-5V7c0-2.757-2.243-5-5-5zm3 39c0 1.654-1.346 3-3 3H13c-1.654 0-3-1.346-3-3V11.414L17.414 4H35c1.654 0 3 1.346 3 3v34zM17 14h-5a1 1 0 1 1 0-2h5c.551 0 1-.448 1-1V6a1 1 0 1 1 2 0v5c0 1.654-1.346 3-3 3zm7 3c-4.962 0-9 4.037-9 9s4.038 9 9 9 9-4.037 9-9-4.038-9-9-9zm0 16c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7zm3.707-6.707a1 1 0 0 1 0 1.414l-3 3a.997.997 0 0 1-1.414 0l-3-3a1 1 0 1 1 1.414-1.414L23 27.586V22a1 1 0 1 1 2 0v5.586l1.293-1.293a1 1 0 0 1 1.414 0z"
fill="#26303d"
class="fill-000000"
></path>
</svg>
<br /><span>Latest <em>NeoForge</em> Installer</span>
<p id="file-name">(neo)forge--installer.jar</p></a
>
</div>
<div class="link">
<a href="${changelogUrl}" title="Changelog..."
><svg
class="changelog_icon"
height="64px"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 48 48"
xml:space="preserve"
>
<path
d="M35 2H17a1 1 0 0 0-.707.293l-8 8A1 1 0 0 0 8 11v30c0 2.757 2.243 5 5 5h22c2.757 0 5-2.243 5-5V7c0-2.757-2.243-5-5-5zm-7 2h4v13.936l-1.13-1.547a1.001 1.001 0 0 0-.798-.41c-.285.019-.614.144-.805.394L28 18.037V4zm10 37c0 1.654-1.346 3-3 3H13c-1.654 0-3-1.346-3-3V11.414L17.414 4H26v17a1 1 0 0 0 1.796.606l2.25-2.955 2.146 2.939A1.002 1.002 0 0 0 34 21V4h1c1.654 0 3 1.346 3 3v34zM20 6v5c0 1.654-1.346 3-3 3h-5a1 1 0 0 1 0-2h5c.551 0 1-.449 1-1V6a1 1 0 0 1 2 0z"
fill="#26303d"
class="fill-000000"
></path>
</svg>
<br /><span>Latest Changelog</span><br /><span></span
></a>
</div>
<div class="link">
<a
href="https://maven.neoforged.net/#/releases/net/neoforged/forge"
title="Older Versions..."
><svg
class="history_icon"
height="64px"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2Zm0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1Z"
fill="#26303d"
class="fill-6563ff"
></path>
</svg>
<br /><span>Older Versions -></span></a
>
</div>
</div>
</div>
</div>
<script>
document.addEventListener("readystatechange", evt=>{
if (evt.target.readyState === "complete") {
loadLatestVersions([{{ .Get 0 }}]);
}
});
document.addEventListener("readystatechange", evt=>{
if (evt.target.readyState === "complete") {
loadLatestVersions([{{ .Get 0 }}]);
}
});
</script>
63 changes: 31 additions & 32 deletions themes/mainroad/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1052,48 +1052,47 @@ textarea {
display: inline-block;
}

/* Installer */
.fileinfo {
color: white;
padding: 0;
text-decoration: none;
transition: background 0.2s ease-in-out;
text-align: center;
margin: 0 0 20px;
margin: 0 0 1.25rem;
font-size: 1.5rem;
line-height: 1.4;
border-color: var(--color-border);
}

.fileinfo .fileinfo__header {
padding: 10px 15px;
padding: .625rem .9375rem;
font-size: 16px;
font-size: 1rem;
font-weight: 700;
.fileinfo__header {
background-color: var(--color-download);
padding: 10px;
line-height: 1.2rem;
}

.fileinfo .fileinfo__body {
padding: 0px;
font-size: 16px;
font-size: 1rem;
font-weight: 700;
display: flex;
justify-content: center;
align-items: stretch;
gap: 10px;
gap: .625rem;
.fileinfo__body {
background-color: var(--color-box);
position: relative;
border-radius: 0 0 3px 3px;
border-top: 1px solid var(--color-border);
margin: 0;
display: grid;
grid-gap: 1px;
grid-auto-flow: column;
grid-template-rows: 1fr 1fr;
grid-auto-columns: 1fr;
}

.fileinfo .fileinfo__body a {
padding: 10px;
padding: .625rem;
align-items: center;
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: center;
flex: 1 1 0px;
text-decoration: none;
.link-boosted {
grid-column-end: span 2;
grid-row-end: span 2;
}

.fileinfo__placeholder {
visibility: hidden;
.link:hover {
background-color: var(--color-download-highlight);
}

/* News */
.news {
margin-top: 1rem;
}
Expand Down Expand Up @@ -1294,7 +1293,7 @@ textarea {
--color-highlight: #d7742f;
--color-background: #d5e0df;
--color-download: #e68c37;
--color-download-highlight: #e5b04c;
--color-download-highlight: #a9aeb1;
--color-box: #bdc7c7;
--color-outer: #bdc7c7;
--color-border: #aab0b3;
Expand All @@ -1314,7 +1313,7 @@ textarea {
--color-highlight: #d7742f;
--color-background: #323232;
--color-download: #d7742f;
--color-download-highlight: #e68c37;
--color-download-highlight: #a9aeb1;
--color-box: #222222;
--color-outer: #111111;
--color-border: #5a5a5a;
Expand Down

1 comment on commit 80dce55

@neoforged-pages-deployments
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying with Cloudflare Pages

Name Result
Last commit: 80dce557d286097766d198504983da957aa1511c
Status: ✅ Deploy successful!
Preview URL: https://b47b2c0e.neoforged-website-previews.pages.dev
PR Preview URL: https://pr-7.neoforged-website-previews.pages.dev

Please sign in to comment.