Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

340 resources filters order of options #398

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions data/resources.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
{ "phases": ["Plan", "Collect", "Process", "Analyse", "Preserve", "Share", "Reuse"],
"levels": ["Basic", "Intermediate", "Advanced"],
"targets": ["training", "guidance", "tool"],
"types": ["Web page", "Video", "Material", "Tool", "Course"],
"topics": ["Data transfer", "FAIR principles", "Metadata", "README files", "University RDM resources", "What is Research Data Management", "Research involving human data", "Sharing human data", "GDPR and ethical review glossary"],
"items": [
{
"title": "RDMkit on Your role",
Expand Down Expand Up @@ -85,7 +89,7 @@
"short_title": "Metadata",
"target": ["training"],
"type": ["Material"],
"search_tags": ["material","metadata"],
"search_tags": ["material","Metadata"],
"phase": ["Plan", "Collect", "Share"],
"topic": ["Metadata"],
"level": ["Basic"],
Expand Down Expand Up @@ -303,7 +307,7 @@
"short_title": "Versioning",
"target": ["training"],
"type": ["Material"],
"search_tags": ["material","git","versioning"],
"search_tags": ["material","git","Versioning"],
"phase": ["Analyse"],
"level": ["Basic"],
"url": "https://nbisweden.github.io/module-versioning-dm-practices/",
Expand All @@ -316,7 +320,7 @@
"short_title": "Data organisation",
"target": ["training"],
"type": ["Material"],
"search_tags": ["material","data organisation","organisation","organization"],
"search_tags": ["material","Data organisation","organisation","organization"],
"phase": ["Collect"],
"level": ["Basic"],
"url": "https://nbisweden.github.io/module-organising-data-dm-practices/",
Expand Down Expand Up @@ -535,7 +539,6 @@
"type": ["Web page"],
"search_tags": ["storage","resources","infrastructure","Storage resources available for researchers in Sweden"],
"phase": ["Collect", "Process", "Analyse", "Preserve"],
"topic": [""],
"level": ["Basic"],
"url": "https://data.scilifelab.se/resources/storage/",
"description": "Information page regarding storage resources available to researchers in Sweden, and how to apply for access.",
Expand All @@ -548,7 +551,6 @@
"type": ["Web page"],
"search_tags": ["compute","resources","infrastructure","Compute resources available for researchers in Sweden"],
"phase": ["Analyse"],
"topic": [""],
"level": ["Basic"],
"url": "https://data.scilifelab.se/resources/e-infrastructure/",
"description": "Information page regarding compute resources related to hosting, simulation, and analysis that are available to researchers in Sweden. It contains information about the services the resources provide, and how to apply for access to them.",
Expand Down
101 changes: 87 additions & 14 deletions layouts/resources/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
{{/* Compile list of the resources in Hugo */}}
<!-- t for training, g for guidance to for tool -->
<!-- {{ $type := slice }} -->
{{ $level := slice }}
{{ $phase := slice }}
{{ $level := $.Site.Data.resources.levels }}
{{ $phase := $.Site.Data.resources.phases }}
{{ $topic := $.Site.Data.resources.topics }}
{{ $t_rlist := slice }}
{{ $t_type := slice }}
{{ $t_provider := slice }}
Expand All @@ -17,17 +18,7 @@
{{ $to_type := slice }}
{{ $to_provider := slice }}

<!-- Go through all resources without sorting, collect type, phase & level.
A dirty fix in order to obtain phase and levels in 'right' order, that
requires that the first 2 resources in resources.json always is the same as now. -->
{{ range $.Site.Data.resources.items }}
<!-- {{ $type = $type | append .type }} -->
{{ $level = $level | append .level }}
{{ $phase = $phase | append .phase }}
{{ end }}
<!-- {{ $type = $type | uniq }} -->
{{ $level = $level | uniq }}
{{ $phase = $phase | uniq }}

<!-- Collect and sort all resources on title -->
{{ range sort $.Site.Data.resources.items ".title" "asc" }}
{{ if in .target "training"}}
Expand Down Expand Up @@ -244,6 +235,88 @@
</div>
{{ end }}
</div>
<!-- Validate the resources.json file, check that all mandatory fields have values
and that fields with 'controlled vocabulary' has valid values. For arrays, check that
first element is not empty. -->
{{ range $itemIndex, $item := $.Site.Data.resources.items }}
{{ if not (.title) }}
{{ errorf "Resource %d (%s) is missing a title" $itemIndex .short_title }}
{{ end }}
{{ if not (.short_title) }}
{{ errorf "Resource %d (%s) is missing a short_title" $itemIndex .title }}
{{ end }}
{{ if not (index .target 0) }}
{{ errorf "Resource %d (%s) is missing a target" $itemIndex .title }}
{{ end }}
{{ if not (index .type 0) }}
{{ errorf "Resource %d (%s) is missing a type" $itemIndex .title }}
{{ end }}
{{ if not (index .search_tags 0) }}
{{ errorf "Resource %d (%s) is missing search_tags" $itemIndex .title }}
{{ end }}
{{ if and .topic (not (index .topic 0)) }}
{{ errorf "Resource %d (%s) has an empty topic" $itemIndex .title }}
{{ end }}
{{ if and .phase (not (index .phase 0)) }}
{{ errorf "Resource %d (%s) has an empty phase" $itemIndex .title }}
{{ end }}
{{ if and (not (index .phase 0)) (not (index .topic 0)) }}
{{ errorf "Resource %d (%s) is missing both phase and topic" $itemIndex .title }}
{{ end }}
{{ if not (index .level 0) }}
{{ errorf "Resource %d (%s) is missing a level" $itemIndex .title }}
{{ end }}
{{ if not (.url) }}
{{ errorf "Resource %d (%s) is missing a url" $itemIndex .title }}
{{ end }}
{{ if not (.description) }}
{{ errorf "Resource %d (%s) is missing a description" $itemIndex .title }}
{{ end }}
{{ if not (index .provider 0) }}
{{ errorf "Resource %d (%s) is missing a provider" $itemIndex .title }}
{{ end }}

<!-- Validate fields with 'controlled vocabularies' -->
{{ range .target}}
{{ if not (in $.Site.Data.resources.targets .) }}
{{ errorf "Resource %d (%s) has a target typo: %s" $itemIndex $item.title . }}
{{ end }}
{{ end }}
{{ range .type }}
{{ if not (in $.Site.Data.resources.types .) }}
{{ errorf "Resource %d (%s) has a type typo: %s" $itemIndex $item.title . }}
{{ end }}
{{ end }}
<!-- ensure that at least the title is given as a search tag -->
{{ $count := 0 }}
{{ range .search_tags }}
{{ if eq $item.title . }}
{{ $count = 1 }}
{{ end }}
{{ end }}
{{ if eq $count 0 }}
{{ errorf "Resource %d does not have it's title (%s) as search tag" $itemIndex .title }}
{{ end }}
<!-- Note: Code for checking topic typos is dependent on an array in resources.json. It would be better if the list of topics
could be collected on the fly, in order to always obtain an updated list -->
{{ if .topic }}
{{ range .topic }}
{{ if not (in $topic .) }}
{{ errorf "Resource %d (%s) has a topic typo: %+s " $itemIndex $item.title . }}
{{ end }}
{{ end }}
{{ end }}
{{ range .phase }}
{{ if not (in $phase .) }}
{{ errorf "Resource %d (%s) has a phase typo: %s" $itemIndex $item.title . }}
{{ end }}
{{ end }}
{{ range .level }}
{{ if not (in $level .) }}
{{ errorf "Resource %d (%s) has a level typo: %s" $itemIndex $item.title . }}
{{ end }}
{{ end }}
{{ end }}

<script>
// Function to search and filter the resource based on selected input
Expand Down Expand Up @@ -279,7 +352,7 @@
for (var [filter_name, filter_list] of Object.entries(selected_filters)) {
var r_resources = new Set;
filter_list.forEach(function (filter_value) {
$(`div.tab-pane.active div.resource[${filter_name}*='${filter_value}']`).each(function () { r_resources.add(this); });
$(`div.tab-pane.active div.resource[${filter_name}*=${filter_value}]`).each(function () { r_resources.add(this); });
});
all_selected_resources.push(r_resources);
};
Expand Down
Loading