aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-01-31 20:30:11 +0100
committerGitHub <noreply@github.com>2023-01-31 20:30:11 +0100
commitfe0ada0c733687050a6a16d19d45a3de7790de7d (patch)
treeaeb243f4ce55d20117c5fd4c852da9d72c533a4a
parent9dd72777f685b98951b13020d5bb303549c79161 (diff)
downloadFlightCore-fe0ada0c733687050a6a16d19d45a3de7790de7d.tar.gz
FlightCore-fe0ada0c733687050a6a16d19d45a3de7790de7d.zip
docs: Redirector to up-to-date releases (#151)
* Add GitHub pages download redirector Very simply put, this fetches the current release, and translates search queries like `?appimage` into the download URL for the most recent .AppImage file, then redirects you to it, effectively downloading it. * Update download link to use redirector Now the link doesn't have to be updated every time there's a release!
-rw-r--r--README.md2
-rw-r--r--docs/index.html64
2 files changed, 65 insertions, 1 deletions
diff --git a/README.md b/README.md
index f4f2e7ff..0bd93816 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
<img src="docs/assets/Square310x310Logo.png" width="200px">
<br>
<br>
- <a href="https://github.com/R2NorthstarTools/FlightCore/releases/download/v1.6.0/FlightCore_1.6.0_x64_en-US.msi"><img src="docs/assets/downloadbutton.png" width="300px"></a>
+ <a href="https://r2northstartools.github.io/FlightCore/index.html?win-setup"><img src="docs/assets/downloadbutton.png" width="300px"></a>
<br>
</p>
diff --git a/docs/index.html b/docs/index.html
new file mode 100644
index 00000000..737e5ea5
--- /dev/null
+++ b/docs/index.html
@@ -0,0 +1,64 @@
+<script>
+// with this we can very easily fetch the latest version of FlightCore
+// and redirect to it, without having to update any version numbers on
+// every release, simply change the search query to either "win-setup"
+// or "appimage", without a query you will be redirect to the release
+// page instead of the download
+//
+// so generally a request would look like this:
+//
+// r2northstartools.github.io/FlightCore/index.html?win-setup
+//
+// or
+//
+// r2northstartools.github.io/FlightCore/index.html?appimage
+//
+// and to redirect to the release page:
+//
+// r2northstartools.github.io/FlightCore/index.html
+
+(async () => {
+ // configuration of repo URL
+ let repo = "FlightCore";
+ let author = "R2NorthstarTools";
+ let api = "https://api.github.com/repos";
+
+ // actual API request
+ let release = await (await fetch(`${api}/${author}/${repo}/releases/latest`)).json();
+ let assets = release.assets;
+
+ // this takes in a regEx and if something matches in the release's
+ // files, it'll return the download link to it
+ let get = (asset) => {
+ for (let i in assets) {
+ if (assets[i].name.match(asset)) {
+ return assets[i].browser_download_url;
+ }
+ }
+ }
+
+ let url;
+
+ // this refers to the actual search query, i.e "<page>?appimage"
+ let search = location.search.replace(/^\?/, "");
+ switch(search) {
+ case "win-zip": // FlightCore_<version>_x64_en-US.zip
+ url = get(/FlightCore_.*\.zip$/);
+ break;
+ case "win-setup": // FlightCore_<version>_x64_en-US.msi
+ url = get(/FlightCore_.*\.msi$/);
+ break;
+
+ case "appimage": // flight-core_<version>_amd64.AppImage
+ url = get(/flight-core_.*\.AppImage$/);
+ break;
+
+ default: // default to release page
+ url = release.html_url;
+ break;
+ }
+
+ // redirect to page
+ location.replace(url);
+})()
+</script>