EPrints Technical Mailing List Archive
See the EPrints wiki for instructions on how to join this mailing list and related information.
Message: #06325
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
Re: [EP-tech] Easier way to do this in a citation?
- To: "eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>
- Subject: Re: [EP-tech] Easier way to do this in a citation?
- From: John Salter <J.Salter@leeds.ac.uk>
- Date: Fri, 3 Mar 2017 15:57:54 +0000
Hi Andrew, 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: <choose> <when test="event_title and event_location and event_dates"> <print expr="event_title" />, <print expr="event_location"/>, <print expr="event_dates"/>. </when> <when test="event_title and event_location"> <print expr="event_title" />, <print expr="event_location"/>. </when> <when test="event_title "> <print expr="event_title" />. </when> </choose> 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! Cheers, John From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk]
On Behalf Of Andrew Collington Hi all, 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)"> <print expr="event_title"/> </if> <if test="event_location"> <if test="is_set(event_title)">, </if> <print expr="event_location"/> </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, Andy -- |
- References:
- [EP-tech] Easier way to do this in a citation?
- From: Andrew Collington <a.p.collington@sussex.ac.uk>
- [EP-tech] Easier way to do this in a citation?
- Prev by Date: [EP-tech] Easier way to do this in a citation?
- Next by Date: Re: [EP-tech] Easier way to do this in a citation?
- Previous by thread: [EP-tech] Easier way to do this in a citation?
- Next by thread: Re: [EP-tech] Easier way to do this in a citation?
- Index(es):