Resolve latest Windows release dynamically
This commit is contained in:
1 parent
37dae3d103
commit
e3cda9c6a6
2 files changed
+97
-3
No files matched your search
+22
-3
@@ -195,9 +195,9 @@
|
|||||||
<h1>Void <span>Bastion</span></h1>
|
<h1>Void <span>Bastion</span></h1>
|
||||||
<p class="lead">Die letzte Verteidigungslinie liegt zwischen dem Reaktor und der Leere. Baue, verbessere und halte deine Stellung gegen immer stärkere Angriffswellen.</p>
|
<p class="lead">Die letzte Verteidigungslinie liegt zwischen dem Reaktor und der Leere. Baue, verbessere und halte deine Stellung gegen immer stärkere Angriffswellen.</p>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<a class="button" href="https://git.dominicspringer.de/Emporex/Void-Bastion-Releases/releases/download/v0.1.0-alpha.2/Void-Bastion-Setup-x64.exe">Windows Alpha herunterladen</a>
|
<a class="button" id="windows-download-hero" href="https://git.dominicspringer.de/Emporex/Void-Bastion-Releases/releases/latest" rel="noopener noreferrer">Windows Alpha herunterladen</a>
|
||||||
<a class="button button-secondary" href="#spiel">Spiel entdecken</a>
|
<a class="button button-secondary" href="#spiel">Spiel entdecken</a>
|
||||||
<span class="status">Alpha 0.1.0 · 64 Bit</span>
|
<span class="status" id="latest-version" aria-live="polite">Aktuelle Windows-Version · 64 Bit</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="platforms" aria-label="Geplante Plattformen"><span>Windows</span><span>Android</span><span>iOS</span></div>
|
<div class="platforms" aria-label="Geplante Plattformen"><span>Windows</span><span>Android</span><span>iOS</span></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -254,7 +254,7 @@
|
|||||||
<img class="dev-icon" src="assets/reactor.webp" alt="Leuchtender Reaktor von Void Bastion">
|
<img class="dev-icon" src="assets/reactor.webp" alt="Leuchtender Reaktor von Void Bastion">
|
||||||
<div><span class="badge">Aktuell in Entwicklung</span><h2>Die Bastion wächst.</h2><p>Void Bastion entsteht bei <strong>GerGames</strong>. Karten, KI-Koop, Endlosmodus, Ranglisten und die technische Grundlage für Online-Multiplayer sind bereits in Arbeit. Veröffentlichungstermine und Store-Links folgen, sobald die spielbare Version bereit ist.</p>
|
<div><span class="badge">Aktuell in Entwicklung</span><h2>Die Bastion wächst.</h2><p>Void Bastion entsteht bei <strong>GerGames</strong>. Karten, KI-Koop, Endlosmodus, Ranglisten und die technische Grundlage für Online-Multiplayer sind bereits in Arbeit. Veröffentlichungstermine und Store-Links folgen, sobald die spielbare Version bereit ist.</p>
|
||||||
<div class="store-grid" aria-label="Geplante Veröffentlichungsplattformen">
|
<div class="store-grid" aria-label="Geplante Veröffentlichungsplattformen">
|
||||||
<a class="store-badge" href="https://git.dominicspringer.de/Emporex/Void-Bastion-Releases/releases/download/v0.1.0-alpha.2/Void-Bastion-Setup-x64.exe"><span class="store-symbol">PC</span><span><b>Windows Alpha</b><small>Setup herunterladen · 111 MiB</small></span></a>
|
<a class="store-badge" id="windows-download-card" href="https://git.dominicspringer.de/Emporex/Void-Bastion-Releases/releases/latest" rel="noopener noreferrer"><span class="store-symbol">PC</span><span><b>Windows Alpha</b><small id="latest-download-size">Aktuelles Setup herunterladen</small></span></a>
|
||||||
<span class="store-badge"><span class="store-symbol">A</span><span><b>Android</b><small>Google Play folgt</small></span></span>
|
<span class="store-badge"><span class="store-symbol">A</span><span><b>Android</b><small>Google Play folgt</small></span></span>
|
||||||
<span class="store-badge"><span class="store-symbol">i</span><span><b>iPhone & iPad</b><small>App Store folgt</small></span></span>
|
<span class="store-badge"><span class="store-symbol">i</span><span><b>iPhone & iPad</b><small>App Store folgt</small></span></span>
|
||||||
</div>
|
</div>
|
||||||
@@ -269,6 +269,25 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
fetch('latest-release.php', { headers: { Accept: 'application/json' }, cache: 'no-cache' })
|
||||||
|
.then((response) => {
|
||||||
|
if (!response.ok) throw new Error('Release-Information nicht verfügbar');
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then((release) => {
|
||||||
|
if (!release.version || !release.windows_url || !release.release_url) return;
|
||||||
|
const heroLink = document.getElementById('windows-download-hero');
|
||||||
|
const cardLink = document.getElementById('windows-download-card');
|
||||||
|
heroLink.href = release.windows_url;
|
||||||
|
cardLink.href = release.windows_url;
|
||||||
|
document.getElementById('latest-version').textContent = `Alpha ${release.version} · 64 Bit`;
|
||||||
|
document.getElementById('latest-download-size').textContent = `Setup herunterladen · ${release.windows_size_mib} MiB`;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
document.getElementById('latest-version').textContent = 'Windows-Testversionen ansehen · 64 Bit';
|
||||||
|
document.getElementById('windows-download-hero').textContent = 'Windows Alpha herunterladen';
|
||||||
|
});
|
||||||
|
|
||||||
const observer = new IntersectionObserver((entries) => {
|
const observer = new IntersectionObserver((entries) => {
|
||||||
entries.forEach((entry) => entry.isIntersecting && entry.target.classList.add('visible'));
|
entries.forEach((entry) => entry.isIntersecting && entry.target.classList.add('visible'));
|
||||||
}, { threshold: 0.14 });
|
}, { threshold: 0.14 });
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
header('X-Content-Type-Options: nosniff');
|
||||||
|
header('Referrer-Policy: no-referrer');
|
||||||
|
|
||||||
|
$apiUrl = 'https://git.dominicspringer.de/api/v1/repos/Emporex/Void-Bastion-Releases/releases';
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
if (function_exists('curl_init')) {
|
||||||
|
$curl = curl_init($apiUrl);
|
||||||
|
curl_setopt_array($curl, [
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_CONNECTTIMEOUT => 4,
|
||||||
|
CURLOPT_TIMEOUT => 8,
|
||||||
|
CURLOPT_USERAGENT => 'GerGames-Void-Bastion-Website/1.0',
|
||||||
|
CURLOPT_HTTPHEADER => ['Accept: application/json'],
|
||||||
|
]);
|
||||||
|
$body = curl_exec($curl);
|
||||||
|
$status = (int) curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
|
||||||
|
curl_close($curl);
|
||||||
|
if (is_string($body) && $status >= 200 && $status < 300) {
|
||||||
|
$response = $body;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$context = stream_context_create(['http' => [
|
||||||
|
'method' => 'GET',
|
||||||
|
'timeout' => 8,
|
||||||
|
'ignore_errors' => true,
|
||||||
|
'header' => "Accept: application/json\r\nUser-Agent: GerGames-Void-Bastion-Website/1.0\r\n",
|
||||||
|
]]);
|
||||||
|
$body = @file_get_contents($apiUrl, false, $context);
|
||||||
|
if (is_string($body)) {
|
||||||
|
$response = $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$releases = is_string($response) ? json_decode($response, true) : null;
|
||||||
|
if (!is_array($releases)) {
|
||||||
|
http_response_code(503);
|
||||||
|
header('Cache-Control: no-store');
|
||||||
|
echo json_encode(['error' => 'Release-Information vorübergehend nicht verfügbar.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($releases as $release) {
|
||||||
|
if (!is_array($release) || !empty($release['draft'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach (($release['assets'] ?? []) as $asset) {
|
||||||
|
if (!is_array($asset) || strtolower((string) ($asset['name'] ?? '')) !== 'void-bastion-setup-x64.exe') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$downloadUrl = (string) ($asset['browser_download_url'] ?? '');
|
||||||
|
$parts = parse_url($downloadUrl);
|
||||||
|
if (($parts['scheme'] ?? '') !== 'https' || strtolower((string) ($parts['host'] ?? '')) !== 'git.dominicspringer.de') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Cache-Control: public, max-age=300, stale-while-revalidate=600');
|
||||||
|
echo json_encode([
|
||||||
|
'version' => ltrim((string) ($release['tag_name'] ?? ''), 'v'),
|
||||||
|
'windows_url' => $downloadUrl,
|
||||||
|
'release_url' => 'https://git.dominicspringer.de/Emporex/Void-Bastion-Releases/releases/tag/' . rawurlencode((string) ($release['tag_name'] ?? '')),
|
||||||
|
'windows_size_mib' => (string) max(1, (int) round(((int) ($asset['size'] ?? 0)) / 1048576)),
|
||||||
|
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
http_response_code(404);
|
||||||
|
header('Cache-Control: no-store');
|
||||||
|
echo json_encode(['error' => 'Es wurde noch kein Windows-Setup veröffentlicht.']);
|
||||||
Reference in new issue
Block a user