Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Citing other eprints
if ( $eprint->is_set("parent") )
{
my $parentid = $eprint->get_value("parent");
my $dataset = $repository->dataset( "eprint" );
my $dobj = $dataset->dataobj($parentid);
my $parent_citation = $repository->make_element( "div", class => "panel panel-info" );
my $citation_header = $repository->make_element( "div", class => "panel-heading" );
my $citation_title = $repository->make_element( "h3", class => "panel-title" );
my $citation_titletext = $repository->make_text( "This dataset is part of a collection" );
$citation_title->appendChild( $citation_titletext );
$citation_header->appendChild( $citation_title );
$parent_citation->appendChild( $citation_header);
my $citation_body = $repository->make_element( "div", class => "panel-body" );
if ( $eprint->exists_and_set( "doi" ) ) {
my $citation_content = $repository->make_text( "Cite the collection as:" );
$citation_body->appendChild( $citation_content );
my $citation_text = $repository->make_element( "p", class => "ghostly", style => "width:100%;" );
my $citation_link = $repository->make_element( "a", class => "ghostly", style => "display:block;height:100%; padding-top:15px; padding-bottom:15px;margin-top:-15px;margin-bottom:-15px;" );
my $citation_linkurl = $repository->config( "base_url" ) .
'/id/eprint/' .
$parentid;
$citation_link->setAttribute( 'href', $citation_linkurl );
$citation_link->setAttribute( 'target', "_blank" );
$citation_link->appendChild( $dobj->render_citation( "ubdata" ) );
$citation_text->appendChild( $citation_link );
$citation_body->appendChild( $citation_text );
my $childcitation_content = $repository->make_text( "Cite this dataset as:" );
$citation_body->appendChild( $childcitation_content );
my $childcitation_text = $repository->make_element( "p", class => "ghostly", style => "width:100%;" );
my $childcitation_link = $repository->make_element( "a", class => "ghostly", style => "display:block;height:100%; padding-top:15px; padding-bottom:15px;margin-top:-15px;margin-bottom:-15px;", href => "#" );
$childcitation_link->appendChild( $eprint->render_citation( "ubdata" ) );
$childcitation_text->appendChild( $childcitation_link );
$citation_body->appendChild( $childcitation_text );
} else {
my $citation_content = $repository->make_text( "Please cite this dataset as:" );
$citation_body->appendChild( $citation_content );
my $citation_text = $repository->make_element( "p", class => "ghostly", style => "width:100%;" );
my $citation_link = $repository->make_element( "a", class => "ghostly", style => "display:block;height:100%; padding-top:15px; padding-bottom:15px;margin-top:-15px;margin-bottom:-15px;" );
my $citation_linkurl = $repository->config( "base_url" ) .
'/id/eprint/' .
$parentid;
$citation_link->setAttribute( 'href', $citation_linkurl );
$citation_link->setAttribute( 'target', "_blank" );
$citation_link->appendChild( $dobj->render_citation( "ubdata" ) );
$citation_text->appendChild( $citation_link );
$citation_body->appendChild( $citation_text );
}
$parent_citation->appendChild( $citation_body );
$fragments{parent_citation} = $parent_citation;
}
<epc:choose>
<epc:when test="parent">
<epc:print expr="$parent_citation" />
</epc:when>
<epc:otherwise>
<epc:print expr="$item.citation('ubdata')" />
</epc:otherwise>
</epc:choose>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment