@@ -65,7 +65,13 @@ <h1>Download URLs</h1>
6565 }
6666
6767 // Fetch the TSV file and display it in a table
68- fetch ( 'https://raw.githubusercontent.com/IDR/idr.openmicroscopy.org/refs/heads/master/_data/download_urls.tsv' )
68+ let TABLE_URL = 'https://raw.githubusercontent.com/IDR/idr.openmicroscopy.org/refs/heads/master/_data/download_urls.tsv' ;
69+ // check query params for ?tsv= to allow testing with a different TSV file
70+ const urlParams = new URLSearchParams ( window . location . search ) ;
71+ if ( urlParams . has ( 'tsv' ) ) {
72+ TABLE_URL = urlParams . get ( 'tsv' ) ;
73+ }
74+ fetch ( TABLE_URL )
6975 . then ( response => response . text ( ) )
7076 . then ( data => {
7177 const lines = data . split ( '\n' ) ;
@@ -91,6 +97,8 @@ <h1>Download URLs</h1>
9197 let idrIdIndex = headers . indexOf ( 'idrid' ) ;
9298 let imageIdIndex = headers . indexOf ( 'image_id' ) ;
9399 let dataLocationIndex = headers . indexOf ( 'data_location' ) ;
100+ let replaceThisIndex = headers . indexOf ( 'replace_this' ) ;
101+ let withThisIndex = headers . indexOf ( 'with_this' ) ;
94102
95103 // Create table body - update client_path to URL, based on the download_url column...
96104 const tbody = table . createTBody ( ) ;
@@ -103,34 +111,12 @@ <h1>Download URLs</h1>
103111 let clientPath = cells [ clientPathIndex ] ;
104112 let downloadUrl = cells [ downloadUrlIndex ] ;
105113 let dataLocation = cells [ dataLocationIndex ] ;
114+ let replaceThis = cells [ replaceThisIndex ] ;
115+ let withThis = cells [ withThisIndex ] ;
106116 let clientPathUrl ;
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-
124- } else if ( downloadUrl . includes ( idrId ) && clientPath . includes ( idrId ) ) {
125- // e.g. https://ftp.ebi.ac.uk/pub/databases/IDR/idr0001-graml-sysgro
126- let urlBase = downloadUrl . split ( idrId ) [ 0 ] ;
127- let urlPath = clientPath . split ( idrId ) [ 1 ] ;
128- clientPathUrl = urlBase + idrId + urlPath ;
129- }
130- if ( clientPathUrl ) {
131- // client_path needs patching for /idr0045-reichmann-zygotespindle/
132- clientPathUrl = clientPathUrl . replace ( "/idr0045-reichmann/" , "/idr0045-reichmann-zygotespindle/" ) ;
133- }
117+
118+ // Simple replace one prefix with another. We rely on the TSV file for correct values...
119+ clientPathUrl = clientPath . replace ( replaceThis , withThis ) ;
134120
135121 cells . forEach ( ( cellText , colIndex ) => {
136122 const td = document . createElement ( 'td' ) ;
0 commit comments