Implement OS detection and dynamic download link for latest app release
Some checks failed
Deploy HTML to Docker LXC / deploy (push) Failing after 17s
Some checks failed
Deploy HTML to Docker LXC / deploy (push) Failing after 17s
This commit is contained in:
56
index.html
56
index.html
@@ -358,7 +358,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<a href="#features" class="btn btn-secondary" style="border:none;">Features</a>
|
||||
<a href="#pricing" class="btn btn-primary" style="padding: 0.5rem 1rem; font-size: 0.875rem;">Scarica App</a>
|
||||
<a href="#" onclick="downloadLatest(event)" class="btn btn-primary" style="padding: 0.5rem 1rem; font-size: 0.875rem;">Scarica App</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -372,7 +372,7 @@
|
||||
<p>Piattaforma multi-agente in cui tu scegli dove salvare i dati e quale AI utilizzare. Crea workflow automatici in linguaggio naturale.</p>
|
||||
|
||||
<div class="hero-buttons">
|
||||
<a href="#" class="btn btn-primary">Scarica per Windows/Mac</a>
|
||||
<a href="#" onclick="downloadLatest(event)" id="hero-download" class="btn btn-primary">Scarica per Windows/Linux</a>
|
||||
<a href="#features" class="btn btn-secondary">Scopri l'architettura</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -584,6 +584,58 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- Auto-detect OS & download latest release ---
|
||||
const RELEASE_API = 'https://git.muticolturano.com/api/v1/repos/roberto/adiuva/releases/latest';
|
||||
const RELEASES_PAGE = 'https://git.muticolturano.com/roberto/adiuva/releases';
|
||||
|
||||
function detectOS() {
|
||||
const ua = navigator.userAgent || navigator.platform || '';
|
||||
if (/Win/i.test(ua)) return 'windows';
|
||||
if (/Linux/i.test(ua)) {
|
||||
// Heuristic: most desktop Linux users on Debian/Ubuntu
|
||||
return 'linux';
|
||||
}
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
// Update hero button label based on OS
|
||||
(function updateLabel() {
|
||||
const os = detectOS();
|
||||
const heroBtn = document.getElementById('hero-download');
|
||||
if (heroBtn) {
|
||||
if (os === 'windows') heroBtn.textContent = 'Scarica per Windows (.exe)';
|
||||
else if (os === 'linux') heroBtn.textContent = 'Scarica per Linux (.deb)';
|
||||
}
|
||||
})();
|
||||
|
||||
async function downloadLatest(e) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const res = await fetch(RELEASE_API);
|
||||
if (!res.ok) throw new Error('API error');
|
||||
const release = await res.json();
|
||||
const assets = release.assets || [];
|
||||
const os = detectOS();
|
||||
|
||||
let asset;
|
||||
if (os === 'windows') {
|
||||
asset = assets.find(a => a.name.endsWith('.exe'));
|
||||
} else if (os === 'linux') {
|
||||
asset = assets.find(a => a.name.endsWith('.deb')) ||
|
||||
assets.find(a => a.name.endsWith('.rpm'));
|
||||
}
|
||||
|
||||
if (asset && asset.browser_download_url) {
|
||||
window.location.href = asset.browser_download_url;
|
||||
} else {
|
||||
// Fallback: send to releases page
|
||||
window.location.href = RELEASES_PAGE;
|
||||
}
|
||||
} catch {
|
||||
window.location.href = RELEASES_PAGE;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user