diff --git a/src/routes/download/+page.js b/src/routes/download/+page.js new file mode 100644 index 00000000..e0fc5339 --- /dev/null +++ b/src/routes/download/+page.js @@ -0,0 +1,17 @@ +const visit = `visit our releases page on GitHub.` + +const content = { + props: { + title: "Download Spyder", + subtitle: `If the download does not start automatically, please click the button below`, + alternative: `To download Spyder for the detected OS, please click the button below`, + download: { + title: "Download Started...", + alternative: `Alternatively, you can manually select the package you want from the buttons below, or ${visit}` + }, + } +} + +export function load() { + return content +} diff --git a/src/routes/download/+page.svelte b/src/routes/download/+page.svelte index ced1bc48..fb0d0f2f 100644 --- a/src/routes/download/+page.svelte +++ b/src/routes/download/+page.svelte @@ -4,6 +4,7 @@ import { releases } from "$lib/config"; import { page } from "$app/stores"; import { metadata } from "$lib/store"; + import { getOS } from "$lib/utils"; import Loader from "$lib/components/Loader.svelte"; import Button from "$lib/components/Button.svelte"; @@ -26,12 +27,16 @@ url: $page.url.href, }); + let result; let arch = "unknown"; let os = "unknown"; let osName = "unknown"; + let macs = Object.entries(releases.mac); let downloadUrl = ""; let osButtons = []; + console.log(macs); + // Generate download buttons even if we don't have // a download parameter in the URL let generateDownloadButtons = (releases) => { @@ -72,21 +77,23 @@ return; } - const result = getOSfromURL(); + result = getOSfromURL(); if (!result) { - return; + // Detect OS and architecture if not provided in the URL + os = getOS(); + arch = "x64"; + } else { + os = result.os; + arch = result.arch; } - os = result.os; - arch = result.arch; - - if (releases[os][arch]) { + if (os !== "mac" && releases[os][arch]) { osName = releases[os][arch].name; downloadUrl = releases[os][arch].link; } - if (downloadUrl) { + if (downloadUrl && result) { window.location = downloadUrl; } }; @@ -98,48 +105,67 @@ getOSValues(); osButtons = generateDownloadButtons(releases); }); - - + export let data; + $: pageTitle = data.props.title; + $: pageSubtitle = data.props.subtitle; + $: pageSubtitleAlt = data.props.alternative; + $: download = data.props.download; + -
- {#if os === "unknown"} -

- Please select the package you want from the links below -

-

- Or visit our releases page on GitHub. -

- {:else if os !== "unknown"} -

- Download started… + + +
+ {#if os !== "unknown"} +

+ {@html result ? download.title : pageTitle}

-

- Selected {osName} - or compatible +

+ {osName} detected

-

- If the download does not start automatically, please click the button - below +

+ {@html result ? pageSubtitle : pageSubtitleAlt}

-
-
-

- Alternatively, you can manually select the package you want from the links - below, or visit our releases page on GitHub. + {#if os !== "mac"} +

+
+ {:else} +
+ {#each macs as mac} +
+ {/if} +

+ {@html download.alternative}

{:else} @@ -147,23 +173,16 @@ {#if osButtons}
-
- Available for -
-
- {#each osButtons as button} -
+ {#each osButtons as button} +
{/if}