-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into subcom-invitation
- Loading branch information
Showing
14 changed files
with
303 additions
and
185 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
assets/js/components/react_invenio_forms/CustomAffiliationsSuggestions.js
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,59 @@ | ||
import React from "react"; | ||
import { Header, Grid } from "semantic-ui-react"; | ||
import { makeIdEntry, makeSubheader } from "react-invenio-forms"; | ||
|
||
|
||
export const CustomAffiliationsSuggestions = (creatibutors) => { | ||
// Ensure creatibutors is always an array | ||
const creatibutorsArray = Array.isArray(creatibutors) ? creatibutors : [creatibutors]; | ||
|
||
return creatibutorsArray.map((creatibutor) => { | ||
const { creatibutor: creatibutorData } = creatibutor; | ||
const { name, acronym, identifiers = [], id } = creatibutorData; | ||
|
||
const subheader = makeSubheader(creatibutorData, creatibutor.isOrganization); | ||
const displayName = acronym ? `${name} (${acronym})` : name; | ||
|
||
const sources = []; | ||
const idStrings = []; | ||
|
||
identifiers.forEach((identifier) => { | ||
const { scheme, identifier: value } = identifier; | ||
|
||
if (scheme === "ror") { | ||
sources.push( | ||
<span key={value}> | ||
Source: {scheme.toUpperCase()} <span>(Preferred)</span> | ||
</span> | ||
); | ||
} else if (scheme === "edmo") { | ||
sources.push( | ||
<span key={value}>Source: {scheme.toUpperCase()}</span> | ||
); | ||
} else { | ||
const idEntry = makeIdEntry(identifier); | ||
if (idEntry) idStrings.push(idEntry); | ||
} | ||
}); | ||
|
||
return ( | ||
<Grid key={id}> | ||
<Grid.Row columns={2} verticalAlign="middle"> | ||
<Grid.Column width={12}> | ||
<Header> | ||
{displayName} {idStrings.length > 0 && <>({idStrings})</>} | ||
{subheader && <Header.Subheader>{subheader}</Header.Subheader>} | ||
</Header> | ||
</Grid.Column> | ||
<Grid.Column width={4} textAlign="right"> | ||
{sources.length > 0 && ( | ||
<Header as="h6" color="grey" style={{ margin: 0 }}> | ||
{sources} | ||
</Header> | ||
)} | ||
</Grid.Column> | ||
</Grid.Row> | ||
</Grid> | ||
); | ||
}); | ||
}; |
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
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,4 +1,3 @@ | ||
version: '2.2' | ||
services: | ||
cache: | ||
extends: | ||
|
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,4 +1,3 @@ | ||
version: '2.2' | ||
services: | ||
cache: | ||
extends: | ||
|
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,4 +1,3 @@ | ||
version: "2.2" | ||
services: | ||
app: | ||
build: | ||
|
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
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
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
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,57 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# ZenodoRDM is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Custom scheme config.""" | ||
|
||
import re | ||
|
||
# Regular expression to validate EDMO identifiers in the format "edmo:<ID>" | ||
edmo_regexp = re.compile(r"^edmo:(\d+)$") | ||
|
||
# Regular expression to match the EDMO URL format | ||
edmo_url_regexp = re.compile( | ||
r"(?:https?://)?(?:edmo\.seadatanet\.org/report/)?(\d+)$", re.IGNORECASE | ||
) | ||
|
||
|
||
def is_edmo(val): | ||
""" | ||
Validate and normalize an EDMO identifier or URL. | ||
Returns the normalized 'edmo:<ID>' format if valid, otherwise None. | ||
""" | ||
# Match against the URL or the edmo:<ID> format | ||
match = edmo_url_regexp.match(val) or edmo_regexp.match(val) | ||
if match: | ||
# Extract the numeric ID from the matched group | ||
return f"edmo:{match.group(1)}" | ||
return None | ||
|
||
|
||
def normalize_edmo(val): | ||
"""Normalize an EDMO identifier or URL to the 'edmo:<ID>' format.""" | ||
return is_edmo(val) | ||
|
||
|
||
def generate_edmo_url(_, normalized_pid): | ||
""" | ||
Generate a URL for a given normalized EDMO identifier. | ||
Assumes the input is in the form 'edmo:<ID>'. | ||
""" | ||
edmo_id = normalized_pid.split(":")[1] | ||
return f"https://edmo.seadatanet.org/report/{edmo_id}" | ||
|
||
|
||
def get_scheme_config_func(): | ||
"""Return the configuration for the EDMO custom scheme.""" | ||
return { | ||
"validator": is_edmo, | ||
"normalizer": normalize_edmo, | ||
"filter": [], | ||
"url_generator": generate_edmo_url, | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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