﻿<xsl:stylesheet version="1.0" 
	xmlns:date="http://exslt.org/dates-and-times"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="date">

<xsl:param name="IsBlogOwner" />
<xsl:param name="RelativeUrl" />

<xsl:output omit-xml-declaration="yes" />

<xsl:template match="/">

	<xsl:apply-templates select="rows/row"/>

</xsl:template>

<xsl:template match="row">

	<div class="blogPostContainer">
		<div class="blogListTitle">
			<h2><xsl:value-of select="Title"/></h2>
		</div>
		
		<div class="blogText">
			<xsl:value-of select="Body" disable-output-escaping="yes" />
		</div>

		<div class="blogDetails">
			Posted by 
			<span class="blogAuthor">
				<xsl:value-of select="substring-after(Author,'#')"/>
			</span>
			 on 
			<span class="blogArticleDate">
				<xsl:variable name="publishedDate" select="date:parseDate(PublishedDate, 'yyyy-MM-dd HH:mm:ss')"/>
				<xsl:value-of select="date:format-date($publishedDate, 'EEEE, d MMM yyyy hh:mm')"/>
			</span>

			<span class="blogArticleCommentCount small">
				<xsl:value-of select="NumComments"/> Comments
			</span>

			<div>
				<xsl:value-of select="substring-after(PostCategory,'#')"/>
			</div>
		</div>

		<xsl:if test="$IsBlogOwner = 'True'">
			<div class="blogCommands small">
				<a>
					<xsl:attribute name="href">
						/<xsl:value-of select="substring-after(FileDirRef,'#')"/>/EditPost.aspx?ID=<xsl:value-of select="ID"/>
					</xsl:attribute>
					[Edit Post]
				</a>
			</div>
		</xsl:if>
	</div>

</xsl:template>

<xsl:template name="strip-tags"> 
	<xsl:param name="text"/> 
	<xsl:choose> 
	    <xsl:when test="contains($text, '&lt;')"> 
	            <xsl:value-of select="substring-before($text, '&lt;')"/> 
	            <xsl:call-template name="strip-tags"> 
	                    <xsl:with-param name="text" select="substring-after($text, '&gt;')"/> 
	            </xsl:call-template> 
	    </xsl:when> 
	    <xsl:otherwise> 
	            <xsl:value-of select="$text"/> 
	    </xsl:otherwise> 
	</xsl:choose> 
</xsl:template> 
  
</xsl:stylesheet>
