EPrints Technical Mailing List Archive

Message: #09049


< 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


CAUTION: This e-mail originated outside the University of Southampton.

Hi!

 Christopher, we've been all young but I think you've done very well :-)

 For the 3, I have then to disable the orcid plugin (disable->1) and enable OrcidAlfa? I think the 2 is ok (just one repository). Thank you very much for the precious hints!

Il 02/09/22 12:03, Christopher Gutteridge ha scritto:

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="j/ssZpstJZKJvhv/Xx9FVqWa0kRT6GLNCqdcuo4V+j5L8RuMQm/UpPR6AuCwle6XLvF1MO/lsTz47+k/H5ZWggUCPIbOA+XUkitZtobc4uywOQf15RTgtjH6d5YknUgCZLHEtcdNFm4u6jZmA7HvUMbZMCilXKUAohykgwAwH7g=" moz-do-not-send="true">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="iCCS9EUjqUJZI8sknGHIjWN3fESKeuXrNfBjyNgaukRkDosusdHltcEoceTlKHVWLIGVogpCMQRODWKUGHT0f3O6L0yz+vkiNlDw5H2MhhqPlowZg87m2jfT73jE6d9K2l+CoQQVfcCAMCyrarARdYOqqoKfdfwbeqKyeW3mWWg=" moz-do-not-send="true"> "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;


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 = "" class="moz-txt-link-freetext" href="https://eur03.safelinks.protection.outlook.com/?url="" originalSrc="http://orcid.org/$value" shash="j/ssZpstJZKJvhv/Xx9FVqWa0kRT6GLNCqdcuo4V+j5L8RuMQm/UpPR6AuCwle6XLvF1MO/lsTz47+k/H5ZWggUCPIbOA+XUkitZtobc4uywOQf15RTgtjH6d5YknUgCZLHEtcdNFm4u6jZmA7HvUMbZMCilXKUAohykgwAwH7g=" moz-do-not-send="true">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/

Industrial Action

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.