[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[EP-tech] Overwrite a Plugin function
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 = "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Forcid.org%2F%24value&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dXpcOGe8tdHnLcAWZgokbElFUzZkFjqLAmxLLvv4yGQ%3D&reserved=0
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 = "https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Forcid.org%2F%24value&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oELWXua9pWXyGZhPR%2FrPGDNPcF0vSqKAKc0XcdmNbkU%3D&reserved=0";
??????? 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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Forcid.org%2F%24value&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oELWXua9pWXyGZhPR%2FrPGDNPcF0vSqKAKc0XcdmNbkU%3D&reserved=0" ) );
??????? return $link;
}
1;
On 02/09/2022 10:38, Yuri via Eprints-tech wrote:
> 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 = "https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Forcid.org%2F%24value&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dXpcOGe8tdHnLcAWZgokbElFUzZkFjqLAmxLLvv4yGQ%3D&reserved=0
>
> 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:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Fne%2BgAES5mGRq4%2FdlVRDHBnGTzrOx%2FD3QgRbGQuG%2F6k%3D&reserved=0
> *** EPrints community wiki:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EqeJOJ3rv2OEoIZr1UORV4a%2FwKDfScxHzX5aokCyi4c%3D&reserved=0
--
Christopher Gutteridge <totl at soton.ac.uk>
You should read our team blog at http://blog.soton.ac.uk/webteam/
Industrial Action
Sadly my trade union is currently in dispute over pay, pensions and
casualisation. You can read more at
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ucu.org.uk%2Farticle%2F11896%2FWhy-were-taking-action&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Ca0192c3ea0c24d983a3d08da8cca73a2%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637977098389798411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Z%2B0rvQDlX4a%2FtgeWXkUdHWhUwgbBD%2BHWJq6HhFR6SL4%3D&reserved=0
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20220902/a1f5d2a6/attachment-0001.html