<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.pl-c
        {mso-style-name:pl-c;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi Andrew,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">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!).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">You could alter your existing code to make the tests clearer:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><choose><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"> <when test="event_title and event_location and event_dates"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"> <print expr="event_title" />, <print expr="event_location"/>, <print expr="event_dates"/>.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"></when><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><when test="event_title and event_location"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"> <print expr="event_title" />, <print expr="event_location"/>.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"></when><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><when test="event_title "><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"> <print expr="event_title" />.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"></when><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"></choose><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">But this does feel a bit noisy too.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">To add (inject) a custom method to EPrints::Script::Compiled, see the example here:
<a href="https://wiki.eprints.org/w/ORCID#Rendering_the_ORCID_in_a_citation">https://wiki.eprints.org/w/ORCID#Rendering_the_ORCID_in_a_citation</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">This keeps the added code in the repository config - and should work over upgrades (unless there's a major rewrite of EPrints::Script).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">In my opinion, any files in <eprints_root>/archives/<archiveid>/cfg/cfg.d/ should be checked as part of an upgrade.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">For a similar example, in White Rose Research Online, we wanted to render event dates in a more 'friendly' human way.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">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'.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">This <a href="https://gist.github.com/jesusbagpuss/491086533294f864de63115c66719def">
https://gist.github.com/jesusbagpuss/491086533294f864de63115c66719def</a> adds a method to EPrints::Script::Compiled that does this conversion. The citation uses:<o:p></o:p></span></p>
<p class="MsoNormal"><span class="pl-c"><if test="event_dates"><print expr="wrro_human_event_dates(event_dates)"/></if><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Hope that helps!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">John<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-fareast-language:EN-GB"> eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk]
<b>On Behalf Of </b>Andrew Collington<br>
<b>Sent:</b> 03 March 2017 13:49<br>
<b>To:</b> eprints-tech@ecs.soton.ac.uk<br>
<b>Subject:</b> [EP-tech] Easier way to do this in a citation?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><if test="is_set(event_title)"><o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt"><print expr="event_title"/><o:p></o:p></p>
<p class="MsoNormal"></if><o:p></o:p></p>
<p class="MsoNormal"><if test="event_location"><o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt"><if test="is_set(event_title)">, </if><o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt"><print expr="event_location"/><o:p></o:p></p>
<p class="MsoNormal"></if><o:p></o:p></p>
<p class="MsoNormal"><if test="is_set(event_dates)">, <print expr="event_dates"/></if><o:p></o:p></p>
<p class="MsoNormal"><if test="is_set(event_title) or is_set(event_location) or is_set(event_dates)">.</if><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Many thanks for any advice,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Andy<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-GB">-- <br>
Andrew Collington<br>
Web Programmer, ITS Client Services<br>
ITS-CS Shawcross, University of Sussex, Falmer, Brighton, BN1 9QT<br>
<br>
T: (01273) 872591 (ext. 2591)<br>
E: <a href="mailto:a.p.collington@sussex.ac.uk"><span style="color:blue">a.p.collington@sussex.ac.uk</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>