[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[EP-tech] Easier way to do this in a citation?
That helps a huge amount, thanks you so much! This gives me a great base on which to maybe add some functionality of our own and the citation reworking using the choose/when does make it a bit clearer until I do (hopefully) get something written. So many thanks for a very helpful response!
From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of John Salter
Sent: 03 March 2017 15:58
To: eprints-tech at ecs.soton.ac.uk
Subject: Re: [EP-tech] Easier way to do this in a citation?
I don't think there is a easy way to do what you require in the existing epscript functions (but there is a way to add it - more on that below!).
You could alter your existing code to make the tests clearer:
<when test="event_title and event_location and event_dates">
<print expr="event_title" />, <print expr="event_location"/>, <print expr="event_dates"/>.
<when test="event_title and event_location">
<print expr="event_title" />, <print expr="event_location"/>.
<when test="event_title ">
<print expr="event_title" />.
But this does feel a bit noisy too.
To add (inject) a custom method to EPrints::Script::Compiled, see the example here: https://wiki.eprints.org/w/ORCID#Rendering_the_ORCID_in_a_citation
This keeps the added code in the repository config - and should work over upgrades (unless there's a major rewrite of EPrints::Script).
In my opinion, any files in <eprints_root>/archives/<archiveid>/cfg/cfg.d/ should be checked as part of an upgrade.
For a similar example, in White Rose Research Online, we wanted to render event dates in a more 'friendly' human way.
They are stored in the database as 'yyyy-mm-dd - yyyy-mm-dd' (or just yyyy-mm-dd if it was a one-day event), and we wanted e.g. '1-3 Mar 2017' '28 Feb - 1 Mar 2017' or '31 Dec 2016 - 2 Jan 2017'.
This https://gist.github.com/jesusbagpuss/491086533294f864de63115c66719def adds a method to EPrints::Script::Compiled that does this conversion. The citation uses:
<if test="event_dates"><print expr="wrro_human_event_dates(event_dates)"/></if>
Hope that helps!
From: eprints-tech-bounces at ecs.soton.ac.uk<mailto:eprints-tech-bounces at ecs.soton.ac.uk> [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Andrew Collington
Sent: 03 March 2017 13:49
To: eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>
Subject: [EP-tech] Easier way to do this in a citation?
I've recently had to add a few new rules in a citation for a conference proceeding. At the moment I have a number of checks that look something like this:
<if test="is_set(event_title)">, </if>
<if test="is_set(event_dates)">, <print expr="event_dates"/></if>
<if test="is_set(event_title) or is_set(event_location) or is_set(event_dates)">.</if>
So it'll only add a comma before the location if the title is supplied, etc. and the full-stop at the end if any event details are shown. But, well, as you can see it's a pretty messy way to do things and wondered if there were something a little more streamlined available that would allow you to supply a list of fields and it'll then automatically put commas between values if the values are there and a full-stop at the end if needs be? I'm only trying to do this with cite tags in citations/eprints/default.xml.
I did see a 'pretty_list' function in Compiled.pm that looks like it may do something like what I want, but despite trying I didn't see how I could pull this into a citation nor could I find any documentation on the subject. Is that possible?
If this kind of functionality doesn't already exist, then what's the best course of action to adding new types of actions to cite tags? Is it possible to create my own class do add extra actions, or should I update existing modules? (which seems like a bad idea if ever wanting to upgrade). Is there any documentation about doing this kind of thing?
Many thanks for any advice,
Web Programmer, ITS Client Services
ITS-CS Shawcross, University of Sussex, Falmer, Brighton, BN1 9QT
T: (01273) 872591 (ext. 2591)
E: a.p.collington at sussex.ac.uk<mailto:a.p.collington at sussex.ac.uk>
-------------- next part --------------
An HTML attachment was scrubbed...