11---
2+ import { Icon } from " astro-icon/components" ;
3+ import { Image } from " astro:assets" ;
4+ import DownloadGephiDesktop from " ../../components/DownloadGephiDesktop.astro" ;
25import LangSwitcher from " ../../components/LangSwitcher.astro" ;
36import Layout from " ../../layouts/Layout.astro" ;
4- import { Image } from " astro:assets" ;
5- import { Icon } from " astro-icon/components" ;
6- import { fromPairs , map , mapValues , toPairs } from " lodash-es" ;
7-
8- const BROWSERS = {
9- windows64: {
10- label: " Windows" ,
11- dlSuffix: " windows-x64.exe" ,
12- icon: " ph:windows-logo-fill" ,
13- },
14- windows32: {
15- label: " Windows (32 bits)" ,
16- dlSuffix: " windows-x32.exe" ,
17- icon: " ph:windows-logo-fill" ,
18- },
19- macSilicon: {
20- label: " Mac OS" ,
21- dlSuffix: " macos-aarch64.dmg" ,
22- icon: " ph:apple-logo-fill" ,
23- },
24- macIntel: {
25- label: " Mac OS (Intel)" ,
26- dlSuffix: " macos-x64.dmg" ,
27- icon: " ph:apple-logo-fill" ,
28- },
29- linux: {
30- label: " Linux" ,
31- dlSuffix: " linux-x64.tar.gz" ,
32- icon: " ph:linux-logo-fill" ,
33- },
34- } as const ;
35-
36- type Browser = keyof typeof BROWSERS ;
37-
38- async function getDownloadLinks() {
39- try {
40- const resp = await fetch (" https://api.github.com/repos/gephi/gephi/releases/latest" );
41- const data = (await resp .json ()) as { tag_name: string ; assets: { browser_download_url: string }[] };
42- const version = data .tag_name .replace (/ ^ v/ , " " );
43- const res = {
44- version ,
45- links: mapValues (
46- BROWSERS ,
47- ({ dlSuffix }) => ` https://github.com/gephi/gephi/releases/download/v${version }/gephi-${version }-${dlSuffix } ` ,
48- ) as Partial <Record <Browser , string >>,
49- };
50-
51- const suffixes = fromPairs (toPairs (BROWSERS ).map (([browser , { dlSuffix }]) => [dlSuffix , browser ]));
52- data .assets .forEach (({ browser_download_url }) => {
53- const suffix = (browser_download_url .split (" /" ).at (- 1 ) || " " ).replace (` gephi-${version }- ` , " " );
54- if (suffixes [suffix ]) {
55- res .links [suffixes [suffix ] as Browser ] = browser_download_url ;
56- }
57- });
58-
59- return res ;
60- } catch (e ) {
61- const version = " 1.0.0" ;
62- return {
63- version ,
64- links: mapValues (
65- BROWSERS ,
66- ({ dlSuffix }) => ` https://github.com/gephi/gephi/releases/download/v${version }/gephi-${version }-${dlSuffix } ` ,
67- ) as Partial <Record <Browser , string >>,
68- };
69- }
70- }
71-
72- const DOWNLOAD_LINKS = await getDownloadLinks ();
737---
748
759<Layout >
@@ -92,51 +26,7 @@ const DOWNLOAD_LINKS = await getDownloadLinks();
9226 Gephi is an <strong >open-source</strong > desktop application to <strong >visually analyze networks</strong >.
9327 </p >
9428
95- <div class =" d-flex flex-column align-items-start" >
96- <a
97- href =" https://github.com/gephi/gephi/releases"
98- id =" download-gephi"
99- class =" btn btn-white fs-4 fw-bold mb-2"
100- ><Icon name =" ph:download-simple-bold" /> <span class =" text" >Download Gephi</span ></a
101- >
102- {
103- map (
104- BROWSERS ,
105- ({ label , icon }, browser : Browser ) =>
106- DOWNLOAD_LINKS .links [browser ] && (
107- <a class = " text-light" data-browser = { browser } href = { DOWNLOAD_LINKS .links [browser ]} >
108- <Icon name = { icon } /> Download for { label }
109- </a >
110- ),
111- )
112- }
113- <a class =" text-light" href =" https://github.com/gephi/gephi/releases" >
114- <Icon name =" ph:clock-counter-clockwise" /> Download Older Versions
115- </a >
116- </div >
117- <script define:vars ={ { DOWNLOAD_LINKS , BROWSERS }} >
118- let currentBrowser = "windows64";
119-
120- if (navigator.appVersion.indexOf("Win") !== -1) {
121- currentBrowser = "windows64";
122- } else if (navigator.appVersion.indexOf("Mac") !== -1) {
123- currentBrowser = "macSilicon";
124- } else if (navigator.userAgent.indexOf("Ubuntu") !== -1) {
125- currentBrowser = "linux";
126- } else if (navigator.appVersion.indexOf("X11") !== -1) {
127- currentBrowser = "linux";
128- }
129-
130- const link = document.getElementById("download-gephi");
131- const linkText = link.querySelector(".text");
132- if (DOWNLOAD_LINKS.links[currentBrowser]) {
133- link.href = DOWNLOAD_LINKS.links[currentBrowser];
134- linkText.innerHTML = `Download Gephi for ${BROWSERS[currentBrowser].label}`;
135- }
136-
137- const smallLink = document.querySelector(`a[data-browser='${currentBrowser}']`);
138- if (smallLink) smallLink.remove();
139- </script >
29+ <DownloadGephiDesktop withAlternativeLinks />
14030 </div >
14131 <div class =" col-5 text-end" >
14232 <Image
0 commit comments