From 80dce557d286097766d198504983da957aa1511c Mon Sep 17 00:00:00 2001 From: UltimatChamp <140878474+UltimatChamp@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:55:50 +0530 Subject: [PATCH] A lot of work in one commit, Adapted with the new dark mode, Some code formatting too, Used from a recommendation --- assets/img/content/installer_icons/CREDITS.MD | 3 + .../img/content/installer_icons/changelog.svg | 1 + .../img/content/installer_icons/history.svg | 1 + .../img/content/installer_icons/installer.svg | 1 + assets/js/neoforge.js | 99 +++++++++++++------ layouts/shortcodes/files.html | 77 +++++++++++++-- themes/mainroad/assets/css/style.css | 63 ++++++------ 7 files changed, 175 insertions(+), 70 deletions(-) create mode 100644 assets/img/content/installer_icons/CREDITS.MD create mode 100644 assets/img/content/installer_icons/changelog.svg create mode 100644 assets/img/content/installer_icons/history.svg create mode 100644 assets/img/content/installer_icons/installer.svg diff --git a/assets/img/content/installer_icons/CREDITS.MD b/assets/img/content/installer_icons/CREDITS.MD new file mode 100644 index 0000000..66aebf1 --- /dev/null +++ b/assets/img/content/installer_icons/CREDITS.MD @@ -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. diff --git a/assets/img/content/installer_icons/changelog.svg b/assets/img/content/installer_icons/changelog.svg new file mode 100644 index 0000000..e4eb4a9 --- /dev/null +++ b/assets/img/content/installer_icons/changelog.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/img/content/installer_icons/history.svg b/assets/img/content/installer_icons/history.svg new file mode 100644 index 0000000..c37dd72 --- /dev/null +++ b/assets/img/content/installer_icons/history.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/img/content/installer_icons/installer.svg b/assets/img/content/installer_icons/installer.svg new file mode 100644 index 0000000..258708d --- /dev/null +++ b/assets/img/content/installer_icons/installer.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/js/neoforge.js b/assets/js/neoforge.js index fbd7ae9..f41339c 100644 --- a/assets/js/neoforge.js +++ b/assets/js/neoforge.js @@ -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 = ` -
NeoForge ${version}
-
- Latest NeoForge Installerneoforge-${version}-installer.jar - Latest Changelog${version} -
+ 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 = ` +
+
+ Download (Latest)
+
+
+
+ + + +
+
`; - } } + } } diff --git a/layouts/shortcodes/files.html b/layouts/shortcodes/files.html index f2692a7..5663fb9 100644 --- a/layouts/shortcodes/files.html +++ b/layouts/shortcodes/files.html @@ -1,16 +1,75 @@ {{ $js:= resources.Get "js/neoforge.js" }} -
-
NeoForge (loading version...)
+
+
diff --git a/themes/mainroad/assets/css/style.css b/themes/mainroad/assets/css/style.css index 56b11b9..7021bd8 100644 --- a/themes/mainroad/assets/css/style.css +++ b/themes/mainroad/assets/css/style.css @@ -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; } @@ -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; @@ -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;