EPrints Technical Mailing List Archive
Message: #09048
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
Re: [EP-tech] Overwrite a Plugin function
- To: <eprints-tech@ecs.soton.ac.uk>, Yuri <yurj@alfa.it>
- Subject: Re: [EP-tech] Overwrite a Plugin function
- From: Christopher Gutteridge <totl@soton.ac.uk>
- Date: Fri, 2 Sep 2022 11:03:54 +0100
First of all, it's an issue in EPrints that it doesn't separate
out the model from the view. That was largely my fault, and in my
defence I was quite young at the time.
I can think of several solutions to what you need. From worst to
best.
1.
The worst solution is to just edit the darn file. This will work but be lost if you upgrade the file. If you did go that route, I would recommend making a formal "patch" file that can be easily re-applied after an upgrade.. but this is still not a good way.
2.
If you absolutely need the plugin to be called "Orcid" then you could, in your config files, erase and recreate the function by tinkering with the register of functions in the Orcid package... Now I'm really rusty on this but I think this would do it. NOTE that there's a closing semi colon after the closing brace. This alters it for ALL repositories so would be more of a concern if you host serveral repositories on one install of EPrints
$EPrints::MetaField::Orcid{render_single_value} = sub {
my( $self, $session, $value ) = @_; my $url = "" class="moz-txt-link-freetext" href="https://eur03.safelinks.protection.outlook.com/?url="" originalSrc="http://orcid.org/$value" shash="UxybOfP5wb78jKn61uUD7JJz8oRscbRN4SLMzz/qZbewzNDGDU1qHFH82U66L0C1i57F4lss08IUIJAJjsqANRZSQvWu88578NFlCwpoNd1ErnEewAn4ef0v8DcMghEbMv/gNimTwbIK0+kadbagbFdUyo5d0+FNyNLB90ySUFQ=">http://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( "orcid.org/$value" ) ); return $link; };
3.
The final, and probably cleanest solution would be to make a new
plugin called, say, OrcidAlfa, and make it subclass Orcid.pm
package EPrints::MetaField::OrcidAlfa;
use strict;
use warnings;
BEGIN {
our( @ISA );
@ISA = qw( EPrints::MetaField::Orcid );
}
sub render_single_value
{
my( $self, $session, $value ) = @_;
my $url = "" class="moz-txt-link-rfc2396E" href="https://eur03.safelinks.protection.outlook.com/?url="" originalSrc="https://orcid.org/$value" shash="Sb1Qa5hc4Ec2GMMmxeuzuvH744+E4p0QeBPT4++/FG/5RIBiQWqw6KGiaDEA0ti9GUJ8u04z/3iASPPAwB2jGV5u2TsqI0SnOzVeQBszTZZeIoAAVhOVUwZ7AyRnRYGPCFfJQyBSmOFYYbuPy2OaYd9L+IWx7fvG1th3pSOvQno=">"https://orcid.org/$value";
my $link = $session->render_link( $url, "_blank" );
$link->appendChild( $session->make_element( "img", src
="" "/images/orcid_id.svg", class => "orcid-icon", alt =>
"ORCID logo" ) );
$link->appendChild( $session->make_text(
"https://orcid.org/$value" ) );
return $link;
}
1;
CAUTION: This e-mail originated outside the University of Southampton. Hi! I would like to overwrite this function: sub render_single_value { my( $self, $session, $value ) = @_; my $url = "" class="moz-txt-link-freetext" href="https://eur03.safelinks.protection.outlook.com/?url="" originalSrc="http://orcid.org/$value" shash="hwxKP3QdNsGWuqFr/bGG8MxbpY9T9fCwyCGj5vGUQWCaOxwlq0j0SiMu6PoB2XibnhTW6oZ1zQ6QmBBU5GtL7y592/HE+hkCpOqeW7T5F07k2RNaBWRxJdQ77w1HSnzyprUuB0pM//JhMRl3yBsYZFjoYlyWaGHtdpLQbeGvPqM=">http://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( "orcid.org/$value" ) ); return $link; } in lib/plugins/EPrints/MetaField/Orcid.pm to remove the "orcid.org/" text before the orcid. I would like to have the customized version in my_archive/cfg/cfg.d/z_orcid_render_single_value.pl.Which is the best way? *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech *** Archive: http://www.eprints.org/tech.php/ *** EPrints community wiki: http://wiki.eprints.org/
Christopher Gutteridge <totl@soton.ac.uk>
You should read our team blog at
http://blog.soton.ac.uk/webteam/
Sadly my trade union is currently in dispute over pay, pensions and casualisation. You can read more at https://www.ucu.org.uk/article/11896/Why-were-taking-action
The Southampton branch is currently working on "Action Short Of a Strike" (ASOS). This means only doing work we are contracted to do, so no working on any additional voluntary tasks. It's frustating, but so are below inflation pay rises.
As a result, so far I've had to turn down or stop working on:
- Coordinating the iSolutions Communities of Practice program
- Coordinating the System Documentation Community of Pracice
- Helping with a workshop on data visualisation
- Providing a Minecraft activity for the Archaeology family day
- Helping another team recruit someone for a post
- Not helped a colleague debug something in a service I'm an expert on but is no longer my responsibility
- Not offering to "keep an eye" on changes impacting our systems while I'm on holiday
I look forward to getting back into these kinds of activity as soon as the industrial action permits.
Please do not cover for people taking ASOS. If it causes problems, it is helpful to make management aware. The most unhelpful thing is for people to mitigate the impacts of industrial action or hide it from management. The best thing to help is to join the union and the action and/or donate to the strike fund.
- Follow-Ups:
- Re: [EP-tech] Overwrite a Plugin function
- From: Christopher Gutteridge <totl@soton.ac.uk>
- Re: [EP-tech] Overwrite a Plugin function
- References:
- [EP-tech] Overwrite a Plugin function
- From: Yuri <yurj@alfa.it>
- Re: [EP-tech] Overwrite a Plugin function
- From: Christopher Gutteridge <totl@soton.ac.uk>
- [EP-tech] Overwrite a Plugin function
- Prev by Date: [EP-tech] Overwrite a Plugin function
- Next by Date: Re: [EP-tech] Overwrite a Plugin function
- Previous by thread: [EP-tech] Sort view with creators_name and corp_creators
- Index(es):