Skip to content

Commit

Permalink
Add orcid fields to searches
Browse files Browse the repository at this point in the history
  • Loading branch information
dennmuel committed May 20, 2019
1 parent e6614a3 commit 9322dde
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions cfg/cfg.d/z_orcid_support.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
{
Expand Down Expand Up @@ -63,7 +63,7 @@ =head2 Changes
last;
}
}

#add orcid subfield
if( !$orcid_present )
{
Expand All @@ -74,9 +74,9 @@ =head2 Changes
input_cols => 19,
allow_null => 1,
}
));
));
}
}
}
}

#automatic update of eprint creator field
Expand Down Expand Up @@ -117,7 +117,7 @@ =head2 Changes
$eprint->set_value("creators", \@new_creators);
}


}, priority => 50 );

#automatic update of eprint editor field
Expand Down Expand Up @@ -158,29 +158,42 @@ =head2 Changes
$eprint->set_value("editors", \@new_editors);
}


}, priority => 50 );

#---Search Fields---#
# Eprints advanced search
my $orcid_search_fields = { meta_fields => [] };
foreach my $role (@{$c->{orcid}->{eprint_fields}})
{
my $field = $role.'_orcid';
push @{$orcid_search_fields->{meta_fields}}, $field;
}
push @{$c->{search}->{advanced}->{search_fields}}, $orcid_search_fields;

# User search
my $user_search_field = { meta_fields => [ "orcid" ] };
push @{$c->{search}->{user}->{search_fields}}, $user_search_field;

#Rendering ORCIDs
{
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)
Expand All @@ -194,25 +207,25 @@ 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 = $creator->{orcid};
if( defined $orcid && $orcid =~ m/^(?:orcid.org\/)?(\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",
"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_link->appendChild( $orcid_span );

$person_span->appendChild( $session->make_text( " " ) );
$person_span->appendChild( $orcid_link );
Expand Down

0 comments on commit 9322dde

Please sign in to comment.