[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Re: Antwort: Re: Antwort: inserting irstats on abstract/detail page



Martin, is this script can be put on archives/{repo}/cfg/cfg.d/
eprint_render.pl file? I already try this script on eprint_render.pl and
running generate_static, and then show error.

Thank you
Agung

On Fri, Dec 5, 2014 at 4:26 PM, <martin.braendle at id.uzh.ch> wrote:

> I think the solution that Yuri presented is for IRStats1.
>
> We use the following code snippet for IRStats2 (compare with
> http://www.zora.uzh.ch/84125/ ):
>
>              # Downloads column
>  # UZH CHANGE 2014/11/13/mb - ZORA-379: show download stats only if there
> are documents
>  if ( $docs_to_show > 0 ) {
>  $td = $session->make_element( "td",
>  valign=>"top" );
>  my $downloads_title = $session->make_element( "h2" );
>  $downloads_title->appendChild(
>  $session->html_phrase( "page:downloads_title" ) );
>  $td->appendChild( $downloads_title );
>
>  my $stats_div = $session->make_element( "div",
>  style=>"margin-left: 10px; margin-right: 10px;"
>  );
>
>  my $repo = $session->get_repository;
>  my $eprintid = $eprint->id;
>  my $handler = $repo->plugin( "Stats::Handler" );
>
>  # get total downloads count
>  my $context = $handler->context({
>  datatype => "downloads",
>  set_name => "eprint",
>  set_value => $eprintid
>  });
>  my $total_downloads = $handler->data( $context )->select->sum_all;
>
>  $stats_div->appendChild( $session->make_text( $total_downloads ) );
>  $stats_div->appendChild( $session->make_text( " " ) );
>
>  if ( $total_downloads == 1 )
>  {
>  $stats_div->appendChild(
>  $session->html_phrase( "page:downloads_1" ) );
>  }
>  else
>  {
>  $stats_div->appendChild(
>  $session->html_phrase( "page:downloads_n" ) );
>  }
>
>  $stats_div->appendChild( $session->make_text( " " ) );
>  $stats_div->appendChild(
>  $session->html_phrase( "page:deposited" ) );
>  $stats_div->appendChild( $session->make_text( " " ) );
>  my $deposit_date = $eprint->get_value( "datestamp" );
>  my ( $d_year, $d_month, $d_day ) = EPrints::Time::split_value(
> $deposit_date );
>  $deposit_date = EPrints::Time::join_value( ( $d_year, $d_month, $d_day)
> );
>
>  $stats_div->appendChild( EPrints::Time::render_short_date( $repo,
> $deposit_date ) );
>
>  $stats_div->appendChild( $session->make_element( "br") );
>
>  # get last 12 months downloads count
>  $context = $handler->context({
>  datatype => "downloads",
>  set_name => "eprint",
>  set_value => $eprintid,
>  range => "12m"
>  });
>  my $last12m_downloads = $handler->data( $context )->select->sum_all;
>  $stats_div->appendChild( $session->make_text( $last12m_downloads ) );
>
>  $stats_div->appendChild( $session->make_text( " " ) );
>
>  if ( $last12m_downloads == 1 )
>  {
>  $stats_div->appendChild(
>  $session->html_phrase( "page:downloads_1" ) );
>  }
>  else
>  {
>  $stats_div->appendChild(
>  $session->html_phrase( "page:downloads_n" ) );
>  }
>  $stats_div->appendChild( $session->make_text( " " ) );
>  $stats_div->appendChild(
>  $session->html_phrase( "page:12m" ) );
>
>  # display link to detailed statistics if there are downloads
>  if ($total_downloads > 0)
>  {
>  $stats_div->appendChild( $session->make_element( "br") );
>  $stats_div->appendChild( $session->make_element( "br") );
>
>  my $stats_uri = "/cgi/stats/report/eprint/" . $eprint->id;
>  my $stats_link = $session->make_element( "a",
>  href   => $stats_uri,
>  );
>  $stats_link->appendChild(  $session->html_phrase( "page:detail_stats" ) );
>         $stats_div->appendChild( $stats_link );
>  }
>
>  $td->appendChild( $stats_div );
>  $tr->appendChild( $td );
>  }
>
>
> Best regards,
>
> Martin
>
>
> --
> Dr. Martin Br?ndle
> Zentrale Informatik
> Universit?t Z?rich
> Winterthurerstr. 190
> CH-8057 Z?rich
>
> mail: martin.braendle at id.uzh.ch
> phone: +41 44 63 56705
> fax: +41 44 63 54505
> http://www.id.uzh.ch
>
> [image: Inactive hide details for Yuri ---05/12/2014 09:50:33---Add this:
> $page->appendChild( $session->make_element( "a", name =>]Yuri
> ---05/12/2014 09:50:33---Add this:     $page->appendChild(
> $session->make_element( "a", name => "stat" ) );
>
> Von: Yuri <yurj at alfa.it>
> An: eprints-tech at ecs.soton.ac.uk
> Datum: 05/12/2014 09:50
> Betreff: [EP-tech] Re: Antwort: inserting irstats on abstract/detail page
> Gesendet von: eprints-tech-bounces at ecs.soton.ac.uk
> ------------------------------
>
>
>
> Add this:
>
>    $page->appendChild( $session->make_element( "a", name => "stat" ) );
>    my $irstats = $session->make_element( "div", class=>"ep_block_left");
>    my $irstatsLastMonthLink =
> "/irstats.cgi?page=last_month&set=eprint_" . $eprint->get_value(
> "eprintid" );
>    my $irstatsLastMonthImg = $session->make_element( "img",
> src=>$irstatsLastMonthLink );
>    my $irstatsLastYearLink = "/irstats.cgi?page=last_year&set=eprint_"
> . $eprint->get_value( "eprintid" );
>    my $irstatsLastYearImg = $session->make_element( "img",
> src=>$irstatsLastYearLink );
>    $irstats->appendChild( $session->html_phrase(
>              "page:irstats",
>              img_last_month => $irstatsLastMonthImg,
>              img_last_year => $irstatsLastYearImg ) );
>    $page->appendChild( $irstats );
>
> with
>
>
>     <epp:phrase id="page:irstats"><h2>Download statistics</h2>
>
> in phrases
>
> these are 2 images, generated by irstats cgi, one last month an one last
> year, for the current eprint.
>
> Basically, use $eprint->get_value( "eprintid" ) to get the eprint id,
> for the link, go to /irstats.cgi and play around to find urls and
> parameters.
>
> Plus, this code adds an anchor #stat so you can link or go directly to
> stats (it is handy to have such a link at the begin of the abstract,
> expecially when the eprint abstract is very long).
>
> Il 05/12/2014 05:11, Ajunk Pracetio ha scritto:
> > I already open archives/{repo}/cfg/cfg.d/eprint_render.pl
> > <http://eprint_render.pl> and at bottom page, there is a code like this
> :
> >  # IRSTATS CODE STARTS HERE
> >                 if
> > ($repository->get_repository->can_call('irstats_abstract_content'))
> >                 {
> >
> $page->appendChild($repository->get_repository->call('irstats_abstract_content',
>
> > $repository, $eprint));
> >                 }
> >                 # END IRSTATS
> >
> > But, when I removed the # and run generate, there nothing graph except
> > text "Document Downloads".
> > Is it okay if I insert this script at that line :
> > <div id="mytable" class="irstats_table"/>
> >
> > <script type="text/javascript">
> > document.observe( "dom:loaded", function() {
> >
> >          new EPJS_Stats_Table( {
> >                  'context': { 'datatype': 'downloads' },
> >                  'options': { 'container_id': 'mytable', 'top':
> 'eprint', 'view': 'Table', 'limit': '5' }
> >          } );
> >
> > });
> > </script>
> >
> > I'm don't know about perl :(
> >
> > Any help very appreciate.
> >
> > Thank you
> > Best regards
> > Agung
> >
> >
> > On Fri, Nov 28, 2014 at 1:41 PM, <martin.braendle at id.uzh.ch
> > <mailto:martin.braendle at id.uzh.ch <martin.braendle at id.uzh.ch>>> wrote:
> >
> >     Hi,
> >
> >     the abstract/detail page is rendered by
> >     archives/{repo}/cfg/cfg.d/eprint_render.pl <http://eprint_render.pl>
> >
> >     http://eprints.github.io/irstats2/api.html describes the functions
> >     to obtain statistics data and gives some examples.
> >
> >     Best regards,
> >
> >     Martin
> >
> >     --
> >     Dr. Martin Br?ndle
> >     Zentrale Informatik
> >     Universit?t Z?rich
> >     Winterthurerstr. 190
> >     CH-8057 Z?rich
> >
> >     mail: martin.braendle at id.uzh.ch <mailto:martin.braendle at id.uzh.ch
> <martin.braendle at id.uzh.ch>>
> >     phone: +41 44 63 56705
> >     fax: +41 44 63 54505
> >     http://www.id.uzh.ch
> >
> >     Inactive hide details for Ajunk Pracetio ---28/11/2014
> >     04:43:23---Hi, I'd like to insert irstats on abstract/detail page.
> >     Is thAjunk Pracetio ---28/11/2014 04:43:23---Hi, I'd like to
> >     insert irstats on abstract/detail page. Is there any guide hoq
> >
> >     Von: Ajunk Pracetio <prazetyo at gmail.com <mailto:prazetyo at gmail.com
> <prazetyo at gmail.com>>>
> >     An: "eprints-tech at ecs.soton.ac.uk
> >     <mailto:eprints-tech at ecs.soton.ac.uk <eprints-tech at ecs.soton.ac.uk>
> >"
> >     <eprints-tech at ecs.soton.ac.uk <mailto:eprints-tech at ecs.soton.ac.uk
> <eprints-tech at ecs.soton.ac.uk>>>
> >     Datum: 28/11/2014 04:43
> >     Betreff: [EP-tech]  inserting irstats on abstract/detail page
> >     Gesendet von: eprints-tech-bounces at ecs.soton.ac.uk
> >     <mailto:eprints-tech-bounces at ecs.soton.ac.uk
> <eprints-tech-bounces at ecs.soton.ac.uk>>
> >
> >
> ------------------------------------------------------------------------
>
> >
> >
> >
> >     Hi,
> >
> >     I'd like to insert irstats on abstract/detail page. Is there any
> >     guide hoq to make it?
> >
> >     Thank you
> >
> >     Best Regards,
> >     Agung P.W
> >
> >     --
> >     Life isn't valuable if you don't have someone to care*** 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/
> >
> >
> >
> >
> > --
> > Life isn't valuable if you don't have someone to care
> >
> >
> > *** 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/
>
>
> *** 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/
>
>


-- 
Life isn't valuable if you don't have someone to care
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20141209/8ba3a4ec/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20141209/8ba3a4ec/attachment-0001.gif