Skip to content

Instantly share code, notes, and snippets.

@carsten
Created June 11, 2009 16:39
Show Gist options
  • Save carsten/128041 to your computer and use it in GitHub Desktop.
Save carsten/128041 to your computer and use it in GitHub Desktop.
Use to display a list of albums and show Picasa Web Albums. In combination with:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:atom="http://www.w3.org/2005/Atom"
exclude-result-prefixes="media atom">
<xsl:output method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes" />
<xsl:template match="/">
<html>
<head>
<title>Picasa Web Albums</title>
<style type="text/css">
<xsl:text>
.albums {
width: 960px;
margin-left: auto;
margin-right: auto;
}
.albums img {
border: 4px solid #eee;
}
.albums a:hover img {
border-color: #999;
}
.albums a:focus , .albums a:active {
outline: none;
}
.albums ul a:focus img, .albums ul a:active img {
border: 3px solid #111;
padding: 1px;
}
.albums ul {
clear: both;
padding: 0 0 10px 0;
margin: 0 0 0 0;
}
.albums ul li {
float: left;
margin: 0 10px 10px 0;
list-style: none;
}
.albums h4 {
clear: both;
margin-bottom: 4px;
}
.albums p {
display: block;
}
.albums p img {
float: left;
margin-right: 1em;
}
</xsl:text>
</style>
</head>
<body>
<div class="albums">
<xsl:choose>
<xsl:when test="$id != ''">
<xsl:apply-templates select="data/picasa-xml-auth/rss/channel" />
<xsl:apply-templates select="data/picasa-xml/rss/channel" />
<p><a href="{$root}/{$current-page}/" title="Album overview">Back to album overview.</a></p>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="data/picasa-albums" />
</xsl:otherwise>
</xsl:choose>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="picasa-albums">
<h3>Albums</h3>
<xsl:apply-templates select="entry" />
</xsl:template>
<xsl:template match="picasa-albums/entry">
<xsl:param name="albumtitle" select="title" />
<xsl:param name="albumcover" select="concat($root, '/image/2/100/100/5/uploads/', cover/filename)" />
<xsl:param name="albumdescription" select="description" />
<h4><a href="{$root}/{$current-page}/{@id}" title="{$albumtitle}"><xsl:value-of select="$albumtitle" /></a></h4>
<p>
<xsl:if test="cover/filename != ''">
<a href="{$root}/{$current-page}/{@id}" title="{$albumtitle}">
<img>
<xsl:attribute name="src"><xsl:value-of select="$albumcover"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="$albumtitle"/></xsl:attribute>
</img>
</a>
</xsl:if>
<xsl:if test="$albumdescription != ''">
<xsl:value-of select="$albumdescription" />
</xsl:if>
</p>
<xsl:if test="cover/filename != ''"><div style="clear: both;"></div></xsl:if>
</xsl:template>
<xsl:template match="picasa-xml/rss/channel | picasa-xml-auth/rss/channel">
<h3><xsl:value-of select="title" /></h3>
<xsl:if test="description != ''"><p><xsl:value-of select="description" /></p></xsl:if>
<ul>
<xsl:apply-templates select="item/media:group" mode="album" />
</ul>
<div style="clear: both;"></div>
</xsl:template>
<xsl:template match="item/media:group" mode="album">
<li>
<a>
<xsl:attribute name="href"><xsl:value-of select="media:content/@url"/></xsl:attribute>
<xsl:attribute name="title">
<xsl:if test="media:description=''"><xsl:value-of select="media:title" /></xsl:if><xsl:value-of select="media:description" />
</xsl:attribute>
<img>
<xsl:attribute name="src"><xsl:value-of select="media:thumbnail/@url"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="media:title"/></xsl:attribute>
</img>
</a>
</li>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment