@@ -28,7 +28,6 @@ <h1>Download URLs</h1>
2828 let links = Array . from ( document . querySelectorAll ( 'a' ) ) ;
2929 // links = links.slice(0,50)
3030 for ( let link of links ) {
31- console . log ( 'Checking link:' , link ) ;
3231 // links.forEach(async link => {
3332 // ignore image viewer links
3433 if ( ! link . href || link . href . includes ( "img_detail" ) ) {
@@ -53,7 +52,6 @@ <h1>Download URLs</h1>
5352 await fetch ( `/link_check/?url=${ encodeURIComponent ( link . href ) } ` )
5453 . then ( res => res . json ( ) )
5554 . then ( data => {
56- console . log ( 'Link check data:' , data ) ;
5755 if ( data . is_valid ) {
5856 link . style . color = 'green' ;
5957 link . title = 'Link is valid (checked with server)' ;
@@ -92,6 +90,7 @@ <h1>Download URLs</h1>
9290 let downloadUrlIndex = headers . indexOf ( 'download_url' ) ;
9391 let idrIdIndex = headers . indexOf ( 'idrid' ) ;
9492 let imageIdIndex = headers . indexOf ( 'image_id' ) ;
93+ let dataLocationIndex = headers . indexOf ( 'data_location' ) ;
9594
9695 // Create table body - update client_path to URL, based on the download_url column...
9796 const tbody = table . createTBody ( ) ;
@@ -103,9 +102,28 @@ <h1>Download URLs</h1>
103102 let idrId = cells [ idrIdIndex ] ;
104103 let clientPath = cells [ clientPathIndex ] ;
105104 let downloadUrl = cells [ downloadUrlIndex ] ;
105+ let dataLocation = cells [ dataLocationIndex ] ;
106106 let clientPathUrl ;
107- // e.g. https://ftp.ebi.ac.uk/pub/databases/IDR/idr0001-graml-sysgro
108- if ( downloadUrl . includes ( idrId ) && clientPath . includes ( idrId ) ) {
107+ if ( dataLocation == "Github" ) {
108+ let branch = "main" ;
109+ // e.g. data/idr-metadata/idr0106-kubota-lunglightsheet/experimentA/companions/Mosaic_Image.companion.ome
110+ // links to https://github.com/IDR/idr0106-kubota-lunglightsheet/blob/main/experimentA/companions/Mosaic_Image.companion.ome
111+ // uod/idr/metadata/idr0052-walther-condensinmap/experimentA/companions/160719_NCAPD2gfpc272c78_MitoSys2/conc/cell0005_R0001.companion.ome
112+ // links to https://github.com/IDR/idr0052-walther-condensinmap/blob/master/experimentA/companions/160719_NCAPD2gfpc272c78_MitoSys2/conc/cell0005_R0001.companion.ome
113+ // uod/idr/metadata/idr0079-hartmann-lateralline/companions/experimentA/056F63395C/056F63395C.companion.ome
114+ // https://github.com/IDR/idr0079-hartmann-lateralline/blob/master/companions/experimentA/056F63395C/056F63395C.companion.ome
115+ let relativePath = clientPath . split ( "metadata/idr" ) [ 1 ] ;
116+ let githubRepo = "idr" + relativePath . split ( "/" ) [ 0 ] ;
117+ // some repos use "master" branch, so check for those...
118+ if ( "idr0079,idr0052,idr0065,idr0075,idr0100" . includes ( githubRepo . split ( "-" ) [ 0 ] ) ) {
119+ branch = "master" ;
120+ }
121+ relativePath = relativePath . split ( "/" ) . slice ( 1 ) . join ( "/" ) ;
122+ clientPathUrl = `https://github.com/IDR/${ githubRepo } /blob/${ branch } /${ relativePath } ` ;
123+ console . log ( "Client path URL (Github):" , clientPath , clientPathUrl ) ;
124+
125+ } else if ( downloadUrl . includes ( idrId ) && clientPath . includes ( idrId ) ) {
126+ // e.g. https://ftp.ebi.ac.uk/pub/databases/IDR/idr0001-graml-sysgro
109127 let urlBase = downloadUrl . split ( idrId ) [ 0 ] ;
110128 let urlPath = clientPath . split ( idrId ) [ 1 ] ;
111129 clientPathUrl = urlBase + idrId + urlPath ;
0 commit comments