-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from IQSS/1-redirct
add code to redirect to Binder
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
# dataverse-binder-redirect | ||
# Dataverse Binder Redirect | ||
|
||
To use Binder with Dataverse, please install the following [external tool][] manifest. | ||
|
||
[external tool]: https://guides.dataverse.org/en/latest/admin/external-tools.html | ||
|
||
Once you do, a "Binder" button will appear under "Access Dataset". Clicking that button will send the user to a static page hosted on GitHub Pages (the code in this repo). The static page places the DOI of a dataset into a URL that Binder can understand and then redirects the user there. | ||
|
||
For example, the user may click "Binder" and land on the static page at https://iqss.github.io/dataverse-binder-redirect/v1/?datasetPid=doi:10.7910/DVN/TJCLKP which will send the user to https://mybinder.org/v2/dataverse/10.7910/DVN/TJCLKP/ | ||
|
||
Please note that this redirect page will no longer be required once the Dataverse external tool framework supports putting parameters in the path (rather than just the query parameters) of a URL ([#9345](https://github.com/IQSS/dataverse/issues/9345)). | ||
|
||
```bash | ||
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \ | ||
'{ | ||
"displayName": "Binder", | ||
"description": "Run on Binder", | ||
"scope": "dataset", | ||
"type": "explore", | ||
"toolUrl": "https://iqss.github.io/dataverse-binder-redirect/v1/", | ||
"toolParameters": { | ||
"queryParameters": [ | ||
{ | ||
"datasetPid": "{datasetPid}" | ||
} | ||
] | ||
} | ||
}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script> | ||
// Send datasetPid as a query parameter like this: | ||
// https://iqss.github.io/dataverse-binder-redirect/v1/?datasetPid=doi:10.7910/DVN/TJCLKP | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const datasetPid = urlParams.get('datasetPid'); | ||
const pidWithoutProtocol = datasetPid.split(':')[1]; | ||
// Redirect to Binder like this: | ||
// https://mybinder.org/v2/dataverse/10.7910/DVN/TJCLKP/ | ||
window.location.replace('https://mybinder.org/v2/dataverse/' + pidWithoutProtocol + '/'); | ||
</script> |