Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIR-1409 Allow to customize badges/icons in search results #1084

Draft
wants to merge 3 commits into
base: 2023.06.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mir-module/src/main/resources/config/mir/mycore.properties
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ MCR.URIResolver.xslIncludes.mods=%MCR.URIResolver.xslIncludes.mods%,mods2mods-cl
MCR.URIResolver.xslIncludes.mycoreobjectXML=%MCR.URIResolver.xslIncludes.mycoreobjectXML%,embargofilter.xsl
MCR.URIResolver.xslIncludes.RDF-mods-journal=%MCR.URIResolver.xslIncludes.RDF-mods-journal%,RDF-mods-journal-mir.xsl
MCR.URIResolver.xslIncludes.solrResponse=%MCR.URIResolver.xslIncludes.solrResponse%,response-mir.xsl
MCR.URIResolver.xslIncludes.solrResponseBadges=response-mir-hit-oa.xsl,response-mir-hit-type.xsl,response-mir-hit-licence.xsl,response-mir-hit-date.xsl,response-mir-hit-state.xsl
MCR.URIResolver.xslIncludes.xeditorTemplates=%MCR.URIResolver.xslIncludes.xeditorTemplates%,xeditor-mir-templates.xsl
MIR.AVPlayer.Stylesheet=metadata/mir-video.js.xsl
MCR.URIResolver.xslImports.modsmeta=metadata/mods-metadata-base.xsl,metadata/mir-browse.xsl,metadata/mir-breadcrumbs.xsl,metadata/mir-metadata-box.xsl,metadata/mir-admindata-box.xsl,metadata/mir-abstract.xsl,metadata/mir-collapse-files.xsl,metadata/mir-file-upload.xsl,metadata/mir-edit.xsl,metadata/mir-share.xsl,%MIR.AVPlayer.Stylesheet%,metadata/mir-viewer.xsl,metadata/mir-citation.xsl,metadata/mir-thumbnail.xsl,metadata/mir-export.xsl,metadata/mir-history.xsl,metadata/mir-epusta.xsl,metadata/mir-workflow.xsl
Expand Down
15 changes: 15 additions & 0 deletions mir-module/src/main/resources/xsl/response-mir-hit-badges.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">

<xsl:include href="xslInclude:solrResponseBadges"/>

<xsl:template name="mir-hit-badges">
<xsl:call-template name="hit-oa"/>
<xsl:call-template name="hit-type"/>
<xsl:call-template name="hit-licence"/>
<xsl:call-template name="hit-date"/>
<xsl:call-template name="hit-state"/>
</xsl:template>
</xsl:stylesheet>
25 changes: 25 additions & 0 deletions mir-module/src/main/resources/xsl/response-mir-hit-date.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">

<xsl:template name="hit-date">
<xsl:if test="str[@name='mods.dateIssued'] or str[@name='mods.dateIssued.host']">
<div class="hit_date">
<xsl:variable name="date">
<xsl:choose>
<xsl:when test="str[@name='mods.dateIssued']">
<xsl:value-of select="str[@name='mods.dateIssued']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="str[@name='mods.dateIssued.host']"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<span class="badge badge-primary">
<xsl:value-of select="$date"/>
</span>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
31 changes: 31 additions & 0 deletions mir-module/src/main/resources/xsl/response-mir-hit-licence.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation"
xmlns:mcrxsl="xalan://org.mycore.common.xml.MCRXMLFunctions"
exclude-result-prefixes="i18n mcrxsl xsl">

<xsl:template name="hit-licence">
<xsl:if test="arr[@name='category.top']/str[contains(text(), 'mir_licenses:')]">
<div class="hit_license">
<span class="badge badge-primary">
<xsl:variable name="accessCondition">
<xsl:value-of
select="substring-after(arr[@name='category.top']/str[contains(text(), 'mir_licenses:')][last()],':')"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($accessCondition, 'rights_reserved')">
<xsl:value-of select="i18n:translate('component.mods.metaData.dictionary.rightsReserved')"/>
</xsl:when>
<xsl:when test="contains($accessCondition, 'oa_nlz')">
<xsl:value-of select="i18n:translate('component.mods.metaData.dictionary.oa_nlz.short')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="mcrxsl:getDisplayName('mir_licenses',$accessCondition)"/>
</xsl:otherwise>
</xsl:choose>
</span>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
31 changes: 31 additions & 0 deletions mir-module/src/main/resources/xsl/response-mir-hit-oa.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation"
exclude-result-prefixes="i18n xsl">

<xsl:template name="hit-oa">
<div class="hit_oa" data-toggle="tooltip">
<xsl:variable name="isOpenAccess" select="bool[@name='worldReadableComplete']='true'"/>

<xsl:choose>
<xsl:when test="$isOpenAccess">
<xsl:attribute name="title">
<xsl:value-of select="i18n:translate('mir.response.openAccess.true')"/>
</xsl:attribute>
<span class="badge badge-success">
<i class="fas fa-unlock-alt" aria-hidden="true"/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="title">
<xsl:value-of select="i18n:translate('mir.response.openAccess.false')"/>
</xsl:attribute>
<span class="badge badge-warning">
<i class="fas fa-lock" aria-hidden="true"/>
</span>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
</xsl:stylesheet>
24 changes: 24 additions & 0 deletions mir-module/src/main/resources/xsl/response-mir-hit-state.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation"
xmlns:mcrxsl="xalan://org.mycore.common.xml.MCRXMLFunctions"
exclude-result-prefixes="i18n mcrxsl xsl">

<xsl:template name="hit-state">
<xsl:if test="not (mcrxsl:isCurrentUserGuestUser())">
<div class="hit_state">
<xsl:variable name="status-i18n">
<!-- template in mir-utils.xsl -->
<xsl:call-template name="get-doc-state-label">
<xsl:with-param name="state-categ-id" select="str[@name='state']"/>
</xsl:call-template>
</xsl:variable>
<span class="badge mir-{str[@name='state']}"
title="{i18n:translate('component.mods.metaData.dictionary.status')}">
<xsl:value-of select="$status-i18n"/>
</span>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
28 changes: 28 additions & 0 deletions mir-module/src/main/resources/xsl/response-mir-hit-type.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mcrxsl="xalan://org.mycore.common.xml.MCRXMLFunctions"
exclude-result-prefixes="mcrxsl xsl">

<xsl:template name="hit-type">
<xsl:choose>
<xsl:when test="arr[@name='mods.genre']">
<xsl:for-each select="arr[@name='mods.genre']/str">
<div class="hit_type">
<span class="badge badge-info">
<xsl:value-of select="mcrxsl:getDisplayName('mir_genres',.)"/>
</span>
</div>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<div class="hit_type">
<span class="badge badge-info">
<xsl:value-of select="mcrxsl:getDisplayName('mir_genres','article')"/>
</span>
</div>
</xsl:otherwise>
</xsl:choose>

</xsl:template>
</xsl:stylesheet>
92 changes: 3 additions & 89 deletions mir-module/src/main/resources/xsl/response-mir.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<xsl:include href="resource:xsl/csl-export-gui.xsl" />
<xsl:include href="resource:xsl/response-facets.xsl"/>
<xsl:include href="resource:xsl/response-mir-hit-badges.xsl"/>
<xsl:include href="resource:xsl/response-mir-utils.xsl" />

<xsl:param name="UserAgent" />
Expand Down Expand Up @@ -541,95 +542,8 @@
<!-- hit type -->
<div class="hit_tnd_container">
<div class="hit_tnd_content">
<div class="hit_oa" data-toggle="tooltip">
<xsl:variable name="isOpenAccess" select="bool[@name='worldReadableComplete']='true'" />
<xsl:choose>
<xsl:when test="$isOpenAccess">
<xsl:attribute name="title">
<xsl:value-of select="i18n:translate('mir.response.openAccess.true')" />
</xsl:attribute>
<span class="badge badge-success">
<i class="fas fa-unlock-alt" aria-hidden="true"></i>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="title">
<xsl:value-of select="i18n:translate('mir.response.openAccess.false')" />
</xsl:attribute>
<span class="badge badge-warning">
<i class="fas fa-lock" aria-hidden="true"></i>
</span>
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:choose>
<xsl:when test="arr[@name='mods.genre']">
<xsl:for-each select="arr[@name='mods.genre']/str">
<div class="hit_type">
<span class="badge badge-info">
<xsl:value-of select="mcrxsl:getDisplayName('mir_genres',.)" ></xsl:value-of>
</span>
</div>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<div class="hit_type">
<span class="badge badge-info">
<xsl:value-of select="mcrxsl:getDisplayName('mir_genres','article')" />
</span>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="arr[@name='category.top']/str[contains(text(), 'mir_licenses:')]">
<div class="hit_license">
<span class="badge badge-primary">
<xsl:variable name="accessCondition">
<xsl:value-of select="substring-after(arr[@name='category.top']/str[contains(text(), 'mir_licenses:')][last()],':')" />
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($accessCondition, 'rights_reserved')">
<xsl:value-of select="i18n:translate('component.mods.metaData.dictionary.rightsReserved')" />
</xsl:when>
<xsl:when test="contains($accessCondition, 'oa_nlz')">
<xsl:value-of select="i18n:translate('component.mods.metaData.dictionary.oa_nlz.short')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="mcrxsl:getDisplayName('mir_licenses',$accessCondition)" />
</xsl:otherwise>
</xsl:choose>
</span>
</div>
</xsl:if>
<xsl:if test="str[@name='mods.dateIssued'] or str[@name='mods.dateIssued.host']">
<div class="hit_date">
<xsl:variable name="date">
<xsl:choose>
<xsl:when test="str[@name='mods.dateIssued']">
<xsl:value-of select="str[@name='mods.dateIssued']" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="str[@name='mods.dateIssued.host']" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<span class="badge badge-primary">
<xsl:value-of select="$date" />
</span>
</div>
</xsl:if>
<xsl:if test="not (mcrxsl:isCurrentUserGuestUser())">
<div class="hit_state">
<xsl:variable name="status-i18n">
<!-- template in mir-utils.xsl -->
<xsl:call-template name="get-doc-state-label">
<xsl:with-param name="state-categ-id" select="str[@name='state']"/>
</xsl:call-template>
</xsl:variable>
<span class="badge mir-{str[@name='state']}" title="{i18n:translate('component.mods.metaData.dictionary.status')}">
<xsl:value-of select="$status-i18n" />
</span>
</div>
</xsl:if>
<xsl:call-template name="mir-hit-badges"/>

<xsl:if test="string-length($MCR.ORCID.OAuth.ClientSecret) &gt; 0">
<div class="orcid-status" data-id="{$identifier}" />
</xsl:if>
Expand Down
Loading