-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67415ab
commit 07ca3c7
Showing
8 changed files
with
7,516 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
=head1 NAME | ||
|
||
EPrints::Plugin::Screen::EPrint::Box::DimensionsBadge | ||
|
||
=head1 DESCRIPTION | ||
|
||
By default this module will render a box on the EPrint summary page that will be | ||
populdated with a Dimensions badge if the item has an appropraite identifier, and | ||
there is some Dimensions data for the item. | ||
|
||
There is also an EPScript method that can be called on an EPrint e.g. in a citation file. | ||
This allows a test to be conducted to see if the EPrint has enough data to make a Dimensions | ||
badge applicable, and also to render the badge. This can be used if the default EPrints Boxes | ||
are not used for rendering the summary page: | ||
|
||
|
||
<epc:if test="$item.dimensions_badge(1)"> | ||
<div id="summary_dimensions" class="summary-widget"> | ||
<h2>Dimensions</h2> | ||
<epc:print expr="$item.dimensions_badge()" /> | ||
</div> | ||
</epc:if> | ||
|
||
Calling the method without a value will render the badge: | ||
<epc:print expr="$item.dimensions_badge()" /> | ||
|
||
Passing a parameter to the method will return a boolean to show whether the badge could be rendered: | ||
<epc:if test="$item.dimensions_badge(1)"> | ||
|
||
|
||
The display of the badge can be altered by updating the configuration in the | ||
B<z_dimensions_badge.pl> configuration file. | ||
|
||
For a full description of the Dimensions badge, please see L<https://badge.dimensions.ai/>. | ||
|
||
=head1 BUGS | ||
|
||
Please view L<https://github.com/eprintsug/dimensions-badge/issues/> for details of | ||
any known bugs, or to submit reports of any bugs you have discovered. | ||
|
||
=head1 AVAILABILITY | ||
|
||
This module should be available via the EPrints Bazaar L<https://bazaar.eprints.org/>. | ||
|
||
The code lives at L<https://github.com/eprintsug/dimensions-badge/>. | ||
|
||
=head1 AUTHOR | ||
|
||
John Salter L<https://orcid.org/0000-0002-8611-8266> - L<https://github.com/jesusbagpuss/> | ||
|
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,75 @@ | ||
######################################################################################## | ||
# Dimensions Summary Page Widget | ||
# | ||
# See: https://badge.dimensions.ai | ||
# | ||
######################################################################################## | ||
|
||
# Enable the widget | ||
$c->{plugins}{"Screen::EPrint::Box::DimensionsBadge"}{params}{disable} = 0; | ||
|
||
# Function to return id type and id. | ||
# Supported id_types are listed on https://badge.dimensions.ai/. | ||
# In 2019-02, doi, pmid and DimensionsIDs (id) are supported. | ||
# | ||
# If an EPrint has multiple usable identifiers, the first returned | ||
# value will be used. | ||
# | ||
# Also, if for some reason you wanted to *not* show a Dimensions badge for an item, returning | ||
# no value from this will not show a badge. | ||
$c->{'dimensions_badge'}->{get_type_and_id} = sub { | ||
my( $eprint ) = @_; | ||
|
||
if( $eprint->exists_and_set( "doi" ) ){ | ||
return( "doi", $eprint->value( "doi" ) ); | ||
} | ||
if( $eprint->exists_and_set( "pmid" ) ){ | ||
return( "pmid", $eprint->value( "pmid" ) ); | ||
} | ||
|
||
# id_numbers that have 10. in them (rudimentary doi check) | ||
if( $eprint->exists_and_set( "id_number" ) && ( $eprint->value( "id_number" ) =~ /\b10./ ) ){ | ||
|
||
return( "doi", $eprint->value( "id_number" ) ); | ||
} | ||
|
||
#other fields could be checked and returned here. | ||
}; | ||
|
||
# Position | ||
# By default the Box plugins will appear at position 1000 of the 'summary_right' area. | ||
# To change the position of the Dimensions badge within this area, alter the value below: | ||
#$c->{plugins}->{"Screen::EPrint::Box::DimensionsBadge"}->{appears}->{summary_right} = 500; | ||
# | ||
# To stop the badge appearing in the summary_right area, un-set the value: | ||
#$c->{plugins}->{"Screen::EPrint::Box::DimensionsBadge"}->{appears}->{summary_right} = undef; | ||
# To make it appear in other places, define where, and the position: | ||
#$c->{plugins}->{"Screen::EPrint::Box::DimensionsBadge"}->{appears}->{summary_bottom} = 25; | ||
|
||
|
||
# Badge appearance | ||
# You can customise how the badge is dispalyed by setting attributes here. | ||
# For the full list of options, see https://badge.dimensions.ai/#customising. | ||
# The values here will be set on the <span> element used to create the badge. | ||
# | ||
#$c->{plugins}{"Screen::EPrint::Box::DimensionsBadge"}{params}{data_attributes} = { | ||
# 'data-legend' => 'always', | ||
# 'data-style' => 'large_circle', | ||
# 'data-hide-zero-citations' => 'true', | ||
#}; | ||
|
||
|
||
# Javascript URL | ||
# By default the link to the badge javascript is included in the Box, or rendered | ||
# with the EPScript methods. | ||
# You may wish to add the link to the badge javascript to your template, or | ||
# include it in your page another way. If you do this, you can prevent the default | ||
# inclusion of the javascript by uncommenting the following line: | ||
#$c->{plugins}{"Screen::EPrint::Box::DimensionsBadge"}{params}{exclude_js} = 1; | ||
# | ||
# If for some reason you need to set a different URL for the main badge javascript, | ||
# you can configure this option: | ||
#$c->{plugins}{"Screen::EPrint::Box::DimensionsBadge"}{params}{js_url} = "https://badge.dimensions.ai/badge.js"; | ||
# | ||
|
||
|
Oops, something went wrong.