Created
August 22, 2013 17:16
-
-
Save ykzts/6310129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:octopress-tumblr-theme="http://desire.sh/2013/08/23/octopress-tumblr-theme" version="1.0" exclude-result-prefixes="xhtml xsl octopress-tumblr-theme" xml:lang="en"> | |
<xsl:output method="xml"/> | |
<xsl:template match="/"> | |
<xsl:apply-templates select="tumblr"/> | |
</xsl:template> | |
<xsl:template match="tumblr"> | |
<html> | |
<head> | |
<xsl:call-template name="octopress-tumblr-theme:head"/> | |
</head> | |
<body> | |
<xsl:call-template name="octopress-tumblr-theme:body"/> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:head"> | |
<link href="/octopress-tumblr-theme.css" rel="stylesheet" type="text/css"/> | |
<title> | |
<xsl:value-of select="tumblelog/@title"/> | |
</title> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:body"> | |
<xsl:call-template name="octopress-tumblr-theme:main-header"/> | |
<xsl:call-template name="octopress-tumblr-theme:main-navigation"/> | |
<div class="main"> | |
<xsl:call-template name="octopress-tumblr-theme:main-content"/> | |
<div class="aside"> | |
<div id="recent-posts"> | |
<h3>Recent Posts</h3> | |
<p><a href="/archive">Archive</a></p> | |
</div> | |
</div> | |
</div> | |
<xsl:call-template name="octopress-tumblr-theme:main-footer"/> | |
<script src="/octopress-tumblr-theme.js" type="application/javascript"/> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:main-header"> | |
<div class="header"> | |
<h1> | |
<a href="/"> | |
<xsl:value-of select="tumblelog/@title"/> | |
</a> | |
</h1> | |
<p class="description"> | |
<xsl:value-of select="tumblelog"/> | |
</p> | |
</div> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:main-navigation"> | |
<div class="navigation"> | |
<ul class="subscription"> | |
<li> | |
<a href="/rss" title="Get the RSS" type="application/rss+xml">RSS</a> | |
</li> | |
</ul> | |
<form action="/search" method="get"> | |
<fieldset> | |
<input class="search" name="q" type="text" value=""/> | |
</fieldset> | |
</form> | |
<ul class="main-navigation"> | |
<li> | |
<a href="/">Blog</a> | |
</li> | |
<li> | |
<a href="/archive">Achive</a> | |
</li> | |
</ul> | |
</div> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:main-content"> | |
<div class="content"> | |
<xsl:apply-templates select="posts/post"/> | |
</div> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:main-footer"> | |
<div class="footer"> | |
<p> | |
<span class="credit"> | |
<xsl:text>Powerd by</xsl:text> | |
<a href="http://www.tumblr.com/">Tumblr</a> | |
</span> | |
</p> | |
</div> | |
</xsl:template> | |
<xsl:template match="post"> | |
<div class="article"> | |
<div class="header"> | |
<h2> | |
<a href="" title="Permalink for this post"> | |
<xsl:value-of select="regular-title"/> | |
</a> | |
</h2> | |
<p class="meta"> | |
<span class="time" title="@date"> | |
<xsl:value-of select="@date"/> | |
</span> | |
</p> | |
</div> | |
<xsl:apply-templates select="regular-body"/> | |
<div class="footer"> | |
</div> | |
</div> | |
</xsl:template> | |
<xsl:template match="regular-body"> | |
<xsl:call-template name="octopress-tumblr-theme:html-parse"> | |
<xsl:with-param name="text" select="."/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:html-parse"> | |
<xsl:param name="text" select="''"/> | |
<xsl:variable name="start-tag"> | |
<xsl:if test="contains($text, '<') and contains($text, '>')"> | |
<xsl:text><</xsl:text> | |
<xsl:value-of select="substring-before(substring-after($text, '<'), '>')"/> | |
<xsl:text>></xsl:text> | |
</xsl:if> | |
</xsl:variable> | |
<xsl:variable name="element-name"> | |
<xsl:if test="string-length($start-tag) > 0 and not(starts-with($text, '</'))"> | |
<xsl:choose> | |
<xsl:when test="contains(normalize-space($start-tag), ' ')"> | |
<xsl:value-of select="substring(substring-before(normalize-space($start-tag), ' '), 2)"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="substring($start-tag, 2, string-length($start-tag) - 2)"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:variable> | |
<xsl:variable name="end-tag"> | |
<xsl:if test="string-length($element-name) > 0"> | |
<xsl:text></</xsl:text> | |
<xsl:value-of select="$element-name"/> | |
<xsl:text>></xsl:text> | |
</xsl:if> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="string-length($element-name) > 0"> | |
<xsl:value-of select="substring-before($text, $start-tag)"/> | |
<xsl:element name="{$element-name}"> | |
<xsl:call-template name="octopress-tumblr-theme:html-attribute-parse"> | |
<xsl:with-param name="attributes" select="normalize-space(substring($start-tag, string-length($element-name) + 2, string-length($start-tag) - string-length($element-name) - 2))"/> | |
</xsl:call-template> | |
<xsl:call-template name="octopress-tumblr-theme:html-parse"> | |
<xsl:with-param name="text" select="substring-before(substring-after($text, $start-tag), $end-tag)"/> | |
</xsl:call-template> | |
</xsl:element> | |
<xsl:call-template name="octopress-tumblr-theme:html-parse"> | |
<xsl:with-param name="text" select="substring-after($text, $end-tag)"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$text"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="octopress-tumblr-theme:html-attribute-parse"> | |
<xsl:param name="attributes" select="''"/> | |
<xsl:variable name="attribute"> | |
<xsl:choose> | |
<xsl:when test="contains($attributes, ' ')"> | |
<xsl:value-of select="substring-before($attributes, ' ')"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$attributes"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="attribute-name"> | |
<xsl:value-of select="substring-before($attribute, '="')"/> | |
</xsl:variable> | |
<xsl:variable name="attribute-value"> | |
<xsl:value-of select="substring-before(substring-after($attribute, concat($attribute-name, '="')), '"')"/> | |
</xsl:variable> | |
<xsl:if test="string-length($attribute-name) > 0"> | |
<xsl:attribute name="{$attribute-name}"> | |
<xsl:value-of select="$attribute-value"/> | |
</xsl:attribute> | |
<xsl:call-template name="octopress-tumblr-theme:html-attribute-parse"> | |
<xsl:with-param name="attributes" select="substring-after($attributes, $attribute)"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment