diff --git a/cfg/cfg.d/z_orcid_support.pl b/cfg/cfg.d/z_orcid_support.pl index 619986b..822bdcb 100644 --- a/cfg/cfg.d/z_orcid_support.pl +++ b/cfg/cfg.d/z_orcid_support.pl @@ -24,8 +24,8 @@ =head2 Changes $c->{plugins}{"Export::Report::CSV::CreatorsOrcid"}{params}{disable} = 0; #---Users---# -#add orcid field to the user profile's -#but checking first to see if the field is already present in the user dataset before adding it +#add orcid field to the user profile's +#but checking first to see if the field is already present in the user dataset before adding it my $orcid_present = 0; for(@{$c->{fields}->{user}}) { @@ -63,7 +63,7 @@ =head2 Changes last; } } - + #add orcid subfield if( !$orcid_present ) { @@ -74,9 +74,9 @@ =head2 Changes input_cols => 19, allow_null => 1, } - )); + )); } - } + } } #automatic update of eprint creator field @@ -117,7 +117,7 @@ =head2 Changes $eprint->set_value("creators", \@new_creators); } - + }, priority => 50 ); #automatic update of eprint editor field @@ -158,7 +158,7 @@ =head2 Changes $eprint->set_value("editors", \@new_editors); } - + }, priority => 50 ); @@ -166,21 +166,21 @@ =head2 Changes { package EPrints::Script::Compiled; use strict; - + sub run_people_with_orcids { my( $self, $state, $value ) = @_; - + my $session = $state->{session}; my $r = $state->{session}->make_doc_fragment; - + my $creators = $value->[0]; - + foreach my $i (0..$#$creators) { - + my $creator = @$creators[$i]; - + if( $i > 0 ) { #not first item (or only one item) @@ -194,25 +194,31 @@ sub run_people_with_orcids $r->appendChild( $session->make_text( ", " ) ); } } - + my $person_span = $session->make_element( "span", "class" => "person" ); $person_span->appendChild( $session->render_name( $creator->{name} ) ); - + + my $orcid_domain; + if( $session->config( 'orcid_support_advance', 'orcid_domain' ) ) { + $orcid_domain = $c->{orcid_support_advance}->{orcid_domain}; + } else { + $orcid_domain = "orcid.org"; + } my $orcid = $creator->{orcid}; - if( defined $orcid && $orcid =~ m/^(?:orcid.org\/)?(\d{4}\-\d{4}\-\d{4}\-\d{3}(?:\d|X))$/ ) + if( defined $orcid && $orcid =~ m/^(?:\Q$orcid_domain\E\/)?(\d{4}\-\d{4}\-\d{4}\-\d{3}(?:\d|X))$/ ) { - my $orcid_link = $session->make_element( "a", + my $orcid_link = $session->make_element( "a", "class" => "orcid", - "href" => "https://orcid.org/$1", + "href" => "https://" . $orcid_domain . "/" . $1, "target" => "_blank", ); $orcid_link->appendChild( $session->make_element( "img", "src" => "/images/orcid_16x16.png" ) ); my $orcid_span = $session->make_element( "span", "class" => "orcid-tooltip" ); - + $orcid_span->appendChild( $session->make_text( "ORCID: " ) ); - $orcid_span->appendChild( $session->make_text( "https://orcid.org/$1" ) ); - $orcid_link->appendChild( $orcid_span ); + $orcid_span->appendChild( $session->make_text( "https://" . $orcid_domain . "/" . $1 ) ); + $orcid_link->appendChild( $orcid_span ); $person_span->appendChild( $session->make_text( " " ) ); $person_span->appendChild( $orcid_link ); diff --git a/cfg/cfg.d/zzz_rioxx2_orcid.pl b/cfg/cfg.d/zzz_rioxx2_orcid.pl index 9a19d02..d98e1da 100644 --- a/cfg/cfg.d/zzz_rioxx2_orcid.pl +++ b/cfg/cfg.d/zzz_rioxx2_orcid.pl @@ -1,19 +1,28 @@ -#Adapted from John Salter's work at: https://wiki.eprints.org/w/ORCID#Exposing_the_ORCID_in_RIOXX +#Adapted from John Salter's work at: https://wiki.eprints.org/w/ORCID#Exposing_the_ORCID_in_RIOXX $c->{rioxx2_value_author} = sub { my( $eprint ) = @_; - + + my $session = $eprint->{session}; + my $orcid_domain; + + if( $session->config( 'orcid_support_advance', 'orcid_domain' ) ) { + $orcid_domain = $session->config( 'orcid_support_advance', 'orcid_domain' ); + } else { + $orcid_domain = "orcid.org"; + } + my @authors; for( @{ $eprint->value( "creators" ) } ) - { + { my $id = $_->{orcid}; - $id = EPrints::ORCID::Utils::get_normalised_orcid( $id ); - if( $id ) + $id = EPrints::ORCID::Utils::get_normalised_orcid( $id ); + if( $id ) { push @authors, { author => EPrints::Utils::make_name_string( $_->{name} ), - id => "https://orcid.org/$id" + id => "https://" . $orcid_domain . "/" . $id }; - } + } else { push @authors, { @@ -21,7 +30,7 @@ }; } } - + #NB If your corp_creators has DOIs or ISNIs for the entries, a similar method could be used to include these here. foreach my $corp ( @{ $eprint->value( "corp_creators" ) } ) { @@ -29,6 +38,6 @@ $entry->{name} = $corp; push @authors, { author => $corp }; } - + return \@authors; }; diff --git a/lib/plugins/EPrints/MetaField/Orcid.pm b/lib/plugins/EPrints/MetaField/Orcid.pm index c818db3..874f080 100644 --- a/lib/plugins/EPrints/MetaField/Orcid.pm +++ b/lib/plugins/EPrints/MetaField/Orcid.pm @@ -73,14 +73,20 @@ sub get_basic_input_elements sub render_single_value { my( $self, $session, $value ) = @_; - - my $url = "https://orcid.org/$value"; - - my $link = $session->render_link( $url, "_blank" ); - $link->appendChild( $session->make_element( "img", src => "/images/orcid_16x16.png", class => "orcid-icon" ) ); - $link->appendChild( $session->make_text( "https://orcid.org/$value" ) ); - - return $link; + my $orcid_domain; + if( $session->config( 'orcid_support_advance', 'orcid_domain' ) ) { + $orcid_domain = $session->config( 'orcid_support_advance', 'orcid_domain' ); + } else { + $orcid_domain = "orcid.org"; + } + + my $url = "https://" . $orcid_domain . "/" . $value; + + my $link = $session->render_link( $url, "_blank" ); + $link->appendChild( $session->make_element( "img", src => "/images/orcid_16x16.png", class => "orcid-icon" ) ); + $link->appendChild( $session->make_text( "https://" . $orcid_domain . "/" . $value ) ); + + return $link; } sub validate @@ -144,7 +150,7 @@ sub validate_orcid { push @problems, $session->html_phrase( "validate:invalid_orcid_format" ); } - + return @problems; }