EPrints Technical Mailing List Archive

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

Message: #05819


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

Re: [EP-tech] Citations and covers


Dear all,

this is how I've solved the issue, and I hope I'll help somebody else too. This is my eprint citation:

<?xml version="1.0" ?>
    <cite:citation xmlns="http://www.w3.org/1999/xhtml" xmlns:cite="" href="http://eprints.org/ep3/citation">http://eprints.org/ep3/citation" xmlns:epc="http://eprints.org/ep3/control">
        <epc:set name='docs' expr='$item.original_documents()'>
            <epc:if test="length($docs) gt 0">
                <epc:foreach expr="$docs" iterator="doc" limit="1">
                    <div class="col-md-3">
                        <div class="thumbnail">
                            <epc:set name='covers' expr='$item.cover_image()'>
                                <epc:if test="length($covers) gt 0">
                                    <epc:foreach expr="$covers" iterator="cover" limit="1">
                                        <cite:linkhere><img src="" class="img-rounded img-responsive" /> </cite:linkhere>
                                    </epc:foreach>
                                </epc:if>
                                <epc:if test="length($covers) gt 0">
                                    <cite:linkhere><img src="" class="img-rounded img-responsive" /> </cite:linkhere>
                                </epc:if>
                            </epc:set>
                            <div class="caption">
                                <epc:choose>
                                    <epc:when test="type = 'article'"> <i class="fa fa-paperclip" aria-hidden="true"> Document </i> </epc:when>
                                    <epc:when test="type = 'audio'"> <i class="fa fa-music" aria-hidden="true"> Audio</i>  </epc:when>
                                    <epc:when test="type = 'book'"> <i class="fa fa-book" aria-hidden="true"> Book</i>  </epc:when>
                                    <epc:when test="type = 'image'"> <i class="fa fa-picture-o" aria-hidden="true"> Image</i>  </epc:when>
                                    <epc:when test="type = 'video'"> <i class="fa fa-video-camera" aria-hidden="true"> Video</i>  </epc:when>
                                    <epc:otherwise> <i class="fa fa-file-archive-o" aria-hidden="true"> Archive </i> </epc:otherwise>
                                </epc:choose>
                                <epc:choose>
                                    <epc:when test="strlen(title) gt 80">
                                        <h3><cite:linkhere><epc:print expr="substr(title,0,70)" />...</cite:linkhere></h3> </epc:when>
                                    <epc:otherwise>
                                        <h3><cite:linkhere><epc:print expr="title" /></cite:linkhere></h3> </epc:otherwise>
                                </epc:choose>
                                <epc:if test="is_set(date)">
                                    <epc:print expr="substr(date.as_string(),0,4)" /></epc:if>
                                <epc:if test="is_set(creators_name)">
                                    <epc:choose>
                                        <epc:when test="length(creators_name) gt 0">
                                            <epc:set name="creators" expr="creators_name" limit="1">
                                                <epc:foreach expr="$creators" iterator="creator">
                                                    <epc:print expr="$creator" /> </epc:foreach>
                                            </epc:set>
                                        </epc:when>
                                    </epc:choose>
                                </epc:if>
                            </div>
                        </div>
                    </div>
                </epc:foreach>
            </epc:if>
        </epc:set>
    </cite:citation>


as you can see I use two procedures, that I created in document_fields.pl

{
package EPrints::Script::Compiled;

    sub run_original_documents {
        my( $self, $state, $eprint ) = @_;
        if( ! $eprint->[0]->isa( "EPrints::DataObj::EPrint") ) {
            $self->runtime_error( "documents() must be called on an eprint object." );
        }
        return [ [grep { $_->is_set( "content" ) && $_->value( "content" ) eq "original" } $eprint->[0]->get_all_documents()],  "ARRAY" ];
    };
    sub run_cover_image {
        my( $self, $state, $eprint ) = @_;
        if( ! $eprint->[0]->isa( "EPrints::DataObj::EPrint") ) {
            $self->runtime_error( "cover_image() must be called on an eprint object." );
        }
        return [ [grep { $_->is_set( "content" ) && $_->value( "content" ) eq "coverimage" } $eprint->[0]->get_all_documents()],  "ARRAY" ];
    }
}

The first one give me the array with the original documents, the second one the covers. Logically you should have one cover, but with users you never know :)

Thanks,
Denis


On Fri, Jul 8, 2016 at 5:34 PM, Denis Pitzalis <denis.pitzalis@gmail.com> wrote:
Hi eprinters,

I am uploading audio to my repository as eprints. Each eprints comes with 2 documents:
1) the audio file, content: original
2) the cover, content: cover

then in my summary, I have:

<epc:set name='docs' expr='$item.original_documents()'>
                    <!--<epc:set name='docs' expr='$item.documents()'>-->
                    <epc:if test="length($docs) gt 0">
                        <epc:foreach expr="$docs" iterator="doc" limit="1">
                            <div id="summary_downloads" class="summary-widget">
                                <epc:choose>
.....
                                <epc:when test="$doc.thumbnail_url('audio_mp4').is_set()">
                                        <audio controls="">
                                            <source src="" type="audio/mp4" />
                                            <source src="" type="audio/ogg" />
                                            <p class="vjs-no-js">
                                                <epc:phrase ref='summary_page:vjs-no-js' />
                                            </p>
                                        </audio>
                                    </epc:when>

which is working fine, but I would like to show the cover image with the audio. How can I access it?

Best regards,
Denis

*** 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/




--