Skip to content

Instantly share code, notes, and snippets.

@terrywbrady
Created January 28, 2019 20:31
Show Gist options
  • Save terrywbrady/e5d2e5aa61b30bce35b5eadf67bc5692 to your computer and use it in GitHub Desktop.
Save terrywbrady/e5d2e5aa61b30bce35b5eadf67bc5692 to your computer and use it in GitHub Desktop.
Sharestream Embed Logic
<xsl:template name="summaryHeaderSharestream">
<xsl:variable name="isAudio" select="dim:field[@element='type'][text()='Audio']"/>
<xsl:for-each select="dim:field[@element='relation' and @qualifier='uri']">
<div class="row">
<div class="col-sm-12">
<xsl:variable name="media">
<xsl:choose>
<xsl:when test="contains(.,'/sharestream2gui')">
<xsl:text>https://mediapilot.georgetown.edu:443/ssdcms/embedplayer.do?aid=</xsl:text>
<xsl:value-of select="substring-before(substring-after(.,'mediaPath='),'&amp;')"/>
<xsl:text>&amp;</xsl:text>
<xsl:text>cid=</xsl:text>
<xsl:value-of select="substring-after(.,'cid=')"/>
<xsl:text>&amp;</xsl:text>
<xsl:text>h=360</xsl:text>
<xsl:text>&amp;</xsl:text>
<xsl:text>w=460</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="./node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="authImage" select="//mets:file/mets:FLocat[starts-with(@xlink:label, $SSTREAM_AUTH) or starts-with(@xlink:label, $SSTREAM_THUMB)]"/>
<xsl:variable name="sharestream-auth" select="concat('sharestream-auth',position())"/>
<xsl:variable name="video-embed-wrapper">
<xsl:choose>
<xsl:when test="$isAudio"><xsl:value-of select="concat('audio-embed-wrapper',position())"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat('video-embed-wrapper',position())"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="video-embed-frame">
<xsl:choose>
<xsl:when test="$isAudio"><xsl:value-of select="concat('audio-embed-frame',position())"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat('video-embed-frame',position())"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="embed-wrapper-class">
<xsl:choose>
<xsl:when test="$isAudio"><xsl:text>audio-embed-wrapper</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>video-embed-wrapper</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="embed-frame-class">
<xsl:choose>
<xsl:when test="$isAudio"><xsl:text>audio-embed-frame</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>video-embed-frame</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$authImage or $isAudio">
<div style="text-align:center" class="gu-media-div" role="button">
<xsl:attribute name="id">
<xsl:value-of select="$sharestream-auth"/>
</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:text>$('#</xsl:text><xsl:value-of select="$video-embed-frame"/><xsl:text>').attr('src','</xsl:text>
<xsl:value-of select="$media"/>
<xsl:text>');</xsl:text>
<xsl:text>$('#</xsl:text><xsl:value-of select="$sharestream-auth"/><xsl:text>').hide();</xsl:text>
<xsl:text>$('#</xsl:text><xsl:value-of select="$video-embed-wrapper"/><xsl:text>').show();</xsl:text>
</xsl:attribute>
<xsl:if test="//mets:file/mets:FLocat[@xlink:label=$SSTREAM_AUTH]">
<h4>This item is restricted to the Georgetown community. You will be asked to login to see this item.</h4>
</xsl:if>
<img align="center">
<xsl:choose>
<xsl:when test="$isAudio">
<xsl:attribute name="src">/static/images/audio-embed-icon.png</xsl:attribute>
<xsl:attribute name="alt">Audio Player Icon. Click to play.</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="src">
<xsl:value-of select="$authImage/@xlink:href"/>
</xsl:attribute>
<xsl:call-template name="gu-alt-text">
<xsl:with-param name="thumb" select="//mets:file[mets:FLocat[starts-with(@xlink:label, $SSTREAM_AUTH) or starts-with(@xlink:label, $SSTREAM_THUMB)]]"/>
<xsl:with-param name="suffix">. Click to play.</xsl:with-param>
</xsl:call-template>
<xsl:attribute name="itemprop">thumbnailUrl</xsl:attribute>
<xsl:attribute name="content">
<xsl:value-of select="concat($base-path,$authImage/@xlink:href)"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</img>
</div>
<div istyle="text-align:center;" style="display:none;text-align:center;">
<xsl:attribute name="id">
<xsl:value-of select="$video-embed-wrapper"/>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="$embed-wrapper-class"/>
</xsl:attribute>
<iframe allowfullscreen="1" allow="autoplay; fullscreen">
<xsl:attribute name="title">
<xsl:value-of select="//dim:field[@element='title'][not(@qualifier)]"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$video-embed-frame"/>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="$embed-frame-class"/>
</xsl:attribute>
<xsl:attribute name="src">
</xsl:attribute>
&#xFEFF; <xsl:comment>non-breaking space to force separating the end tag</xsl:comment>
</iframe>
</div>
</xsl:when>
<xsl:otherwise>
<div id="video-embed-wrapper" class="video-embed-wrapper gu-media-div">
<iframe id="video-embed-frame" class="video-embed-frame" allowfullscreen="1" allow="autoplay; fullscreen">
<xsl:attribute name="title">
<xsl:value-of select="//dim:field[@element='title'][not(@qualifier)]"/>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="$media"/>
</xsl:attribute>
&#xFEFF; <!-- non-breaking space to force separating the end tag -->
</iframe>
</div>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
</xsl:for-each>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment