Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
DataCite DOI
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=Document Landing Pages= The DataCite DOI plugin supports minting DOIs for documents uploaded to eprint records, however all DOIs must resolve to a landing page however and so in order to enable this your repository needs to support document landing pages. The following code snippets illustrate how to implement document landing pages in EPrints. First we need a URL rewrite trigger to catch the URLs which should resolve to the landing page. The following needs to be added to the eprints or archives' configuration files, e.g. '''lib/cfg.d/doc_landing_pages.pl'''. We can also define a flag here for plugins to check to see if document landing pages are enabled on this repository. <pre> # configuration flag used to check if document landing pages are enabled on this repository $c->{doc_landing_pages_enabled} = 1; $c->add_trigger( EP_TRIGGER_URL_REWRITE, sub { my( %args ) = @_; my( $uri, $rc, $request ) = @args{ qw( uri return_code request ) }; # matches https://myrepo.ac.uk/document/<doc_id> if( defined $uri && ($uri =~ m#^/document/(.*)$# ) ) { $request->handler('perl-script'); $request->set_handlers(PerlResponseHandler => [ 'EPrints::Apache::Document' ] ); ${$rc} = EPrints::Const::OK; } return EP_TRIGGER_OK; }, priority => 100 ); </pre> This trigger uses a Document handler we need to implement, e.g. '''perl_lib/EPrints/Apache/Document.pm''' <pre> ###################################################################### # # EPrints::Apache::Document # ###################################################################### package EPrints::Apache::Document; use strict; use EPrints; use EPrints::Apache::AnApache; sub handler { my( $r ) = @_; my $uri = $r->uri; if( $uri =~ m#^/document/(.*)$# ) { my $repository = $EPrints::HANDLE->current_repository; return DECLINED if( !defined $repository ); # Document landing pages enabled for this repository? return DECLINED unless( $repository->config( "doc_landing_pages_enabled" ) ); my $doc_id = $1; my $doc_ds = $repository->dataset( "document" ); my $doc = $doc_ds->dataobj( $doc_id ); if( defined $doc ) { EPrints::ScreenProcessor->process( session => $repository, screenid => "Document", document => $doc, ); return OK; } } return DECLINED; } 1; </pre> The handler calls on an EPrints screen to generate the content for the landing page, e.g. '''perl_lib/EPrints/Plugin/Screen/Document.pm''' <pre> =head1 NAME EPrints::Plugin::Screen::Document =cut# package EPrints::Plugin::Screen::Document; use EPrints::Plugin::Screen; @ISA = ( 'EPrints::Plugin::Screen' ); use strict; sub new { my( $class, %params ) = @_; my $self = $class->SUPER::new(%params); return $self; } sub properties_from { my( $self ) = @_; $self->{processor}->{eprint} = $self->{processor}->{document}->get_eprint; $self->SUPER::properties_from; } sub render_title { my( $self ) = @_; my $session = $self->{session}; my $f = $self->{session}->make_doc_fragment; my $eprint = $self->{processor}->{eprint}; my $doc = $self->{processor}->{document}; $f->appendChild( $self->{processor}->{eprint}->render_citation( "screen" ) ); $f->appendChild( $self->{session}->html_phrase( "document_join" ) ); $f->appendChild( $self->{processor}->{document}->render_citation( "screen" ) ); return $f; } sub render { my( $self ) = @_; my $repo = $self->{repository}; my $doc = $self->{processor}->{document}; my $page = $repo->make_doc_fragment; my $div = $repo->make_element( "div", class => "doc_citation" ); $div->appendChild( $doc->render_citation( "landing_page", eprint => $self->{processor}->{eprint} ) ); return( $div ); } 1; </pre> And finally, the screen uses a citation file to display the document landing page content in an easily customisable fashion, e.g. '''lib/defaultcfg/citations/document/landing_page.xml''' <pre> <?xml version="1.0" ?> <!-- Full "abstract page" (or splash page or summary page, depending on your jargon) for an eprint. --> <cite:citation xmlns="http://www.w3.org/1999/xhtml" xmlns:epc="http://eprints.org/ep3/control" xmlns:cite="http://eprints.org/ep3/citation" > <!-- Display the parent eprint citation --> <epc:print expr="$eprint.citation_link('default')" /> <!-- Display the document details in a similar fashion to eprint summary pages --> <table> <tr> <td valign="top" align="right"><epc:print expr="$item.icon( 'HoverPreview', 'noNewWindow' )" /></td> <td valign="top"> <epc:print expr="$item.citation('default')" /><br /> <a href="{$item.url()}" class="ep_document_link"><epc:phrase ref="summary_page:download"/> (<epc:print expr="$item.doc_size().human_filesize()" />)</a> </td> </tr> </table> </cite:citation> </pre>
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)