...
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> xmlns:urwg="http://www.gridforum.org/2003/ur-wg" xmlns:SimpleDateFormat="http://xml.apache.org/xalan/java/java.text.SimpleDateFormat" xmlns:Date="http://xml.apache.org/xalan/java/java.util.Date"> <!-- Declaration of parameters --> <!-- if you want to use a Sakai value or a passed in parameter from the --> <!-- query string, you should state it here --> <!-- The id parameter from the query string --> <xsl:param name="id"/> <!-- a number we can switch on to The sakai.tool.placement.ia parameter from the query string --> <xsl:param name="sakai.tool.placement.id"/> <!-- a number we can switch on to display different content for each page --> <xsl:param name="pageNumber"/> <!-- if passed, the created variable will be a key to a single blog Entry --> <xsl:param name="created"/> <!-- Declare output method --> <xsl:output method="html"/> <!-- Main Template outputs our HTML page --> <xsl:template match="/"> <xsl:choose> <html> <xsl:when test="$pageNumber=4"> Rss! </xsl:when> <head><title><xsl:text>My Blog</xsl:text></title></head> <xsl:otherwise> <body> <html> <div> <head> <img> <title>My Blog</title> <xsl:attribute name="src"> <link <xsl:value-of select="/ospiPresentation/presentationFiles/myLogo/artifact/fileArtifact/uri"/rel="stylesheet" type="text/css"> <!--<xsl:attribute name="href">blogStyle.css</xsl:attribute>--> </xsl:attribute> <xsl:attribute name="href"> <xsl:attribute name="alt">My Institutions Logo</xsl:attribute> <xsl:value-of select="/ospiPresentation/presentationFiles/style/artifact/fileArtifact/uri"/> <xsl:attribute name="style">float: right; padding: 1em</xsl:attribute> </xsl:attribute> </img> </link> <h1>My Blog</h1> </head> </div> <body> <div id="wrapper"> <!-- a little menu to navigate --> <div id="menuheader"> style="width: 100%; padding: 1em; margin: 1em 0; border-bottom: solid 1px black"> <xsl:call-templateattribute name="menuLinkstyle"> <xsl:with-param name="pageNumber"></xsl:with-param>text>background-image:url('</xsl:text> <xsl:withvalue-paramof nameselect="text">Home</xsl:with-param>/ospiPresentation/presentationFiles/backgroundImage/artifact/fileArtifact/uri"/> </xsl:call-template> | <xsl:text>')</xsl:text> <xsl:call-template name="menuLink"> </xsl:attribute> <xsl:with-param name="pageNumber">2</xsl:with-param> <img> <xsl:with-paramattribute name="text">All Entries</xsl:with-param>src"> </xsl:call-template> <xsl:value-of select="/ospiPresentation/presentationFiles/myLogo/artifact/fileArtifact/uri"/> </div> </xsl:attribute> <!-- a switch to select content for this page based on the value of pageNumber --><xsl:attribute name="alt">My Institutions Logo</xsl:attribute> <div> <xsl:attribute name="style">float: right;</xsl:attribute> <xsl:choose> </img> <xsl:when test="$pageNumber=2"> <h1>My Blog</h1> <h3>All Entries</h3> </div> <ul> <!-- a little menu to navigate --> <xsl:for-each select="/ospiPresentation/blogEntry/artifact"> <div id="menu"> <xsl:sort select="./metaData/repositoryNode/created" order="descending"/> <ul> <li> <xsl:call-template name="menuLink"> <li> <xsl:with-param name="pageNumber"/> <a> <xsl:with-param name="text">Last 5</xsl:with-param> <xsl:attribute name="href"> </xsl:call-template> <xsl:text disable-output-escaping="yes">viewPresentation.osp?id=</xsl:text> </li> <li> <xsl:value-of select="$id"/> <xsl:call-template name="menuLink"> <xsl:text disable-output-escaping="yes">&pageNumber=3&created=</xsl:text> <xsl:with-param name="pageNumber">1</xsl:with-param> <xsl:valuewith-ofparam selectname="./metaData/repositoryNode/created"/>text">About Me</xsl:with-param> </xsl:call-template> </xsl:attribute> </li> <xsl:value-of select="./metaData/displayName"/> - <li> <xsl:valuecall-oftemplate selectname="./metaData/repositoryNode/created"/menuLink"> <xsl:with-param name="pageNumber">2</xsl:with-param> </a> <xsl:with-param </li>name="text">Entry Index</xsl:with-param> </xsl:call-template> </xsl:for-each>li> </ul> <li> </xsl:when> <xsl:call-template name="menuLink"> <xsl:when test="$pageNumber=3"> <xsl:forwith-eachparam selectname="pageNumber"/ospiPresentation/blogEntry/artifact[metaData/repositoryNode/created=$created]">>4</xsl:with-param> <div style="border: solid 1px black; padding: 1em; margin<xsl: 1em 1em 2em 2em">with-param name="text">RSS Feed</xsl:with-param> <h3><xsl:value-of select="./metaData/displayName"/></h3></xsl:call-template> </li> <h4><xsl:value-of select="./metaData/repositoryNode/created"/></h4> </ul> <xsl:value-of select="./structuredData/blogEntry/entryBody" disable-output-escaping="yes"/> </div> </div> <div id="contentWrapper"> </xsl:for-each> <div id="entryNav"> </xsl:when> <h3>Blog Posts</h3> <xsl:otherwise> <ul> <xsl:for-each select="/ospiPresentation/blogEntry/artifact[position() < 5]"> <xsl:sortfor-each select="./metaDataospiPresentation/repositoryNodeblogEntry/createdartifact" order="descending"/>> <div style="border: solid 1px black; padding: 1em; margin: 1em 1em 2em 2em"><xsl:sort data-type="number" <h3><xsl:value-of select="./metaData/displayName"/></h3>Date:getTime(SimpleDateFormat:parse(SimpleDateFormat:new('EEE MMM dd kk:mm:ss zzz yyyy'), ./metaData/repositoryNode/created))" <h4><xsl:value-of selectorder="./metaData/repositoryNode/createddescending"/></h4>> <xsl:value-of select="./structuredData/blogEntry/entryBody" disable-output-escaping="yes"/> <li> </div> <a> </xsl:for-each> <xsl:attribute name="href"> <xsl:text disable-output-escaping="yes">viewPresentation.osp?sakai.tool.placement.id=</xsl:text> <xsl:value-of select="$sakai.tool.placement.id"/> <xsl:text disable-output-escaping="yes">&id=</xsl:text> <xsl:value-of select="$id"/> <xsl:text disable-output-escaping="yes">&pageNumber=3&created=</xsl:text> <xsl:value-of select="./metaData/repositoryNode/created"/> </xsl:attribute> <xsl:value-of select="./metaData/displayName"/> </a> </li> </xsl:for-each> </ul> </div> <!-- a switch to select content for this page based on the value of pageNumber --> <div id="content"> <xsl:choose> <xsl:when test="$pageNumber=1"> <!-- about me --> About me Page </xsl:when> <xsl:when test="$pageNumber=2"> <!-- display an index of all blog entries --> <h3>All Entries</h3> <ul id="datedEntryList"> <xsl:for-each select="/ospiPresentation/blogEntry/artifact"> <xsl:sort data-type="number" select="Date:getTime(SimpleDateFormat:parse(SimpleDateFormat:new('EEE MMM dd kk:mm:ss zzz yyyy'), ./metaData/repositoryNode/created))" order="descending"/> <li> <a> <xsl:attribute name="href"> <xsl:text disable-output-escaping="yes">viewPresentation.osp?sakai.tool.placement.id=</xsl:text> <xsl:value-of select="$sakai.tool.placement.id"/> <xsl:text disable-output-escaping="yes">&id=</xsl:text> <xsl:value-of select="$id"/> <xsl:text disable-output-escaping="yes">&pageNumber=3&created=</xsl:text> <xsl:value-of select="./metaData/repositoryNode/created"/> </xsl:attribute> <xsl:value-of select="./metaData/displayName"/> - <xsl:value-of select="./metaData/repositoryNode/created"/> </a> </li> </xsl:for-each> </ul> </xsl:when> <xsl:when test="$pageNumber=3"> <!-- individual entry displayed --> <xsl:for-each select="/ospiPresentation/blogEntry/artifact[metaData/repositoryNode/created=$created]"> <xsl:call-template name="entry"> <xsl:with-param name="title"> <xsl:value-of select="./metaData/displayName"/> </xsl:with-param> <xsl:with-param name="date"> <xsl:value-of select="./metaData/repositoryNode/created"/> </xsl:with-param> <xsl:with-param name="body"> <xsl:value-of select="./structuredData/blogEntry/entryBody"/> </xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:when> <xsl:otherwise> <!-- last 5 blog entries --> <xsl:for-each select="/ospiPresentation/blogEntry/artifact[position() > 0]"> <!-- sort by year, moth, day created dates formatted like: Tue Jan 09 09:59:52 EST 2007 --> <xsl:sort data-type="number" select="Date:getTime(SimpleDateFormat:parse(SimpleDateFormat:new('EEE MMM dd kk:mm:ss zzz yyyy'), ./metaData/repositoryNode/created))" order="descending"/> <xsl:call-template name="entry"> <xsl:with-param name="title"> <xsl:value-of select="./metaData/displayName"/> </xsl:with-param> <xsl:with-param name="date"> <xsl:value-of select="./metaData/repositoryNode/created"/> </xsl:with-param> <xsl:with-param name="body"> <xsl:value-of select="./structuredData/blogEntry/entryBody"/> </xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:otherwise> </xsl:choose> </div> <!-- content --> <div style="clear: both"/> </div> <!-- contentWrapper --> </div> <!-- end wrapper div --> </body> </html> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="entry"> <xsl:param name="title"/> <xsl:param name="date"/> <xsl:param name="body"/> <div class="entry"> <h3> <xsl:value-of select="$title"/> </h3> <div class="date"> </xsl:otherwise><xsl:value-of select="$date"/> </div> </xsl:choose> <div class="entryBody"> <xsl:value-of </div>select="$body" disable-output-escaping="yes"/> </body>div> </html> div> </xsl:template> <!-- a named template to menu display links correctly --> <xsl:template name="menuLink"> <xsl:param name="pageNumber"/> <xsl:param name="text"/> <span style="padding: 0 2em;"> <a> <xsl:attribute name="href"> <xsl:text disable-output-escaping="yes">viewPresentation.osp?sakai.tool.placement.id=</xsl:text> <xsl:value-of select="$id$sakai.tool.placement.id"/> <xsl:text disable-output-escaping="yes">&pageNumberid=</xsl:text> <xsl:value-of select="$pageNumber$id"/> <xsl:text disable-output-escaping="yes">&pageNumber=</xsl:attribute> text> <xsl:value-of select="$text$pageNumber"/> </a>xsl:attribute> </span><xsl:value-of select="$text"/> </a> </xsl:template> </xsl:stylesheet> |