AppImage / AppImage/appimage.github.io

Use client-side JavaScript to get the latest release from GitHub

Offen
#61 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement help wanted
Vorherrschende Sprache
Shell
Sterne
374
Forks
769
Ø Merge
4 T. 10 Std.
Gemergte PRs (30 T.)
8

Beschreibung

AppImageHub is a repository of AppImages available on the net, but we don't want to keep track of each version released. It is a vital part of the AppImage philosophy that there should be no intermediaries between application authors and users, and in the very same second a releases is made available, it should be "there" for download for users. Hence, for AppImages made available on GitHub Releases, we could use the GitHub API on the client side to get the latest AppImage.

Something along the lines of https://stackoverflow.com/questions/24987542/

```

$(document).ready(function () {
GetLatestReleaseInfo();
});

function GetLatestReleaseInfo() {
$.getJSON("https://api.github.com/repos/ShareX/ShareX/releases/latest").done(function (release) {
var asset = release.assets[0];
var downloadCount = 0;
for (var i = 0; i < release.assets.length; i++) {
downloadCount += release.assets[i].download_count;
}
var oneHour = 60 * 60 * 1000;
var oneDay = 24 * oneHour;
var dateDiff = new Date() - new Date(asset.updated_at);
var timeAgo;
if (dateDiff < oneDay)
{
timeAgo = (dateDiff / oneHour).toFixed(1) + " hours ago";
}
else
{
timeAgo = (dateDiff / oneDay).toFixed(1) + " days ago";
}
var releaseInfo = release.name + " was updated " + timeAgo + " and downloaded " + downloadCount.toLocaleString() + " times.";
$(".sharex-download").attr("href", asset.browser_download_url);
$(".release-info").text(releaseInfo);
$(".release-info").fadeIn("slow");
});
}

```

__TODO__: Iterate through all AppImages that may be in the latest release and return the download link for the one matching the architecture the browser is running.

Help from JavaScript wizards highly appreciated.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.