Difference between revisions of "SUNScholar/Altmetrics/5.X"

From Libopedia
Jump to navigation Jump to search
Line 231: Line 231:
 
</pre>
 
</pre>
  
==Step X==
+
==Step 4==
 
Then [[SUNScholar/Rebuild_DSpace|rebuild DSpace]].
 
Then [[SUNScholar/Rebuild_DSpace|rebuild DSpace]].

Revision as of 12:15, 10 June 2015

BACK TO ALTMETRICS

Step 1

Edit the following file:

nano $HOME/source/dspace/config/modules/altmetrics.cfg

Modify as need.

See example below.

#---------------------------------------------------------------#
#-----------IMPACT METRICS DISPLAY CONFIGURATIONS---------------#
#---------------------------------------------------------------#
# Configuration properties used by impact metrics badges        #
#---------------------------------------------------------------#
 
# Metadata field which contains the interesting identifiers
altmetrics.field = dc.identifier.uri

#---------------------------------------------------------------#
# Configure altmetric.com badges.                               #
# See http://api.altmetric.com/embeds.html                      #
#---------------------------------------------------------------#

# Is the Altmetric.com badge enabled?
altmetric.enabled = true

# Possible values: donut medium-donut large-donut 1 4
altmetric.badgeType = donut

# Possible values: left right top bottom
#altmetric.popover =

# Possible values: right
#altmetric.details =

# Possible values: true
#altmetric.noScore = 

# Possible values: true
#altmetric.hideNoMentions =

# e.g. _blank
#altmetric.linkTarget =


#---------------------------------------------------------------#
# Configure PlumX Artifact widgets.                             #
# See https://plu.mx/pitt/developers/widgets                    #
#---------------------------------------------------------------#

# Is the PlumX Artifact widget enabled?
plumx.enabled = true

# Possible values: popup summary details
plumx.widget-type = popup

# Used with widget types: popup
# Possible values: top bottom left right
#plumx.data-popup = left

# Used with widget types: popup summary details
# Possible values: true false
#plumx.data-hide-when-empty = true

# Used with widget types: summary details
# Possible values: true false
#plumx.data-hide-print = false

# Used with widget types: summary
# Possible values: vertical horizontal
#plumx.data-orientation = vertical

# Used with widget types: details
# Possible values: any positive integer
#plumx.data-width = 

# Used with widget types: details
# Possible values: true false
#plumx.data-border = false

Step 2

Normally this step would be the rebuild of DSpace, however in DSpace 5.2 no provision was made for Altmetrics to be rendered in the new Mirage 2 theme.

So we continue and enable Altmetrics in the XMLUI Mirage 2 theme.

Edit the following file:

nano $HOME/source/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl

Directly after the <xsl:template name="itemSummaryView-DIM"> on line 42, add the following. Make sure to indent correctly.

        <!-- optional: Altmeric.com badge and PlumX widget -->
        <xsl:if test='confman:getProperty("altmetrics", "altmetric.enabled") and ($identifier_doi or $identifier_handle)'>
            <xsl:call-template name='impact-altmetric'/>
        </xsl:if>
        <xsl:if test='confman:getProperty("altmetrics", "plumx.enabled") and $identifier_doi'>
            <xsl:call-template name='impact-plumx'/>
        </xsl:if>

Now we have to insert the templates called above. Go to the very end of the file and before the last </xsl:stylesheet> closing tag, and insert the following:

    <xsl:template name='impact-altmetric'>
        <div id='impact-altmetric'>
            <!-- Altmetric.com -->
            <script type="text/javascript" src="{concat($scheme, 'd1bxh8uas1mnw7.cloudfront.net/assets/embed.js')}">
            </script>
            <div id='altmetric'
                 class='altmetric-embed'>
                <xsl:variable name='badge_type' select='confman:getProperty("altmetrics", "altmetric.badgeType")'/>
                <xsl:if test='boolean($badge_type)'>
                    <xsl:attribute name='data-badge-type'><xsl:value-of select='$badge_type'/></xsl:attribute>
                </xsl:if>

                <xsl:variable name='badge_popover' select='confman:getProperty("altmetrics", "altmetric.popover")'/>
                <xsl:if test='$badge_popover'>
                    <xsl:attribute name='data-badge-popover'><xsl:value-of select='$badge_popover'/></xsl:attribute>
                </xsl:if>

                <xsl:variable name='badge_details' select='confman:getProperty("altmetrics", "altmetric.details")'/>
                <xsl:if test='$badge_details'>
                    <xsl:attribute name='data-badge-details'><xsl:value-of select='$badge_details'/></xsl:attribute>
                </xsl:if>

                <xsl:variable name='no_score' select='confman:getProperty("altmetrics", "altmetric.noScore")'/>
                <xsl:if test='$no_score'>
                    <xsl:attribute name='data-no-score'><xsl:value-of select='$no_score'/></xsl:attribute>
                </xsl:if>

                <xsl:if test='confman:getProperty("altmetrics", "altmetric.hideNoMentions")'>
                    <xsl:attribute name='data-hide-no-mentions'>true</xsl:attribute>
                </xsl:if>

                <xsl:variable name='link_target' select='confman:getProperty("altmetrics", "altmetric.linkTarget")'/>
                <xsl:if test='$link_target'>
                    <xsl:attribute name='data-link-target'><xsl:value-of select='$link_target'/></xsl:attribute>
                </xsl:if>

                <xsl:choose>    <!-- data-doi data-handle data-arxiv-id data-pmid -->
                    <xsl:when test='$identifier_doi'>
                        <xsl:attribute name='data-doi'><xsl:value-of select='$identifier_doi'/></xsl:attribute>
                    </xsl:when>
                    <xsl:when test='$identifier_handle'>
                        <xsl:attribute name='data-handle'><xsl:value-of select='$identifier_handle'/></xsl:attribute>
                    </xsl:when>
                </xsl:choose>
                
            </div>
        </div>
    </xsl:template>

    <xsl:template name="impact-plumx">
        <div id="impact-plumx" style="clear:right">
            <!-- PlumX <http://plu.mx> -->
            <xsl:variable name="plumx_type" select="confman:getProperty('altmetrics', 'plumx.widget-type')"/>
            <xsl:variable name="plumx-script-url">
                <xsl:choose>
                    <xsl:when test="boolean($plumx_type)">
                        <xsl:value-of select="concat($scheme, 'd39af2mgp1pqhg.cloudfront.net/widget-', $plumx_type, '.js')"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="concat($scheme, 'd39af2mgp1pqhg.cloudfront.net/widget-popup.js')"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>

            <script type="text/javascript" src="{$plumx-script-url}">
            </script>

            <xsl:variable name="plumx-class">
                <xsl:choose>
                    <xsl:when test="boolean($plumx_type) and ($plumx_type != 'popup')">
                        <xsl:value-of select="concat('plumx-', $plumx_type)"/>
                    </xsl:when>
                    <xsl:otherwise>plumx-plum-print-popup</xsl:otherwise>
                </xsl:choose>
            </xsl:variable>

            <a>
                <xsl:attribute name="id">plumx</xsl:attribute>
                <xsl:attribute name="class"><xsl:value-of select="$plumx-class"/></xsl:attribute>
                <xsl:attribute name="href">https://plu.mx/pitt/a/?doi=<xsl:value-of select="$identifier_doi"/></xsl:attribute>

                <xsl:variable name="plumx_data-popup" select="confman:getProperty('altmetrics', 'plumx.data-popup')"/>
                <xsl:if test="$plumx_data-popup">
                    <xsl:attribute name="data-popup"><xsl:value-of select="$plumx_data-popup"/></xsl:attribute>
                </xsl:if>

                <xsl:if test="confman:getProperty('altmetrics', 'plumx.data-hide-when-empty')">
                    <xsl:attribute name="data-hide-when-empty">true</xsl:attribute>
                </xsl:if>

                <xsl:if test="confman:getProperty('altmetrics', 'plumx.data-hide-print')">
                    <xsl:attribute name="data-hide-print">true</xsl:attribute>
                </xsl:if>

                <xsl:variable name="plumx_data-orientation" select="confman:getProperty('altmetrics', 'plumx.data-orientation')"/>
                <xsl:if test="$plumx_data-orientation">
                    <xsl:attribute name="data-orientation"><xsl:value-of select="$plumx_data-orientation"/></xsl:attribute>
                </xsl:if>

                <xsl:variable name="plumx_data-width" select="confman:getProperty('altmetrics', 'plumx.data-width')"/>
                <xsl:if test="$plumx_data-width">
                    <xsl:attribute name="data-width"><xsl:value-of select="$plumx_data-width"/></xsl:attribute>
                </xsl:if>

                <xsl:if test="confman:getProperty('altmetrics', 'plumx.data-border')">
                    <xsl:attribute name="data-border">true</xsl:attribute>
                </xsl:if>
                
            </a>

        </div>

Step 3

After updating the XSL file, the next step is to updated the CSS style.

Edit the following file:

nano $HOME/source/dspace-xmlui-mirage2/src/main/webapp/styles/classic_mirage_color_scheme/_item-view.scss

Go to the bottom of the file and add the following:

#impact-altmetric {
    float:right;
    margin:0 30px 0 30px;
}

#impact-plumx {
    float:right;
}

Step 4

Then rebuild DSpace.