Last active
March 4, 2020 04:08
-
-
Save eulereadgbe/52401d5ae1ce290398dd59ae4eaf75f1 to your computer and use it in GitHub Desktop.
Added top 10 most downloaded items to /statistics-home
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:template match="dri:div[@id='aspect.statistics.StatisticsTransformer.div.home' and @n='home']//dri:table[@id='aspect.statistics.StatisticsTransformer.table.list-table' and @rend='tableWithTitle detailtable']"> | |
<xsl:variable name="statsURL" select="confman:getProperty('solr-statistics.server')"/> | |
<xsl:apply-templates select="document(concat($statsURL,'/select?q=type:2+-isBot:true+statistics_type:view&wt=xml&indent=true&facet=true&facet.field=id&facet.sort=count&facet.limit=10'))" mode="most-visited"/> | |
<xsl:apply-templates select="document(concat($statsURL,'/select?q=type:0+-isBot:true+statistics_type:view&wt=xml&indent=true&facet=true&facet.field=owningItem&fq=bundleName:ORIGINAL&facet.sort=count&facet.limit=10'))" mode="most-downloaded"/> | |
</xsl:template> | |
<xsl:template match="/" mode="most-downloaded"> | |
<h3 class="ds-table-head">Total Downloads</h3> | |
<div class="table-responsive"> | |
<table class="ds-table table table-striped table-hover tableWithTitle detailtable"> | |
<tbody> | |
<tr class="ds-table-row"> | |
<th class="ds-table-header-cell labelcell"> </th> | |
<th class="ds-table-header-cell labelcell">Downloads</th> | |
</tr> | |
<xsl:for-each select="/response/lst/lst/lst[@name='owningItem']/int"> | |
<tr class="ds-table-row"> | |
<xsl:variable name="searchURL" select="confman:getProperty('discovery','search.server')"/> | |
<td class="most_downloaded ds-table-cell labelcell"> | |
<xsl:variable name="itemId"> | |
<xsl:value-of select="./@name"/> | |
</xsl:variable> | |
<xsl:apply-templates select="document(concat($searchURL,'/select?q=*:*&fl=title,handle&wt=xml&omitHeader=true&indent=true&fq=search.resourceid:',$itemId))" mode="itemMeta"/> | |
</td> | |
<td class="downloaded_count ds-table-cell labelcell"> | |
<xsl:value-of select="format-number(text(),'#,###')"/> | |
</td> | |
</tr> | |
</xsl:for-each> | |
</tbody> | |
</table> | |
</div> | |
</xsl:template> | |
<xsl:template match="/" mode="most-visited"> | |
<h3 class="ds-table-head">Total Visits</h3> | |
<div class="table-responsive"> | |
<table class="ds-table table table-striped table-hover tableWithTitle detailtable"> | |
<tbody> | |
<tr class="ds-table-row"> | |
<th class="ds-table-header-cell labelcell"> </th> | |
<th class="ds-table-header-cell labelcell">Views</th> | |
</tr> | |
<xsl:for-each select="/response/lst/lst/lst[@name='id']/int"> | |
<tr class="ds-table-row"> | |
<xsl:variable name="searchURL" select="confman:getProperty('discovery','search.server')"/> | |
<td class="most_downloaded ds-table-cell labelcell"> | |
<xsl:variable name="itemId"> | |
<xsl:value-of select="./@name"/> | |
</xsl:variable> | |
<xsl:apply-templates select="document(concat($searchURL,'/select?q=*:*&fl=title,handle&wt=xml&omitHeader=true&indent=true&fq=search.resourceid:',$itemId))" mode="itemMeta"/> | |
</td> | |
<td class="downloaded_count ds-table-cell labelcell"> | |
<xsl:value-of select="format-number(text(),'#,###')"/> | |
</td> | |
</tr> | |
</xsl:for-each> | |
</tbody> | |
</table> | |
</div> | |
</xsl:template> | |
<xsl:template match="/" mode="itemMeta"> | |
<xsl:variable name="mainURL" select="confman:getProperty('dspace.baseUrl')"/> | |
<a> | |
<xsl:attribute name="href"><xsl:value-of select="concat($mainURL,'/handle/',/response/result/doc/str[@name='handle']/text())"/></xsl:attribute> | |
<xsl:for-each select="/response/result/doc/arr[@name='title']/str"> | |
<xsl:value-of select="./text()"/> | |
</xsl:for-each> | |
</a> | |
</xsl:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment