Skip to content

Commit d8cc3ec

Browse files
authored
Merge pull request datalad#440 from datalad/knitting-threads
Knitting threads: bringing changes from all over into upstream
2 parents ab87477 + 3b9d423 commit d8cc3ec

File tree

13 files changed

+164
-97
lines changed

13 files changed

+164
-97
lines changed

datalad_catalog/catalog/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ The `artwork` and `assets` directories contain images and web assets (such as Ja
2020

2121
## Serving the content
2222

23-
Since this site is self-contained and static, no further build processes, server-side implementations, or access to content delivery networks (CDNs) are necessary in order to serve the content. All that is needed is a simple HTTP server.
23+
Since this site is self-contained and static, no further build processes or access to content delivery networks (CDNs) are necessary in order to serve the content. All that is needed is a simple HTTP server with one specific addition - a custom redirect. This is required because the application makes use of [Vue Router's history mode](https://v3.router.vuejs.org/guide/essentials/history-mode.html#html5-history-mode), which requires a server-side redirect configuration to deal with the fact that a VueJS application is actually a single-page app.
2424

25-
This can be achieved locally, for example using Python:
25+
For serving the content locally, this is already taken care of in `datalad-catalog`, and you can simply run the following:
2626

2727
```bash
2828
cd path/to/catalog/directory
29-
python3 -m http.server
29+
datalad catalog-serve -c .
3030
```
3131

32-
The content can also be hosted and served online. A straightforward and free way to achieve this is via GitHub and [GitHub Pages](https://pages.github.com/). After publishing this content as a GitHub repository, you can activate GitHub Pages in the repository's settings. See detailed instructions [here](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site).
32+
The content can also be hosted and served online. A straightforward way to achieve this, and one which has a free tier, is via [Netlify](https://www.netlify.com/) (the common alternative, [GitHub Pages](https://pages.github.com/), does not currently support server-side redirects). After publishing this content, e.g. as a GitHub repository, you can link that repository to a site on Netlify. [See here](https://docs.netlify.com/routing/redirects/) how to set up redirects with Netlify. Of course, the site can also be served from your preferred server setup, as long as page redirects can be supported.
3333

3434
## Maintaining content
3535

datalad_catalog/catalog/assets/app_component_dataset.js

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const datasetView = () =>
3434
files_ready: false,
3535
tags_ready: false,
3636
description_ready: false,
37-
description_display: "",
3837
citation_busy: false,
3938
citation_text: "",
4039
invalid_doi: false,
@@ -43,14 +42,13 @@ const datasetView = () =>
4342
watch: {
4443
subdatasets_ready: function (newVal, oldVal) {
4544
if (newVal) {
46-
console.log("subdatasets fetched!");
45+
console.debug("Watched property: subdatasets_ready = true")
46+
console.debug("Subdatasets have been fetched:");
4747
this.subdatasets = this.selectedDataset.subdatasets;
48-
console.log("from watcher");
49-
console.log(this.subdatasets);
48+
console.debug(this.subdatasets);
5049
tags = this.tag_options;
5150
if (this.subdatasets) {
5251
this.subdatasets.forEach((subds, index) => {
53-
console.log(index + "; " + subds);
5452
if (subds.available == "true" && subds.keywords) {
5553
tags = tags.concat(
5654
subds.keywords.filter((item) => tags.indexOf(item) < 0)
@@ -67,8 +65,10 @@ const datasetView = () =>
6765
dataset_ready: function (newVal, oldVal) {
6866
// TODO: some of these methods/steps should be moved to the generatpr tool. e.g. shortname
6967
if (newVal) {
68+
console.debug("Watched property: dataset_ready = true")
69+
console.debug("Active dataset:");
7070
dataset = this.selectedDataset;
71-
console.log(this.selectedDataset);
71+
console.debug(this.selectedDataset);
7272
disp_dataset = {};
7373
// Set name to unknown if not available
7474
if (!dataset.hasOwnProperty("name") || !dataset["name"]) {
@@ -156,6 +156,13 @@ const datasetView = () =>
156156
}
157157
} else {
158158
disp_dataset.url = dataset.url;
159+
if (disp_dataset.url && dataset.url.toLowerCase().indexOf("gin.g-node") >= 0) {
160+
disp_dataset.is_gin = true;
161+
disp_dataset.url = disp_dataset.url.replace('ssh://', '');
162+
disp_dataset.url = disp_dataset.url.replace('[email protected]:', 'https://gin.g-node.org');
163+
disp_dataset.url = disp_dataset.url.replace('[email protected]', 'https://gin.g-node.org');
164+
disp_dataset.url = disp_dataset.url.replace('.git', '');
165+
}
159166
}
160167
// Description
161168
if (
@@ -200,6 +207,19 @@ const datasetView = () =>
200207
else {
201208
disp_dataset.show_export = false
202209
}
210+
// Determine show/hide confirg for "Request access" button
211+
if (dataset.config?.hasOwnProperty("dataset_options") && dataset.config.dataset_options.hasOwnProperty("include_access_request")) {
212+
disp_dataset.show_access_request = dataset.config.dataset_options.include_access_request
213+
}
214+
else {
215+
// default should be to display the access request button, if access request contact/url are included
216+
disp_dataset.show_access_request = true
217+
}
218+
// Show / hide binder button: if disp_dataset.url exists OR if dataset has a notebook specified in metadata
219+
disp_dataset.show_binder_button = false
220+
if ( disp_dataset.url || dataset.hasOwnProperty("notebooks") && current_dataset.notebooks.length > 0 ) {
221+
disp_dataset.show_binder_button = true
222+
}
203223
// Write main derived variable and set to ready
204224
this.displayData = disp_dataset;
205225
this.display_ready = true;
@@ -338,6 +358,8 @@ const datasetView = () =>
338358
}, 1000);
339359
},
340360
async selectDataset(event, obj, objId, objVersion, objPath) {
361+
console.debug("Inside selectDataset")
362+
console.debug(event)
341363
event.preventDefault()
342364
var newBrowserTab = event.ctrlKey || event.metaKey || (event.button == 1)
343365
if (obj != null) {
@@ -375,29 +397,6 @@ const datasetView = () =>
375397
this.search_tags = []
376398
this.clearSearchTagText()
377399
},
378-
selectDescription(desc) {
379-
if (desc.content.startsWith("path:")) {
380-
this.description_ready = false;
381-
filepath = desc.content.split(":")[1];
382-
extension = "." + filepath.split(".")[1];
383-
desc_file = getFilePath(
384-
this.selectedDataset.dataset_id,
385-
this.selectedDataset.dataset_version,
386-
desc.path,
387-
extension
388-
);
389-
fetch(desc_file)
390-
.then((response) => response.blob())
391-
.then((blob) => blob.text())
392-
.then((markdown) => {
393-
this.description_display = marked.parse(markdown);
394-
this.description_ready = true;
395-
});
396-
} else {
397-
this.description_display = desc.content;
398-
this.description_ready = true;
399-
}
400-
},
401400
gotoHome() {
402401
// if there is NO home page set:
403402
// - if there is a tab name in the URL, navigate to current
@@ -464,12 +463,19 @@ const datasetView = () =>
464463
gotoURL(url) {
465464
window.open(url);
466465
},
467-
openWithBinder(dataset_url) {
466+
openWithBinder(dataset_url, current_dataset) {
468467
const environment_url =
469468
"https://mybinder.org/v2/gh/datalad/datalad-binder/main";
470469
const content_url = "https://github.com/jsheunis/datalad-notebooks";
471470
const content_repo_name = "datalad-notebooks";
472471
const notebook_name = "download_data_with_datalad_python.ipynb";
472+
if (current_dataset.hasOwnProperty("notebooks") && current_dataset.notebooks.length > 0) {
473+
// until including the functionality to select from multiple notebooks in a dropdown, just select the first one
474+
notebook = current_dataset.notebooks[0]
475+
content_url = notebook.git_repo_url.replace(".git", "")
476+
content_repo_name = content_url.substring(content_url.lastIndexOf('/') + 1)
477+
notebook_name = notebook.notebook_path
478+
}
473479
binder_url =
474480
environment_url +
475481
"?urlpath=git-pull%3Frepo%3D" +
@@ -558,8 +564,9 @@ const datasetView = () =>
558564
fetch(doi, { headers })
559565
.then((response) => response.text())
560566
.then((data) => {
561-
this.selectedDataset.citation_text = data;
562-
console.log(data);
567+
// strip html tags from response text
568+
let doc = new DOMParser().parseFromString(data, 'text/html');
569+
this.selectedDataset.citation_text = doc.body.textContent || "";
563570
this.citation_busy = false;
564571
});
565572
} else {
@@ -582,7 +589,7 @@ const datasetView = () =>
582589
// If a tab parameter is supplied via the router, navigate to that tab if
583590
// part of available tabs, otherwise default tab
584591
else {
585-
selectTab = tabs.indexOf(tab_param.toLowerCase())
592+
selectTab = available_tabs.indexOf(tab_param.toLowerCase())
586593
if (selectTab >= 0) {
587594
this.tabIndex = selectTab;
588595
} else {
@@ -598,6 +605,7 @@ const datasetView = () =>
598605
},
599606
},
600607
async beforeRouteUpdate(to, from, next) {
608+
console.debug("Executing navigation guard: beforeRouteUpdate")
601609
this.subdatasets_ready = false;
602610
this.dataset_ready = false;
603611

@@ -624,7 +632,6 @@ const datasetView = () =>
624632
this.$root.selectedDataset.keywords = this.$root.selectedDataset.keywords
625633
? this.$root.selectedDataset.keywords
626634
: [];
627-
this.dataset_ready = true;
628635

629636
if (
630637
this.$root.selectedDataset.hasOwnProperty("subdatasets") &&
@@ -706,7 +713,7 @@ const datasetView = () =>
706713
this.$root.selectedDataset.has_files = false;
707714
}
708715
// Now list all tabs and set the correct one
709-
// order in DOM: subdatasets, content, publications, funding, provenance,
716+
// order in DOM: content, subdatasets, publications, funding, provenance,
710717
sDs = this.$root.selectedDataset
711718
available_tabs = ['content', 'subdatasets']
712719
standard_tabs = ['publications', 'funding', 'provenance']
@@ -741,9 +748,11 @@ const datasetView = () =>
741748
available_tabs_lower,
742749
this.$root.selectedDataset.config?.dataset_options?.default_tab
743750
)
751+
this.dataset_ready = true;
744752
next();
745753
},
746754
async created() {
755+
console.debug("Executing lifecycle hook: created")
747756
// fetch superfile in order to set id and version on $root
748757
homefile = metadata_dir + "/super.json";
749758
homeresponse = await fetch(homefile);
@@ -772,7 +781,6 @@ const datasetView = () =>
772781
}
773782
text = await response.text();
774783
app.selectedDataset = JSON.parse(text);
775-
this.dataset_ready = true;
776784
if (
777785
this.$root.selectedDataset.hasOwnProperty("subdatasets") &&
778786
this.$root.selectedDataset.subdatasets instanceof Array &&
@@ -872,8 +880,10 @@ const datasetView = () =>
872880
available_tabs_lower,
873881
this.$root.selectedDataset.config?.dataset_options?.default_tab
874882
)
883+
this.dataset_ready = true;
875884
},
876885
mounted() {
886+
console.debug("Executing lifecycle hook: mounted")
877887
this.tag_options_filtered = this.tag_options;
878888
this.tag_options_available = this.tag_options;
879889
}

datalad_catalog/catalog/metadata/1882e2e6-fbbf-4ade-a65f-3a1615235f51/e5d2f8368fc5f6717d8ef131041c6d943298d0c7/cc9/4e43626749e8e368f1526a44a8fcf.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@
4747
]
4848
},
4949
"name": "Studyforrest Structural MRI scans",
50-
"description": [
51-
{
52-
"source": "datacite_gin",
53-
"content": "\"This dataset contains T1 and T2 weighted MRI scans, susceptibility weighted\n images, and diffusion imaging scans. These data are suitable for analyses\n of brain structure.\n\n For more information about the project visit: http://studyforrest.org\""
54-
}
55-
],
50+
"description": "\"This dataset contains T1 and T2 weighted MRI scans, susceptibility weighted\n images, and diffusion imaging scans. These data are suitable for analyses\n of brain structure.\n\n For more information about the project visit: http://studyforrest.org\"",
5651
"license": {
5752
"name": "Open Data Commons Public Domain Dedication and License (PDDL)",
5853
"url": "https://opendatacommons.org/licenses/pddl/"

datalad_catalog/catalog/metadata/3a8648b3-7df8-413f-8efb-4d39040ac174/10e23aafa8271f742e9022a3522d9a88d7fe30cf/e3a/40711c6157b40133f72c8598b00a2.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,7 @@
165165
"value": 11
166166
}
167167
],
168-
"description": [
169-
{
170-
"source": "datacite_gin",
171-
"content": "\"Extension of the dataset published in Hanke et al. (2014; doi:10.1038/sdata.2014.3) with\n additional acquisitions for 6 of the original 20 participants (and one additional participant).\n Participants performed a central fixation task while being stimulated with oriented gratings.\n The experiment was repeated in four different sessions with 7T BOLD fMRI acquisition, each\n with a different scan resolution (0.8, 1.4, 2.0, and 3.0 mm).\n \n This research was supported by a grant from the German Research Foundation (DFG) awarded to\n S. Pollmann and O. Speck (DFG PO 548/15-1). This research was, in part, also supported by the\n German Federal Ministry of Education and Research (BMBF) as part of a US-German collaboration\n in computational neuroscience (CRCNS), co-funded by the BMBF and the US National Science\n Foundation (BMBF 01GQ1112; NSF 1129855). Work on the data-sharing technology employed for this\n research was supported by US-German CRCNS project, co-funded by the BMBF and the US National\n Science Foundation (BMBF 01GQ1411; NSF 1429999).\""
172-
}
173-
],
168+
"description": "\"Extension of the dataset published in Hanke et al. (2014; doi:10.1038/sdata.2014.3) with\n additional acquisitions for 6 of the original 20 participants (and one additional participant).\n Participants performed a central fixation task while being stimulated with oriented gratings.\n The experiment was repeated in four different sessions with 7T BOLD fMRI acquisition, each\n with a different scan resolution (0.8, 1.4, 2.0, and 3.0 mm).\n \n This research was supported by a grant from the German Research Foundation (DFG) awarded to\n S. Pollmann and O. Speck (DFG PO 548/15-1). This research was, in part, also supported by the\n German Federal Ministry of Education and Research (BMBF) as part of a US-German collaboration\n in computational neuroscience (CRCNS), co-funded by the BMBF and the US National Science\n Foundation (BMBF 01GQ1112; NSF 1129855). Work on the data-sharing technology employed for this\n research was supported by US-German CRCNS project, co-funded by the BMBF and the US National\n Science Foundation (BMBF 01GQ1411; NSF 1429999).\"",
174169
"publications": [
175170
{
176171
"type": "",

datalad_catalog/catalog/metadata/5b1081d6-84d7-11e8-b00a-a0369fb55db0/b623351b43eb2715331ac59ad4cf41682e84ff7d/ed9/46e96a98769a46c7cb92b89d071a7.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,7 @@
172172
"value": 10
173173
}
174174
],
175-
"description": [
176-
{
177-
"source": "datacite_gin",
178-
"content": "\"Extension of a matching fMRI dataset (Sengupta, et al., 2017; OpenFMRI ds000113c) on participants performing a\n central fixation task while being stimulated with oriented visual gratings. This dataset extends the previous one\n with acquisitions for 3 matching spatial resolutions (1.4, 2.0, and 3.0 mm) at 3T (complementing the previous 7T\n acquisitions at 0.8, 1.4, 2.0, and 3.0 mm). Five of the total of seven participants are identical in both datasets.\n All participants are part of the studyforrest.org project.\n\n- This research was enabled by a grant from the German Research Foundation (DFG) awarded to S. Pollmann and\n O. Speck (DFG PO 548/15-1).\n\n- This research was, in part, also supported by the German Federal Ministry of Education and Research (BMBF) as\n part of a US-German collaboration in computational neuroscience (CRCNS), co-funded by the BMBF and the US\n National Science Foundation (BMBF 01GQ1112; NSF 1129855).\n\n- Data management technology (DataLad) employed for this research was supported by US-German CRCNS project,\n co-funded by the BMBF and the US National Science Foundation (BMBF 01GQ1411; NSF 1429999).\""
179-
}
180-
],
175+
"description": "\"Extension of a matching fMRI dataset (Sengupta, et al., 2017; OpenFMRI ds000113c) on participants performing a\n central fixation task while being stimulated with oriented visual gratings. This dataset extends the previous one\n with acquisitions for 3 matching spatial resolutions (1.4, 2.0, and 3.0 mm) at 3T (complementing the previous 7T\n acquisitions at 0.8, 1.4, 2.0, and 3.0 mm). Five of the total of seven participants are identical in both datasets.\n All participants are part of the studyforrest.org project.\n\n- This research was enabled by a grant from the German Research Foundation (DFG) awarded to S. Pollmann and\n O. Speck (DFG PO 548/15-1).\n\n- This research was, in part, also supported by the German Federal Ministry of Education and Research (BMBF) as\n part of a US-German collaboration in computational neuroscience (CRCNS), co-funded by the BMBF and the US\n National Science Foundation (BMBF 01GQ1112; NSF 1129855).\n\n- Data management technology (DataLad) employed for this research was supported by US-German CRCNS project,\n co-funded by the BMBF and the US National Science Foundation (BMBF 01GQ1411; NSF 1429999).\"",
181176
"publications": [
182177
{
183178
"type": "",

0 commit comments

Comments
 (0)