EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #06976


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Adding items to EP-XML template


Add

sub is_feed { return 0; }

Which will keep it as an export plugin but prevent it being in the list of feeds on search and view pages.

On 23/11/2017 11:25, Andrew Beeken wrote:

So! Any ideas how I stop the RSS icon for this feed showing up on browse views? :D

 

From: Andrew Beeken
Sent: 23 November 2017 11:19
To: 'eprints-tech@ecs.soton.ac.uk' <eprints-tech@ecs.soton.ac.uk>
Subject: RE: [EP-tech] Adding items to EP-XML template

 

Thanks for all the replies – changing the RegEx and the date has worked, however there is the issue now that some of our data contains incomplete dates. I’m working on adding in some extra regex checks to pad the dates as necessary and that seems to be effective so far!

 

I’ve got some other bits to clean up on EPrints before 2018 so you may not have heard the last of me 😉 (Not a threat, honest!)

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Andrew Beeken
Sent: 21 November 2017 20:25
To: eprints-tech@ecs.soton.ac.uk; John Salter <j.salter@leeds.ac.uk>; Christopher Gutteridge <cjg@ecs.soton.ac.uk>
Subject: Re: [EP-tech] Adding items to EP-XML template

 

Thanks for responses guys.

I totally agree that this isn't the correct use for this feed but I'll bite my tongue lest I say something unprofessional ;)

My comment about the date was more that this isn't the date we need, rather than it was incorrect for its purpose.

Of course I'll be implementing this in a unique feed! :)

I'll take a look at suggestions tomorrow and let you know how I get on.

On a related note, I'll be moving off EPrints work at the University as of next January following a reshuffle of staff roles. I'll still be here but my focus will be more on library systems development, so some of us may cross paths again in the future. But thanks to everyone on this list for the help and support over the last few years (and beer for those who I've met in person in places like Dublin and Edinburgh!) I won't pretend I've come away knowing everything about EPrints; the code still baffles me on a number of levels which I find frustrating as someone who has coded for a living for 15 years, but I'm thankful for your patience, especially as I've been working on moving our repository to its new home. I'm not sure who at Lincoln will be replacing me on EPrints duty but whoever it is will get a recommended list of names of people to badger ;)

Once again, a massive thanks, I'll let you know how I get on with this feed.

Andrew


From: Christopher Gutteridge <cjg@ecs.soton.ac.uk>
Sent: Tuesday, November 21, 2017 5:01:59 PM
To: eprints-tech@ecs.soton.ac.uk; John Salter; Andrew Beeken
Subject: Re: [EP-tech] Adding items to EP-XML template

 

Yes, what John said :)

By the way, for some of our sites, we use the normal views feature for this. Every /view/ page can have a .include file. eg.

https://eprints.soton.ac.uk/view/people/bf4af598-26bf-47f4-a0a4-800095a23eb5.html

has a matching

https://eprints.soton.ac.uk/view/people/bf4af598-26bf-47f4-a0a4-800095a23eb5.include

with just the HTML of the main bit in. Handy to include elsewhere.

 

On 21/11/2017 16:49, John Salter wrote:

> Both "date" and "datestamp" should be stored in the same format in EPrints:

Ah, Mr. Gutteridge…  close, but no cigar! :o)

 

The 'date' field normally doesn't include the time component - so the regex

/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/

won't match. This should:

/^(\d{4})-(\d{2})-(\d{2})$/

 

*BUT* I'd advise against updating the RSS2 feed to do this. People may be using it in the way it's intended.

I'd subclass the RSS2 feed - adding your new date sorting method.

-OR- configure an author browse view, and use the RSS links embedded in them (or pull in the .include version of the view page).

 

Cheers,

John

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Christopher Gutteridge
Sent: 21 November 2017 16:28
To:
eprints-tech@ecs.soton.ac.uk; Andrew Beeken <anbeeken@lincoln.ac.uk>
Subject: Re: [EP-tech] Adding items to EP-XML template

 

That's the correct behaviour for an RSS feed. I'm guessing the logic of this is that your website has an RSS importer already that makes it the desired route.

Both "date" and "datestamp" should be stored in the same format in EPrints, so you should just have this:

my $datestamp = $eprint->get_value( "date" );

                                if( $datestamp =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/ )

                                {

                                                my $time = timelocal( $6, $5, $4, $3, $2-1, $1 );

                                                $item->appendChild( $session->render_data_element(

                                                                2,

                                                                "pubDate",

                                                                EPrints::Time::rfc822_datetime( $time ) ) );

                                }

So now it's an RSS feed with the dates of the items in the catalogue, rather than of catalogue records.

On 21/11/2017 16:05, Andrew Beeken wrote:

Okay, so the goalposts have shifted on this since talking in more detail with our ICT team!

 

Basically, our repository feeds our staff directory pages in real time using the available feeds; specifically this feed: http://eprints.lincoln.ac.uk/cgi/exportview/creators/userid/RSS2/userid.xml. I did question why the RSS2 feed was being used and received the answer that this particular feed formats up a “Description” which can be pulled straight into the staff profiles which are then ordered based on the date on the record. So far, so good, but the issue at hand is those dates. I initially thought the problem was the format that the dates were coming out in and proposed that we include the records pre-formatted citation in the standard XML feed for them.

 

However, it now transpires that the date on the RSS2 feed is just plain wrong; it’s using the datestamp, when the record was created, rather than the date that the article, book etc was published, as stored in the date field. For the academics this means that the records on their staff profile are not in publication order. So we come back to the decision – use the standard XML file and add the citation, or change the RSS2 template to use the published date rather than the created date. ICT would prefer the latter so that they don’t have to change the staff directory code.

 

I’ve been taking a look at the latter an I think I’ve found the chunk in the RSS2 script that deals with the date:

 

my $datestamp = $eprint->get_value( "datestamp" );

                                if( $datestamp =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/ )

                                {

                                                my $time = timelocal( $6, $5, $4, $3, $2-1, $1 );

                                                $item->appendChild( $session->render_data_element(

                                                                2,

                                                                "pubDate",

                                                                EPrints::Time::rfc822_datetime( $time ) ) );

                                }

 

I tried tweaking this to change datestamp to date, however this completely removed the date from the feed. I’m guessing that this is something to do with how the RegEx decides to proceed on the if statement. So I thought I’d see what happened if I just pushed the date straight into the element which… didn’t work…

 

                                $item->appendChild( $session->render_data_element(

                                                2,

                                                "pubDate",

                                                EPrints::Time::rfc822_datetime( $eprint->get_value( "date" ) ) ) );

 

I’m sure there’s obvious reasons for that which I probably can’t see (I always feel code dyslexic when I look at EPrints source for some reason…) Personally I’d prefer to push the citation in a more capable feed than RSS2 but I think I’m going to be at the behest of the Staff Directory here.

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of John Salter
Sent: 21 November 2017 14:53
To:
eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Adding items to EP-XML template

 

> The XML export just exports all the fields on an object

Unless that field has

    export_as_xml => 0,

 

- like the suggestions field does by default…

 

What are you trying to achieve with your export?

Personally, I'd suggest subclassing that plugin, and adding a citation to it that way - as always, TMTOWTDI!

It depends on how and when you'll be calling the plugin.

 

If it's for active, user-generated requests, Adam's method may be more suitable, as the processing is done when a record is saved, rather than when a record is requested.

 

Cheers,

John

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Adam Field
Sent: 21 November 2017 14:34
To:
eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Adding items to EP-XML template

 

Hi Andrew

 

                The XML export just exports all the fields on an object.  I wouldn’t modify it if I were you.  The simplest way would be to add a new field to your item.

 

                I’m not sure if virtual fields come out in the XML export, but if they do, adding a virtual field to your object may be the easiest way to do this.  Alternatively, use an automatic field and write the citation to it.  See

https://wiki.eprints.org/w/Training_Video:Virtual_Fields and https://wiki.eprints.org/w/Training_Video:Automatic_Fields

 

--

Adam

 

From: <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of Andrew Beeken <anbeeken@lincoln.ac.uk>
Reply-To: <
eprints-tech@ecs.soton.ac.uk>
Date: Tuesday, 21 November 2017 14:24
To: "
eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>
Subject: [EP-tech] Adding items to EP-XML template

 

Hi all,

 

Just took a dive into the EPrints XML export template (perl_lib/EPrints/Plugin/Export/XML.pm) to try and add a node for the records citation to it and I can’t see where you would do this? Is there somewhere separate that defines what data it pulls through?

 

Cheers in advance!

Andrew


Image removed by sender. EF Gold

The University of Lincoln, located in the heart of the city of Lincoln, has established an international reputation based on high student satisfaction, excellent graduate employment and world-class research.


The information in this e-mail and any attachments may be confidential. If you have received this email in error please notify the sender immediately and remove it from your system. Do not disclose the contents to another person or take copies.

Email is not secure and may contain viruses. The University of Lincoln makes every effort to ensure email is sent without viruses, but cannot guarantee this and recommends recipients take appropriate precautions.

The University may monitor email traffic data and content in accordance with its policies and English law. Further information can be found at:
http://www.lincoln.ac.uk/legal.

*** 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/ *** EPrints developers Forum: http://forum.eprints.org/

 

*** 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/
*** EPrints developers Forum: http://forum.eprints.org/

 

-- 
Christopher Gutteridge -- http://users.ecs.soton.ac.uk/cjg
 
University of Southampton Open Data Service: http://data.southampton.ac.uk/
You should read our Web & Data Innovation blog: http://blogs.ecs.soton.ac.uk/webteam/
 

 

*** 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/
*** EPrints developers Forum: http://forum.eprints.org/

 

-- 
Christopher Gutteridge -- http://users.ecs.soton.ac.uk/cjg
 
University of Southampton Open Data Service: http://data.southampton.ac.uk/
You should read our Web & Data Innovation blog: http://blogs.ecs.soton.ac.uk/webteam/
 


*** 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/
*** EPrints developers Forum: http://forum.eprints.org/

-- 
Christopher Gutteridge -- http://users.ecs.soton.ac.uk/cjg

University of Southampton Open Data Service: http://data.southampton.ac.uk/
You should read our Web & Data Innovation blog: http://blogs.ecs.soton.ac.uk/webteam/