Skip to content

Instantly share code, notes, and snippets.

View jessgusclark's full-sized avatar

Jesse Clark jessgusclark

View GitHub Profile
@jessgusclark
jessgusclark / anchor-php-replace-version1.xsl
Last active December 5, 2016 16:42
Template match for anchors to remove .php
<xsl:template match="a[contains(@href, '.php')]">
<a href="{replace(@href, '.php', '')}">
<xsl:value-of select="node()" />
</a>
</xsl:template>
<!-- Create a variable with the data that you want from $taggedItems -->
<xsl:variable name="myvariable">
<xsl:for-each select="$taggedItems">
<xsl:sort select="last-pub-date" order="descending"/>
<item>
<url><xsl:value-of select="..." /></url>
<title><xsl:value-of select="..." /><title>
<description>...</description>
</item>
</xsl:for-each>
@jessgusclark
jessgusclark / date.pcf
Created August 26, 2016 16:09
Converting Dates from OU Campus to XS:Date
<?xml version="1.0" encoding="utf-8"?>
<?pcf-stylesheet path="date.xsl" title="Date Example" extension="htm"?>
<!DOCTYPE document SYSTEM "http://commons.omniupdate.com/dtd/standard.dtd">
<document xmlns:ouc="http://omniupdate.com/XSL/Variables">
<ouc:div label="content1" group="Everyone" button-class="oucEditButton" button-text="Col1 Content" break="break" button="hide"><ouc:editor csspath="/_resources/ou/editor/maincontent.css" cssmenu="/_resources/ou/editor/menu.txt" width="955" wysiwyg-class="maincontent"/></ouc:div>
<ouc:div label="artdate" group="Everyone" button-text="Edit Date"><ouc:multiedit type="date" format="iso" prompt="Date" alt="Date." maxlength="100"/>08/27/2016</ouc:div>
@jessgusclark
jessgusclark / snippet.xsl
Created July 18, 2016 21:16
Icons in OU Campus
<!-- Convert img to icon -->
<xsl:template match="img[starts-with(@class, 'material-icons')]">
<i class="{@class}"><xsl:value-of select="@alt" /></i>
</xsl:template>
<!-- Template to display and format an Individual Tag -->
<xsl:template name="DisplayTag">
<xsl:param name="tag" />
<!-- Remove the `library-database-` from the tag name -->
<xsl:variable name="tag-name" select="replace($tag/name, 'library-database-', '')" />
<!-- Link the label to the page. This server uses aspx -->
<a href="{$tag-name}.aspx">
<span class="label label-success">
<!-- Get the Tags that are associated with the data file -->
<xsl:template name="GetTagsForPage">
<xsl:param name="page-path" />
<xsl:variable name="page-tags" select="doc(concat('ou:/Tag/GetTags?site=', $ou:site, '&amp;path=', $page-path))/tags" />
<xsl:for-each select="$page-tags/tag">
<xsl:call-template name="DisplayTag">
<xsl:with-param name="tag" select="." />
</xsl:call-template>
<!-- Display Journal content -->
<h3><xsl:value-of select="$page-content/document/ouc:properties/parameter[@name='database-name']" /></h3>
<p><xsl:value-of select="$page-content/document/ouc:properties/parameter[@name='database-description']" /></p>
<p><a href="{$page-content/ouc:properties[@label='config']/parameter[@name='database-url']}">Open Database</a></p>
<!-- GetTagsForPage function will get the tags associated with the data file -->
<xsl:call-template name="GetTagsForPage">
<xsl:with-param name="page-path" select="concat($data-folder,'/', $file-name)" />
</xsl:call-template>
<!-- Get the first character of the title (example: If 'accounting' this will return 'A') -->
<xsl:variable name="current-letter" select="upper-case(
substring(
$page-content/document/ouc:properties/parameter[@name='database-name'],1,1
)
)"/>
<!-- If previous data file exists, get it, else leave the variable $previous-letter as blank -->
<xsl:variable name="previous-letter">
<xsl:if test="preceding-sibling::file[1] != ''">
<!-- Loop through list using the sibiling -->
<xsl:for-each select="$sortedcopy/file">
<!-- Variables for single data file -->
<xsl:variable name="file-name"><xsl:value-of select="."/></xsl:variable>
<xsl:variable name="page-content" select="doc(concat($data-location,'/', $file-name))" />
<!-- Check to make sure it is a data file -->
<xsl:if test="$page-content/document/page/@type = 'library-database'"> <!--library-database -->
@jessgusclark
jessgusclark / GetFilesFolder.xsl
Created April 18, 2016 17:44
Get Files in Folder
<!-- static folder to look for data files: -->
<xsl:variable name="data-folder" select="'/pcf/data'" />
<xsl:variable name="data-location" select="concat($ou:root, $ou:site, $data-folder)" />
<!-- Create Sorted Version First, this has to happen here so we can use preceding-sibling later -->
<xsl:variable name="sortedcopy">
<xsl:for-each select="doc($data-location)/list/file">
<xsl:sort select="." order="ascending"/>
<xsl:copy-of select="."/>