diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
commit | e38d2351b83fa65c66ccde443777647ef5cb6cff (patch) | |
tree | 1897fc20e9f73a81c520a5b9f76f8ed042124883 /xslt/entry-templates | |
download | tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip |
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'xslt/entry-templates')
-rw-r--r-- | xslt/entry-templates/Album.xsl | 497 | ||||
-rw-r--r-- | xslt/entry-templates/Compact.xsl | 294 | ||||
-rw-r--r-- | xslt/entry-templates/Default.xsl | 346 | ||||
-rw-r--r-- | xslt/entry-templates/Fancy.xsl | 444 | ||||
-rw-r--r-- | xslt/entry-templates/Makefile.am | 17 | ||||
-rw-r--r-- | xslt/entry-templates/Video.xsl | 512 |
6 files changed, 2110 insertions, 0 deletions
diff --git a/xslt/entry-templates/Album.xsl b/xslt/entry-templates/Album.xsl new file mode 100644 index 0000000..9b6e6f0 --- /dev/null +++ b/xslt/entry-templates/Album.xsl @@ -0,0 +1,497 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Entry template for videos + + Copyright (C) 2003-2006 Robby Stephenson - [email protected] + + Known Issues: + o If there is more an one image, there's a lot of white space under + the top tables. + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" + doctype-system="http://www.w3.org/TR/html4/loose.dtd" + encoding="utf-8"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> +<xsl:param name="font"/> <!-- font family --> +<xsl:param name="fontsize"/> <!-- font size --> +<xsl:param name="fgcolor"/> <!-- foreground color --> +<xsl:param name="bgcolor"/> <!-- background color --> +<xsl:param name="color1"/> <!-- highlighted text color --> +<xsl:param name="color2"/> <!-- highlighted background color --> + +<xsl:param name="collection-file"/> <!-- might have a link to parent collection --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="fieldsByCat" match="tc:field" use="@category"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:variable name="endl"> +<xsl:text> +</xsl:text> +</xsl:variable> + +<!-- all the categories --> +<xsl:variable name="categories" select="/tc:tellico/tc:collection/tc:fields/tc:field[generate-id(.)=generate-id(key('fieldsByCat',@category)[1])]/@category"/> +<!-- all the tracks --> +<xsl:variable name="tracks" select="/tc:tellico/tc:collection/tc:fields/tc:field[starts-with(@name,'track')]"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<!-- The default layout is pretty boring, but catches every field value in + the entry. The title is in the top H1 element. --> +<xsl:template match="tc:tellico"> + <!-- This stylesheet is designed for Tellico document syntax version 10 --> + <xsl:call-template name="syntax-version"> + <xsl:with-param name="this-version" select="'10'"/> + <xsl:with-param name="data-version" select="@syntaxVersion"/> + </xsl:call-template> + + <html> + <head> + <style type="text/css"> + body { + margin: .2em 1%; + padding: 0; + font-family: "<xsl:value-of select="$font"/>", Arial, Helvetica, sans-serif; + font-size: <xsl:value-of select="$fontsize"/>pt; + background-color: <xsl:value-of select="$bgcolor"/>; + color: <xsl:value-of select="$fgcolor"/>; + line-height: 1.6; + } + #banner { + padding-bottom: .2em; + margin-bottom: .2em; + } + img#logo { + padding-top: .3em; /* match h1 */ + } + h1 { + color: <xsl:value-of select="$color1"/>; + background-color: <xsl:value-of select="$color2"/>; + background-image: url(<xsl:value-of select="concat($imgdir, 'gradient_header.png')"/>); + background-repeat: repeat-x; + font-size: 1.8em; + text-align: left; + padding: .1em .5em; + margin: 0; + font-weight: bold; + } + span.title { + font-style: italic + } + img { + padding-right: 6px; + padding-bottom: 6px; + border: 0px; + } + table.category { + margin-bottom: 6px; + float: left; + } + tr.category { + font-weight: bold; + font-size: 1.2em; + color: #fff; + background-color: #666; + text-align: center; + } + th { + font-weight: bold; + text-align: left; + color: black; + background: #ccc; + } + td.fieldValue { + color: black; + background: #ddd; + } + th, td.fieldValue { + padding: .1em .3em; + } + p { + margin-top: 0px; + text-align: justify; + } + img { + border: 0px solid; + } + <!-- since text is our own color, links have to be, too --> + a { + color: #006; + } + p.navigation { + font-weight: bold; + text-align: center; + clear: both; + } + </style> + <title> + <xsl:value-of select="tc:collection/tc:entry[1]//tc:title[1]"/> + <xsl:text> – </xsl:text> + <xsl:value-of select="tc:collection/@title"/> + </title> + </head> + <body> + <xsl:apply-templates select="tc:collection[1]"/> + <xsl:if test="$collection-file"> + <p class="navigation"> + <a href="{$collection-file}"><< <xsl:value-of select="tc:collection/@title"/></a> + </p> + </xsl:if> + </body> + </html> +</xsl:template> + +<!-- type 3 is video collections --> +<!-- warn user that this template is meant for videos only. --> +<xsl:template match="tc:collection[@type!=4]"> + <h1><i18n>This template is meant for music collections only.</i18n></h1> +</xsl:template> + +<xsl:template match="tc:collection[@type=4]"> + <xsl:apply-templates select="tc:entry[1]"/> +</xsl:template> + +<xsl:template match="tc:entry"> + <xsl:variable name="entry" select="."/> + <xsl:variable name="titleCat" select="key('fieldsByName','title')/@category"/> + + <!-- the top table has images in the left cell and main fields in the right. + 2 images can be on the left --> + <table width="100%" class="category"> + <tr> + <!-- now, show all the images in the entry, type 10 --> + <xsl:variable name="images" select="../tc:fields/tc:field[@type=10]"/> + <!-- only insert cell if at least one image --> + <xsl:if test="$entry/*[local-name(.) = $images[1]/@name]"> + <td valign="top" rowspan="2"> + <xsl:for-each select="$images"> + + <!-- images will never be multiple, so no need to check for that --> + <!-- find the value of the image field in the entry --> + <xsl:variable name="image" select="$entry/*[local-name(.) = current()/@name]"/> + <!-- check if the value is not empty --> + <xsl:if test="$image"> + <a> + <xsl:attribute name="href"> + <xsl:choose> + <!-- Amazon license requires the image to be linked to the amazon website --> + <xsl:when test="$entry/tc:amazon"> + <xsl:value-of select="$entry/tc:amazon"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <img alt=""> + <xsl:attribute name="src"> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:attribute> + <!-- limit to maximum width of 150 and height of 200 --> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="150"/> + <xsl:with-param name="limit-height" select="200"/> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + </xsl:call-template> + </img> + </a> + </xsl:if> + </xsl:for-each> + </td> + </xsl:if> + + <!-- want all the width we can get --> + <td valign="top"> + <!-- now a nested table with the general fields --> + <div id="banner"> + + <h1> + <xsl:choose> + <xsl:when test="count(.//tc:artist) = 1"> + <xsl:value-of select=".//tc:artist[1]"/> + </xsl:when> + <xsl:otherwise> + <i18n>(Various)</i18n> + </xsl:otherwise> + </xsl:choose> + <xsl:text> – </xsl:text> + <span class="title"> + <xsl:value-of select=".//tc:title[1]"/> + </span> + + <!-- Tellico 0.8 had multiple years in the default video collection --> + <xsl:if test=".//tc:year"> + <span class="year"> + <xsl:text> (</xsl:text> + <xsl:value-of select=".//tc:year[1]"/> + <xsl:text>)</xsl:text> + </span> + </xsl:if> + + </h1> + </div> + </td> + </tr> + <tr> + <td valign="top"> + + <table width="100%"> + <xsl:for-each select="key('fieldsByCat', $titleCat)"> + <xsl:if test="@name != 'title'"> + <tr> + <th> + <xsl:value-of select="@title"/> + </th> + <td class="fieldValue" width="100%"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </tr> + </xsl:if> + </xsl:for-each> + </table> + + </td> + </tr> + </table> + + <!-- doo all the track fields first --> + <xsl:variable name="artist" select="tc:artists/tc:artist[1]"/> + <xsl:for-each select="$tracks"> + <xsl:variable name="fieldName" select="current()/@name"/> + <xsl:call-template name="trackField"> + <xsl:with-param name="values" select="$entry/*[local-name()=concat($fieldName,'s')]"/> + <xsl:with-param name="name" select="$fieldName"/> + <xsl:with-param name="artist" select="$artist"/> + </xsl:call-template> + <!-- special case for tracks, since they're usually long tables. + clear after every 2nd table --> + <xsl:if test="position() mod 2 = 0"> + <br style="clear:left" /> + </xsl:if> + </xsl:for-each> + + <!-- now for every thing else --> + <!-- write categories other than general and images --> + <xsl:for-each select="$categories[. != $titleCat and + not(starts-with(key('fieldsByCat',.)[1]/@name,'track')) and + key('fieldsByCat',.)[1]/@type != 10]"> + + <xsl:variable name="category" select="."/> + <xsl:variable name="fields" select="key('fieldsByCat', $category)"/> + <xsl:variable name="first-type" select="$fields[1]/@type"/> + + <xsl:variable name="n" select="count($entry//*[key('fieldsByName',local-name(.))/@category=$category])"/> + + <!-- only output if there are field values in this category --> + <xsl:if test="$n > 0"> + <table width="50%" class="category"> + <tr class="category"> + <td colspan="2"> + <xsl:attribute name="colspan"> + <xsl:if test="$first-type = 2">1</xsl:if> + <xsl:if test="not($first-type = 2)">2</xsl:if> + </xsl:attribute> + <xsl:value-of select="."/> + </td> + </tr> + <xsl:for-each select="$fields"> + <xsl:if test="$entry//*[local-name(.)=current()/@name]"> + <tr> + <xsl:choose> + <!-- paragraphs --> + <xsl:when test="@type = 2"> + <td class="fieldValue" width="100%"> + <p> + <xsl:value-of select="$entry/*[local-name(.)=current()/@name]" disable-output-escaping="yes"/> + </p> + </td> + </xsl:when> + + <!-- tables are field type 8 --> + <!-- ok to put category name inside div instead of table here --> + <xsl:when test="@type = 8"> + <td> + <!-- look at number of columns --> + <xsl:choose> + <xsl:when test="tc:prop[@name = 'columns'] > 1"> + <table> + <xsl:if test="tc:prop[@name = 'column1']"> + <thead> + <tr> + <xsl:call-template name="columnTitle"> + <xsl:with-param name="index" select="1"/> + <xsl:with-param name="max" select="tc:prop[@name = 'columns']"/> + <xsl:with-param name="elem" select="'th'"/> + <xsl:with-param name="field" select="."/> + </xsl:call-template> + </tr> + </thead> + </xsl:if> + <tbody> + <xsl:for-each select="$entry//*[local-name(.) = current()/@name]"> + <tr> + <xsl:for-each select="tc:column"> + <td> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:when> + <xsl:otherwise> + <ul> + <xsl:for-each select="$entry//*[local-name(.) = current()/@name]"> + <li> + <xsl:value-of select="."/> + </li> + </xsl:for-each> + </ul> + </xsl:otherwise> + </xsl:choose> + </td> + </xsl:when> + + <!-- everything else --> + <xsl:otherwise> + <th> + <xsl:value-of select="@title"/> + </th> + <td class="fieldValue" width="100%"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </xsl:otherwise> + </xsl:choose> + </tr> + </xsl:if> + </xsl:for-each> + </table> + </xsl:if> + </xsl:for-each> +</xsl:template> + +<xsl:template name="trackField"> + <xsl:param name="values"/> + <xsl:param name="name"/> + <xsl:param name="artist"/> + <xsl:variable name="field" select="key('fieldsByName', $name)"/> + <table width="50%" class="category"> + <xsl:variable name="cols" select="count($values/*[1]/tc:column)"/> + + <tr class="category"> + <td colspan="{$cols}"> + <xsl:value-of select="$field/@category"/> + </td> + </tr> + <xsl:if test="$field/tc:prop[@name = 'column1']"> + <tr> + <th colspan="2" style="text-align:center"> + <xsl:value-of select="$field/tc:prop[@name = 'column1']"/> + <xsl:if test="not($values/*[1]/tc:column[2] = $artist)"> + <xsl:text> / </xsl:text> + <em><xsl:value-of select="$field/tc:prop[@name = 'column2']"/></em> + </xsl:if> + </th> + <th style="text-align:center"> + <xsl:value-of select="$field/tc:prop[@name = 'column3']"/> + </th> + <xsl:call-template name="columnTitle"> + <xsl:with-param name="index" select="4"/> + <xsl:with-param name="max" select="$cols"/> + <xsl:with-param name="elem" select="'th'"/> + <xsl:with-param name="field" select="$field"/> + </xsl:call-template> + + </tr> + </xsl:if> + + <xsl:for-each select="$values/*"> + <tr> + <th style="text-align:center"> + <xsl:value-of select="format-number(position(), '00')"/> + </th> + <xsl:choose> + <!-- a three column table could have an empty third column --> + <xsl:when test="$cols > 1"> + <!-- if it has three columns, assume first is title, + second is artist and third is track length. --> + <td class="fieldValue"> + <xsl:if test="string-length(tc:column[1])"> + <xsl:value-of select="tc:column[1]"/> + </xsl:if> + <xsl:if test="string-length(tc:column[2]) and not(tc:column[2] = $artist)"> + <xsl:text> / </xsl:text> + <em><xsl:value-of select="tc:column[2]"/></em> + </xsl:if> + </td> + <td class="fieldValue" style="text-align: right; padding-right: 10px"> + <em><xsl:value-of select="tc:column[3]"/></em> + </td> + </xsl:when> + <xsl:otherwise> + <td class="fieldValue"> + <xsl:value-of select="."/> + </td> + </xsl:otherwise> + </xsl:choose> + </tr> + </xsl:for-each> + + <!-- if it has multiple columns, + and the final one has a ':', add the time together --> + <!-- it should still work if the first row itself doesn't contain a ':' --> + <xsl:if test="$cols > 1 and + count($values/*[contains(tc:column[number($cols)], ':')])"> + <tr> + <th colspan="2" style="text-align: right; padding-right: 10px;"> + <strong><i18n>Total:</i18n> </strong> + </th> + <td class="fieldValue" style="text-align: right; padding-right: 10px"> + <em> + <xsl:call-template name="sumTime"> + <xsl:with-param name="nodes" select="$values//tc:column[number($cols)]"/> + </xsl:call-template> + </em> + </td> + </tr> + </xsl:if> + </table> +</xsl:template> + +</xsl:stylesheet> diff --git a/xslt/entry-templates/Compact.xsl b/xslt/entry-templates/Compact.xsl new file mode 100644 index 0000000..f523d68 --- /dev/null +++ b/xslt/entry-templates/Compact.xsl @@ -0,0 +1,294 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - compact template for viewing entry data + + Copyright (C) 2003-2006 Robby Stephenson - [email protected] + + The drop-shadow effect is based on the "A List Apart" method + at http://www.alistapart.com/articles/cssdropshadows/ + + Known Issues: + o Dependent titles have no value in the entry element. + o Bool and URL fields are assumed to never have multiple values. + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> +<xsl:param name="font"/> <!-- font family --> +<xsl:param name="fontsize"/> <!-- font size --> +<xsl:param name="fgcolor"/> <!-- foreground color --> +<xsl:param name="bgcolor"/> <!-- background color --> + +<xsl:param name="collection-file"/> <!-- might have a link to parent collection --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:variable name="endl"> +<xsl:text> +</xsl:text> +</xsl:variable> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<!-- The default layout is pretty boring, but catches every field value in + the entry. The title is in the top H1 element. --> +<xsl:template match="tc:tellico"> + <!-- This stylesheet is designed for Tellico document syntax version 10 --> + <xsl:call-template name="syntax-version"> + <xsl:with-param name="this-version" select="'10'"/> + <xsl:with-param name="data-version" select="@syntaxVersion"/> + </xsl:call-template> + + <html> + <head> + <style type="text/css"> + body { + margin: 0px; + padding: 0px; + font-family: <xsl:value-of select="$font"/>; + font-size: <xsl:value-of select="$fontsize"/>pt; + color: <xsl:value-of select="$fgcolor"/>; + background-color: <xsl:value-of select="$bgcolor"/>; + } + #content { + padding-right: 160px; + } + #images { + margin: 6px 5px 0px 5px; + float: right; + min-width: 150px; + } + div.img-shadow { + float: left; + background: url(<xsl:value-of select="concat($datadir,'shadowAlpha.png')"/>) no-repeat bottom right; + margin: 10px 0 0 10px; + } + div.img-shadow img { + display: block; + position: relative; + border: 1px solid #a9a9a9; + margin: -6px 6px 6px -6px; + } + table { + border-collapse: collapse; + border-spacing: 0px; + } + th.fieldName { + font-weight: bold; + text-align: left; + padding: 0px 4px 0px 2px; + white-space: nowrap; + } + td.fieldValue { + text-align: left; + padding: 0px 10px 0px 2px; + } + td.column1 { + text-align: left; + padding: 0px; + } + td.column2 { + font-style: italic; + text-align: left; + padding: 0px 10px; + } + p { + margin-top: 0px; + text-align: left; + } + ul { + margin-top: 0px; + margin-bottom: 0px; + padding: 0px 0px 0px 20px; + } + img { + border: 0px; + } + p.navigation { + font-weight: bold; + text-align: center; + clear: both; + } + </style> + <title> + <xsl:value-of select="tc:collection/tc:entry[1]//tc:title[1]"/> + <xsl:text> – </xsl:text> + <xsl:value-of select="tc:collection/@title"/> + </title> + </head> + <body> + <xsl:apply-templates select="tc:collection[1]"/> + <xsl:if test="$collection-file"> + <p class="navigation"> + <a href="{$collection-file}"><< <xsl:value-of select="tc:collection/@title"/></a> + </p> + </xsl:if> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <xsl:apply-templates select="tc:entry[1]"/> +</xsl:template> + +<xsl:template match="tc:entry"> + <xsl:variable name="entry" select="."/> + + <!-- all the images are in a div, aligned to the right side and floated--> + <div id="images"> + <!-- images are field type 10 --> + <xsl:for-each select="../tc:fields/tc:field[@type=10]"> + + <!-- find the value of the image field in the entry --> + <xsl:variable name="image" select="$entry/*[local-name(.) = current()/@name]"/> + <!-- check if the value is not empty --> + <xsl:if test="$image"> + <div class="img-shadow"> + <a> + <xsl:attribute name="href"> + <xsl:choose> + <!-- Amazon license requires the image to be linked to the amazon website --> + <xsl:when test="$entry/tc:amazon"> + <xsl:value-of select="$entry/tc:amazon"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <img alt=""> + <xsl:attribute name="src"> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:attribute> + <!-- limit to maximum width of 150 and height of 200 --> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="150"/> + <xsl:with-param name="limit-height" select="200"/> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + </xsl:call-template> + </img> + </a> + </div> + <br/> <!-- needed since the img-shadow block floats --> + </xsl:if> + </xsl:for-each> + </div> + + <!-- all the data is in the content block --> + <div id="content"> + + <!-- now for all the rest of the data --> + <!-- iterate over the categories, but skip images --> + <table> + <tbody> + <xsl:for-each select="../tc:fields/tc:field[@type!=10]"> + <xsl:variable name="field" select="."/> + + <xsl:if test="$entry//*[local-name(.) = $field/@name]"> + <tr> + <th class="fieldName" valign="top"> + <xsl:value-of select="@title"/> + <xsl:text>:</xsl:text> + </th> + + <td class="fieldValue"> + <!-- ok, big xsl:choose loop for field type --> + <xsl:choose> + + <!-- paragraphs are field type 2 --> + <xsl:when test="@type = 2"> + <p> + <xsl:value-of select="$entry/*[local-name(.) = $field/@name]" disable-output-escaping="yes"/> + </p> + </xsl:when> + + <!-- tables are field type 8 --> + <!-- ok to put category name inside div instead of table here --> + <xsl:when test="@type = 8"> + <!-- look at number of columns --> + <xsl:choose> + <xsl:when test="$field/tc:prop[@name = 'columns'] > 1"> + <table> + <tbody> + <xsl:for-each select="$entry//*[local-name(.) = $field/@name]"> + <tr> + <xsl:for-each select="tc:column"> + <xsl:choose> + <xsl:when test="position() = 1"> + <td class="column1"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:when> + <xsl:otherwise> + <td class="column2"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:when> + <xsl:otherwise> + <ul> + <xsl:for-each select="$entry//*[local-name(.) = $field/@name]"> + <li> + <xsl:value-of select="."/> + </li> + </xsl:for-each> + </ul> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:otherwise> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$field/@name"/> + </xsl:call-template> + </xsl:otherwise> + + </xsl:choose> + </td> + </tr> + </xsl:if> + </xsl:for-each> + </tbody> + </table> + </div> +</xsl:template> + +</xsl:stylesheet> diff --git a/xslt/entry-templates/Default.xsl b/xslt/entry-templates/Default.xsl new file mode 100644 index 0000000..fcd01fd --- /dev/null +++ b/xslt/entry-templates/Default.xsl @@ -0,0 +1,346 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - classic template for viewing entry data + + Copyright (C) 2003-2006 Robby Stephenson - [email protected] + + Known Issues: + o Dependent titles have no value in the entry element. + o Bool and URL fields are assumed to never have multiple values. + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" + doctype-system="http://www.w3.org/TR/html4/loose.dtd" + encoding="utf-8"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> +<xsl:param name="font"/> <!-- font family --> +<xsl:param name="fontsize"/> <!-- font size --> +<xsl:param name="fgcolor"/> <!-- foreground color --> +<xsl:param name="bgcolor"/> <!-- background color --> +<xsl:param name="color1"/> <!-- highlighted text color --> +<xsl:param name="color2"/> <!-- highlighted background color --> + +<xsl:param name="collection-file"/> <!-- might have a link to parent collection --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="fieldsByCat" match="tc:field" use="@category"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:variable name="endl"> +<xsl:text> +</xsl:text> +</xsl:variable> + +<!-- all the categories --> +<xsl:variable name="categories" select="/tc:tellico/tc:collection/tc:fields/tc:field[generate-id(.)=generate-id(key('fieldsByCat',@category)[1])]/@category"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<!-- The default layout is pretty boring, but catches every field value in + the entry. The title is in the top H1 element. --> +<xsl:template match="tc:tellico"> + <!-- This stylesheet is designed for Tellico document syntax version 10 --> + <xsl:call-template name="syntax-version"> + <xsl:with-param name="this-version" select="'10'"/> + <xsl:with-param name="data-version" select="@syntaxVersion"/> + </xsl:call-template> + + <html> + <head> + <style type="text/css"> + body { + margin: 4px; + padding: 0px; + font-family: "<xsl:value-of select="$font"/>"; + font-size: <xsl:value-of select="$fontsize"/>pt; + color: <xsl:value-of select="$fgcolor"/>; + background-color: <xsl:value-of select="$bgcolor"/>; + } + h1.title { + font-size: 1.8em; + padding: 0px; + padding-top: 2px; + padding-bottom: 2px; + margin: 0px; + text-align: center; + font-weight: bold; + } + img { + padding-right: 10px; + border: 0px; + } + table.category { + margin-bottom: 1em; + float: left; + } + tr.category { + font-weight: bold; + font-size: 1.2em; + color: <xsl:value-of select="$color1"/>; + background-color: <xsl:value-of select="$color2"/>; + text-align: center; + } + th { + font-weight: bold; + text-align: left; + color: #fff; + background-color: #666; + padding-left: 3px; + padding-right: 3px; + } + td { + padding: 0 .2em; + } + p { + margin-top: 0px; + text-align: justify; + } + img { + border: 0px solid; + } + p.navigation { + clear: both; + font-weight: bold; + text-align: center; + clear: both; + } + </style> + <title> + <xsl:value-of select="tc:collection/tc:entry[1]//tc:title[1]"/> + <xsl:text> – </xsl:text> + <xsl:value-of select="tc:collection/@title"/> + </title> + </head> + <body> + <xsl:apply-templates select="tc:collection[1]"/> + <xsl:if test="$collection-file"> + <p class="navigation"> + <a href="{$collection-file}"><< <xsl:value-of select="tc:collection/@title"/></a> + </p> + </xsl:if> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <xsl:apply-templates select="tc:entry[1]"/> +</xsl:template> + +<xsl:template match="tc:entry"> + <xsl:variable name="entry" select="."/> + + <!-- first, show the title --> + <xsl:if test=".//tc:title"> + <h1> + <xsl:for-each select=".//tc:title"> + <xsl:value-of select="."/> + <xsl:if test="position() < last()"> + <br/> + </xsl:if> + </xsl:for-each> + </h1> + </xsl:if> + + <!-- put the general category and all images in top table, one cell for each --> + <xsl:variable name="cat1" select="key('fieldsByName','title')/@category"/> + <table width="100%"> + <tr> + <td valign="top"> + <!-- show the general group, or more accurately, the title's group --> + <table class="category" width="100%"> + <tr class="category"> + <td colspan="2"> + <xsl:value-of select="$cat1"/> + </td> + </tr> + <xsl:for-each select="key('fieldsByCat', $cat1)"> + <xsl:if test="@name!='title'"> + <tr> + <th> + <xsl:value-of select="@title"/> + </th> + <td width="75%"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </tr> + </xsl:if> + </xsl:for-each> + </table> + </td> + <!-- now, show all the images in the entry, type 10 --> + <xsl:variable name="images" select="../tc:fields/tc:field[@type=10]"/> + <xsl:if test="count($images) > 0"> + <!-- now, show all the images in the entry, type 10 --> + <xsl:for-each select="$images"> + + <!-- images will never be multiple, so no need to check for that --> + <!-- find the value of the image field in the entry --> + <xsl:variable name="image" select="$entry/*[local-name(.) = current()/@name]"/> + <!-- check if the value is not empty --> + <xsl:if test="$image"> + <td valign="top"> + <table class="category"> + <tr class="category"> + <td> + <xsl:value-of select="current()/@title"/> + </td> + </tr> + <tr> + <td> + <a> + <xsl:attribute name="href"> + <xsl:choose> + <!-- Amazon license requires the image to be linked to the amazon website --> + <xsl:when test="$entry/tc:amazon"> + <xsl:value-of select="$entry/tc:amazon"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <img alt=""> + <xsl:attribute name="src"> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:attribute> + <!-- limit to maximum width of 150 of height of 200 --> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="150"/> + <xsl:with-param name="limit-height" select="200"/> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + </xsl:call-template> + </img> + </a> + </td> + </tr> + </table> + </td> + </xsl:if> + </xsl:for-each> + </xsl:if> + </tr> + </table> + + <!-- write categories other than general and images --> + <xsl:for-each select="$categories[. != $cat1 and + key('fieldsByCat',.)[1]/@type!=10]"> + <table width="50%" class="category"> + <tr class="category"> + <td colspan="2"> + <xsl:value-of select="."/> + </td> + </tr> + <xsl:for-each select="key('fieldsByCat', .)"> + <tr> + <xsl:choose> + <!-- paragraphs --> + <xsl:when test="@type = 2"> + <td> + <p> + <xsl:value-of select="$entry/*[local-name(.)=current()/@name]" disable-output-escaping="yes"/> + </p> + </td> + </xsl:when> + + <!-- tables are field type 8 --> + <!-- ok to put category name inside div instead of table here --> + <xsl:when test="@type = 8"> + <td> + <!-- look at number of columns --> + <xsl:choose> + <xsl:when test="tc:prop[@name = 'columns'] > 1"> + <table width="100%"> + <xsl:if test="tc:prop[@name = 'column1']"> + <thead> + <tr> + <th width="50%"> + <xsl:value-of select="tc:prop[@name = 'column1']"/> + </th> + <th width="50%"> + <xsl:value-of select="tc:prop[@name = 'column2']"/> + </th> + <xsl:call-template name="columnTitle"> + <xsl:with-param name="index" select="3"/> + <xsl:with-param name="max" select="tc:prop[@name = 'columns']"/> + <xsl:with-param name="elem" select="'th'"/> + <xsl:with-param name="field" select="."/> + </xsl:call-template> + </tr> + </thead> + </xsl:if> + <tbody> + <xsl:for-each select="$entry//*[local-name(.) = current()/@name]"> + <tr> + <xsl:for-each select="tc:column"> + <td width="{floor(100 div count(../tc:column))}%"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:when> + <xsl:otherwise> + <ul> + <xsl:for-each select="$entry//*[local-name(.) = current()/@name]"> + <li> + <xsl:value-of select="."/> + </li> + </xsl:for-each> + </ul> + </xsl:otherwise> + </xsl:choose> + </td> + </xsl:when> + + <!-- everything else --> + <xsl:otherwise> + <th> + <xsl:value-of select="@title"/> + </th> + <td> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </xsl:otherwise> + </xsl:choose> + </tr> + </xsl:for-each> + </table> + </xsl:for-each> +</xsl:template> + +</xsl:stylesheet> diff --git a/xslt/entry-templates/Fancy.xsl b/xslt/entry-templates/Fancy.xsl new file mode 100644 index 0000000..875309f --- /dev/null +++ b/xslt/entry-templates/Fancy.xsl @@ -0,0 +1,444 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - fancy template for viewing entry data + + Copyright (C) 2003-2006 Robby Stephenson - [email protected] + + The drop-shadow effect is based on the "A List Apart" method + at http://www.alistapart.com/articles/cssdropshadows/ + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> +<xsl:param name="font"/> <!-- font family --> +<xsl:param name="fontsize"/> <!-- font size --> +<xsl:param name="fgcolor"/> <!-- foreground color --> +<xsl:param name="bgcolor"/> <!-- background color --> +<xsl:param name="color1"/> <!-- highlighted text color --> +<xsl:param name="color2"/> <!-- highlighted background color --> + +<xsl:param name="collection-file"/> <!-- might have a link to parent collection --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="fieldsByCat" match="tc:field" use="@category"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:variable name="image-width" select="'150'"/> +<xsl:variable name="image-height" select="'200'"/> +<xsl:variable name="endl"> +<xsl:text> +</xsl:text> +</xsl:variable> + +<!-- all the categories --> +<xsl:variable name="categories" select="/tc:tellico/tc:collection/tc:fields/tc:field[generate-id(.)=generate-id(key('fieldsByCat',@category)[1])]/@category"/> +<!-- layout changes depending on whether there are images or not --> +<xsl:variable name="num-images" select="count(tc:tellico/tc:collection/tc:entry[1]/*[key('fieldsByName',local-name(.))/@type = 10])"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<!-- The default layout is pretty boring, but catches every field value in + the entry. The title is in the top H1 element. --> +<xsl:template match="tc:tellico"> + <!-- This stylesheet is designed for Tellico document syntax version 10 --> + <xsl:call-template name="syntax-version"> + <xsl:with-param name="this-version" select="'10'"/> + <xsl:with-param name="data-version" select="@syntaxVersion"/> + </xsl:call-template> + + <html> + <head> + <style type="text/css"> + body { + margin: 0px; + padding: 0px; + font-family: "<xsl:value-of select="$font"/>"; + font-size: <xsl:value-of select="$fontsize"/>pt; + color: <xsl:value-of select="$fgcolor"/>; + background-color: <xsl:value-of select="$bgcolor"/>; + background-image: url(<xsl:value-of select="concat($imgdir, 'gradient_bg.png')"/>); + background-repeat: repeat; + } + h1 { + margin: 0px; + padding: 0px; + font-size: 1.8em; + color: <xsl:value-of select="$color1"/>; + background-color: <xsl:value-of select="$color2"/>; + background-image: url(<xsl:value-of select="concat($imgdir, 'gradient_header.png')"/>); + background-repeat: repeat-x; + border-bottom: 1px outset black; + text-align: center; + } + <xsl:if test="$num-images > 0"> + div#images { + margin: 10px 5px 0px 5px; + float: right; + min-width: <xsl:value-of select="$image-width"/>px; /* min-width instead of width, stylesheet actually scales image */ + } + </xsl:if> + div.img-shadow { + float: left; + background: url(<xsl:value-of select="concat($datadir,'shadowAlpha.png')"/>) no-repeat bottom right; + margin: 6px 0 10px 10px; + clear: left; + } + div.img-shadow img { + display: block; + position: relative; + border: 1px solid #a9a9a9; + margin: -6px 6px 6px -6px; + } + h3 { + text-align: center; + font-size: 1.1em; + } + div#content { + padding-left: 1%; + padding-right: 1%; + } + div.category { + padding: 0px 0px 0px 4px; + margin: 8px; + border: 1px solid <xsl:value-of select="$fgcolor"/>; + text-align: center; + /* if background is grey, text has to be black */ + color: #000; + background-color: #ccc; + min-height: 1em; + overflow: hidden; + } + h2 { + color: <xsl:value-of select="$color1"/>; + background-color: <xsl:value-of select="$color2"/>; + background-image: url(<xsl:value-of select="concat($imgdir, 'gradient_header.png')"/>); + background-repeat: repeat-x; + border-bottom: 1px outset; + border-color: <xsl:value-of select="$fgcolor"/>; + padding: 0px 8px 0px 0px; + margin: 0px 0px 2px -4px; /* -4px to match .category padding */ + font-size: 1.0em; + top: -1px; + font-style: normal; + text-align: right; + } + table { + border-collapse: collapse; + border-spacing: 0px; + max-width: 100%; + } + tr.table-columns { + font-style: italic; + } + th.fieldName { + font-weight: bolder; + text-align: left; + padding: 0px 4px 0px 2px; + white-space: nowrap; + } + td.fieldValue { + text-align: left; + padding: 0px 10px 0px 2px; + vertical-align: top; + width: 90%; /* nowrap is set on the fieldName column, so just want enough width to take the rest */ + } + td.column1 { + font-weight: bold; + text-align: left; + padding: 0px 2px 0px 2px; +/* white-space: nowrap;*/ + } + td.column2 { + font-style: italic; + text-align: left; + padding: 0px 10px 0px 10px; +/* width: 90%; nowrap is set on the fieldName column, so just want enough width to take the rest */ + } + p { + margin: 2px 10px 2px 0; + padding: 0px; + text-align: justify; + font-size: 90%; + } + ul { + text-align: left; + margin: 0px 0px 0px 0px; + padding-left: 20px; + } + img { + border: 0px; + } + p.navigation { + font-weight: bold; + text-align: center; + clear: both; + } + </style> + <title> + <xsl:value-of select="tc:collection[1]/tc:entry[1]//tc:title[1]"/> + <xsl:text> – </xsl:text> + <xsl:value-of select="tc:collection[1]/@title"/> + </title> + </head> + <body> + <xsl:apply-templates select="tc:collection[1]"/> + <xsl:if test="$collection-file"> + <p class="navigation"> + <a href="{$collection-file}"><< <xsl:value-of select="tc:collection/@title"/></a> + </p> + </xsl:if> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <xsl:apply-templates select="tc:entry[1]"/> +</xsl:template> + +<xsl:template match="tc:entry"> + <xsl:variable name="entry" select="."/> + + <!-- first, show the title --> + <xsl:if test=".//tc:title"> + <h1> + <xsl:for-each select=".//tc:title"> + <xsl:value-of select="."/> + <xsl:if test="position() < last()"> + <br/> + </xsl:if> + </xsl:for-each> + </h1> + </xsl:if> + + <!-- all the images are in a div, aligned to the right side and floated --> + <!-- only want this div if there are any images in the entry --> + <xsl:if test="$num-images > 0"> + <div id="images"> + <!-- images are field type 10 --> + <xsl:for-each select="../tc:fields/tc:field[@type=10]"> + + <!-- find the value of the image field in the entry --> + <xsl:variable name="image" select="$entry/*[local-name(.) = current()/@name]"/> + <!-- check if the value is not empty --> + <xsl:if test="$image"> + <div class="img-shadow"> + <a> + <xsl:attribute name="href"> + <xsl:choose> + <!-- Amazon license requires the image to be linked to the amazon website --> + <xsl:when test="$entry/tc:amazon"> + <xsl:value-of select="$entry/tc:amazon"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <img alt="" style="vertical-align:bottom;"> + <xsl:attribute name="src"> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:attribute> + <!-- limit to maximum width of 150 and height of 200 --> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="$image-width"/> + <xsl:with-param name="limit-height" select="$image-height"/> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + </xsl:call-template> + </img> + </a> + </div> + <br/> <!-- needed since the img-shadow block floats --> + </xsl:if> + </xsl:for-each> + </div> + </xsl:if> + + <!-- all the data is in the content block --> + <div id="content"> + <!-- now for all the rest of the data --> + <!-- iterate over the categories, but skip paragraphs and images --> + <xsl:for-each select="$categories[key('fieldsByCat',.)[1]/@type != 2 and key('fieldsByCat',.)[1]/@type != 10]"> + <xsl:call-template name="output-category"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="category" select="."/> + </xsl:call-template> + </xsl:for-each> + + <!-- now do paragraphs --> + <xsl:for-each select="$categories[key('fieldsByCat',.)[1]/@type = 2]"> + <xsl:call-template name="output-category"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="category" select="."/> + </xsl:call-template> + </xsl:for-each> + + </div> + +</xsl:template> + +<xsl:template name="output-category"> + <xsl:param name="entry"/> + <xsl:param name="category"/> + + <xsl:variable name="fields" select="key('fieldsByCat', $category)"/> + <xsl:variable name="first-type" select="$fields[1]/@type"/> + + <xsl:variable name="n" select="count($entry//*[key('fieldsByName',local-name(.))/@category=$category])"/> + <!-- only output if there are fields in this category + also, special case, don't output empty paragraphs --> + <xsl:if test="$n > 0 and (not($first-type = 2) or $entry/*[local-name(.) = $fields[1]/@name])"> + <div class="container"> + <xsl:if test="$num-images = 0 and $first-type != 2"> + <xsl:attribute name="style"> + <xsl:text>width: 50%; </xsl:text> + <!-- two columns of divs --> + <xsl:choose> + <xsl:when test="$categories[. = $category and position() mod 2 = 1]"> + <xsl:text>float: left; clear: both;</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>float: right;</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + <xsl:if test="$num-images = 0 and $first-type = 2"> + <xsl:attribute name="style"> + <xsl:text>width: 100%; float: left; clear: both;</xsl:text> + </xsl:attribute> + </xsl:if> + <div class="category"> + + <h2> + <xsl:value-of select="$category"/> + </h2> + <!-- ok, big xsl:choose loop for field type --> + <xsl:choose> + + <!-- paragraphs are field type 2 --> + <xsl:when test="$first-type = 2"> + <p> + <!-- disabling the output escaping allows html --> + <xsl:value-of select="$entry/*[local-name(.) = $fields[1]/@name]" disable-output-escaping="yes"/> + </p> + </xsl:when> + + <!-- tables are field type 8 --> + <!-- ok to put category name inside div instead of table here --> + <xsl:when test="$first-type = 8"> + <!-- look at number of columns --> + <xsl:choose> + <xsl:when test="$fields[1]/tc:prop[@name = 'columns'] > 1"> + <table width="100%"> + <xsl:if test="$fields[1]/tc:prop[@name = 'column1']"> + <thead> + <tr class="table-columns"> + <th width="50%"> + <xsl:value-of select="$fields[1]/tc:prop[@name = 'column1']"/> + </th> + <th width="50%"> + <xsl:value-of select="$fields[1]/tc:prop[@name = 'column2']"/> + </th> + <xsl:call-template name="columnTitle"> + <xsl:with-param name="index" select="3"/> + <xsl:with-param name="max" select="$fields[1]/tc:prop[@name = 'columns']"/> + <xsl:with-param name="elem" select="'th'"/> + <xsl:with-param name="field" select="$fields[1]"/> + </xsl:call-template> + </tr> + </thead> + </xsl:if> + <tbody> + <xsl:for-each select="$entry//*[local-name(.) = $fields[1]/@name]"> + <tr> + <xsl:for-each select="tc:column"> + <xsl:choose> + <xsl:when test="position() = 1"> + <td class="column1"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:when> + <xsl:otherwise> + <td class="column2"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:when> + <xsl:otherwise> + <ul> + <xsl:for-each select="$entry//*[local-name(.) = $fields[1]/@name]"> + <li> + <xsl:value-of select="."/> + </li> + </xsl:for-each> + </ul> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:otherwise> + <table> + <tbody> + <!-- already used title, so skip it --> + <xsl:for-each select="$fields[@name != 'title']"> + <tr> + <th class="fieldName" valign="top"> + <xsl:value-of select="@title"/> + <xsl:text>:</xsl:text> + </th> + <td class="fieldValue"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </tr> + </xsl:for-each> + </tbody> + </table> + + </xsl:otherwise> + </xsl:choose> + + </div> + </div> + </xsl:if> +</xsl:template> + +</xsl:stylesheet> diff --git a/xslt/entry-templates/Makefile.am b/xslt/entry-templates/Makefile.am new file mode 100644 index 0000000..5b1b875 --- /dev/null +++ b/xslt/entry-templates/Makefile.am @@ -0,0 +1,17 @@ +####### kdevelop will overwrite this part!!! (begin)########## + + +EXTRA_DIST = Default.xsl Video.xsl Album.xsl Fancy.xsl Compact.xsl + +####### kdevelop will overwrite this part!!! (end)############ + +xsldir = $(kde_datadir)/tellico/entry-templates +xsl_DATA = Default.xsl Video.xsl Album.xsl Fancy.xsl Compact.xsl + +KDE_OPTIONS = noautodist + +CLEANFILES = *~ + +# probably a better way to do this +uninstall-hook: + -if [ -d $(xsldir) ]; then rmdir $(xsldir); fi diff --git a/xslt/entry-templates/Video.xsl b/xslt/entry-templates/Video.xsl new file mode 100644 index 0000000..c74e88e --- /dev/null +++ b/xslt/entry-templates/Video.xsl @@ -0,0 +1,512 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Entry template for videos + + Copyright (C) 2003-2006 Robby Stephenson - [email protected] + + Known Issues: + o If there is more an one image, there's a lot of white space under + the top tables. + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> +<xsl:param name="font"/> <!-- font family --> +<xsl:param name="fontsize"/> <!-- font size --> +<xsl:param name="fgcolor"/> <!-- foreground color --> +<xsl:param name="bgcolor"/> <!-- background color --> +<xsl:param name="color1"/> <!-- highlighted text color --> +<xsl:param name="color2"/> <!-- highlighted background color --> + +<xsl:param name="collection-file"/> <!-- might have a link to parent collection --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="fieldsByCat" match="tc:field" use="@category"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:variable name="endl"> +<xsl:text> +</xsl:text> +</xsl:variable> + +<!-- all the categories --> +<xsl:variable name="categories" select="/tc:tellico/tc:collection/tc:fields/tc:field[generate-id(.)=generate-id(key('fieldsByCat',@category)[1])]/@category"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<!-- The default layout is pretty boring, but catches every field value in + the entry. The title is in the top H1 element. --> +<xsl:template match="tc:tellico"> + <!-- This stylesheet is designed for Tellico document syntax version 10 --> + <xsl:call-template name="syntax-version"> + <xsl:with-param name="this-version" select="'10'"/> + <xsl:with-param name="data-version" select="@syntaxVersion"/> + </xsl:call-template> + + <html> + <head> + <style type="text/css"> + body { + margin: .2em 1%; + padding: 0; + font-family: "<xsl:value-of select="$font"/>", Arial, Helvetica, sans-serif; + font-size: <xsl:value-of select="$fontsize"/>pt; + color: <xsl:value-of select="$fgcolor"/>; + background: <xsl:value-of select="$bgcolor"/>; + line-height: 1.6; + } + div#banner { + padding-bottom: .1em; + margin-bottom: .4em; + border-bottom: .2em ridge <xsl:value-of select="$color2"/>; + } + img#logo { + padding-left: .5em; + padding-top: .4em; + float: right; + } + h1 { + color: <xsl:value-of select="$color2"/>; + font-size: 1.8em; + text-align: left; + padding: .2em; + margin: 0; + font-weight: bold; + } + span.year { + font-size: 0.8em; + } + span.country { + font-style: italic; + } + h2 { + font-size: 1.2em; + margin: 0; + padding: 0; + padding-left: .2em; + } + img { + padding-right: 1em; + padding-bottom: 1em; + } + table.category { + margin-right: 1%; + margin-bottom: 1em; + float: left; + border-collapse: collapse; + border-spacing: 0px; + } + tr.category { + font-weight: bold; + font-size: 1.2em; + color: <xsl:value-of select="$color1"/>; + background: <xsl:value-of select="$color2"/>; + text-align: center; + } + /* there seems to be a khtml bug, in 3.4.x at least, repeat-x doesn't + work on the tr element, so have to put it on the th element */ + tr.category th { + background-image: url(<xsl:value-of select="concat($imgdir, 'gradient_header.png')"/>); + background-repeat: repeat-x; + } + th { + font-weight: bold; + text-align: left; + color: <xsl:value-of select="$color2"/>; + background <xsl:value-of select="$color1"/>; + padding: 0px 0.2em 0px 0.2em; + white-space: nowrap; + } + thead th { + color: <xsl:value-of select="$color1"/>; + background <xsl:value-of select="$color2"/>; + text-align: center; + } + td { + padding: 0px 0.2em 0px 0.2em; + } + td.role { + font-style: italic; + } + p { + margin-top: 0; + text-align: justify; + font-size: .9em; + } + ul { + margin-top: .3em; + margin-bottom: .3em; + margin-left: 0; + padding: 0 0 0 1.5em; + } + img { + border: 0px; + } + p.navigation { + font-weight: bold; + text-align: center; + clear: both; + } + </style> + <title> + <xsl:value-of select="tc:collection/tc:entry[1]//tc:title[1]"/> + <xsl:text> – </xsl:text> + <xsl:value-of select="tc:collection/@title"/> + </title> + </head> + <body> + <xsl:apply-templates select="tc:collection[1]"/> + <xsl:if test="$collection-file"> + <p class="navigation"> + <a href="{$collection-file}"><< <xsl:value-of select="tc:collection/@title"/></a> + </p> + </xsl:if> + </body> + </html> +</xsl:template> + +<!-- type 3 is video collections --> +<!-- warn user that this template is meant for videos only. --> +<xsl:template match="tc:collection[@type!=3]"> + <h1><i18n>This template is meant for video collections only.</i18n></h1> +</xsl:template> + +<xsl:template match="tc:collection[@type=3]"> + <xsl:apply-templates select="tc:entry[1]"/> +</xsl:template> + +<xsl:template match="tc:entry"> + <xsl:variable name="entry" select="."/> + <xsl:variable name="titleCat" select="key('fieldsByName','title')/@category"/> + <!-- there might not be a cast --> + <xsl:variable name="castCat"> + <xsl:choose> + <xsl:when test="tc:casts"> + <xsl:value-of select="key('fieldsByName','cast')/@category"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="''"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <div id="banner"> + <!-- do format logo --> + <xsl:choose> + <xsl:when test="$datadir and tc:medium = 'DVD'"> + <img width="74" height="30" id="logo" alt="(DVD)"> + <xsl:attribute name="src"> + <xsl:value-of select="concat($datadir,'dvd-logo.png')"/> + </xsl:attribute> + </img> + </xsl:when> + <xsl:when test="$datadir and tc:medium = 'VHS'"> + <img width="56" height="30" id="logo" alt="(VHS)"> + <xsl:attribute name="src"> + <xsl:value-of select="concat($datadir,'vhs-logo.png')"/> + </xsl:attribute> + </img> + </xsl:when> + <xsl:when test="$datadir and tc:medium = 'Blu-ray'"> + <img width="56" height="30" id="logo" alt="(Blu-ray)"> + <xsl:attribute name="src"> + <xsl:value-of select="concat($datadir,'bluray-logo.png')"/> + </xsl:attribute> + </img> + </xsl:when> + <xsl:when test="$datadir and tc:medium = 'HD DVD'"> + <img width="119" height="30" id="logo" alt="(HD DVD)"> + <xsl:attribute name="src"> + <xsl:value-of select="concat($datadir,'hddvd-logo.png')"/> + </xsl:attribute> + </img> + </xsl:when> + </xsl:choose> + + <!-- title block --> + <h1> + <xsl:value-of select=".//tc:title[1]"/> + <xsl:if test="tc:widescreen"><xsl:text/> + <xsl:text> – </xsl:text><xsl:value-of select="key('fieldsByName', 'widescreen')/@title"/><xsl:text/> + </xsl:if> + <xsl:if test="tc:directors-cut"><xsl:text/> + <xsl:text> – </xsl:text><xsl:value-of select="key('fieldsByName', 'directors-cut')/@title"/><xsl:text/> + </xsl:if> + <xsl:if test=".//tc:year|.//tc:nationality"> + <span class="year"> + <xsl:text> (</xsl:text> + <xsl:if test=".//tc:year"> + <xsl:value-of select=".//tc:year[1]"/> + </xsl:if> + <xsl:if test=".//tc:nationality"> + <xsl:if test=".//tc:year"> + <xsl:text> – </xsl:text> + </xsl:if> + <span class="country"> + <xsl:value-of select=".//tc:nationality[1]"/> + </span> + </xsl:if> + <xsl:text>)</xsl:text> + </span> + </xsl:if> + </h1> + + </div> + + <!-- the images and the rest of the categories are each in a table in a table cell --> + <table class="category" width="100%"> + <tbody> + <tr> + <td valign="top"> + + <!-- now, show all the images in the entry, field type 10 --> + <xsl:variable name="images" select="../tc:fields/tc:field[@type=10]"/> + <xsl:if test="count($images) > 0"> + <table> + <tbody> + <!-- now, show all the images in the entry, type 10 --> + <xsl:for-each select="$images"> + <tr> + <td> + + <!-- images will never be multiple, so no need to check for that --> + <!-- find the value of the image field in the entry --> + <xsl:variable name="image" select="$entry/*[local-name(.) = current()/@name]"/> + <!-- check if the value is not empty --> + <xsl:if test="$image"> + <a> + <xsl:attribute name="href"> + <xsl:choose> + <!-- Amazon license requires the image to be linked to the amazon website --> + <xsl:when test="$entry/tc:amazon"> + <xsl:value-of select="$entry/tc:amazon"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <img alt=""> + <xsl:attribute name="src"> + <xsl:call-template name="image-link"> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + <xsl:with-param name="dir" select="$imgdir"/> + </xsl:call-template> + </xsl:attribute> + <!-- limit to maximum width of 200 of height of 300 --> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="200"/> + <xsl:with-param name="limit-height" select="300"/> + <xsl:with-param name="image" select="key('imagesById', $image)"/> + </xsl:call-template> + </img> + </a> + </xsl:if> + </td> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:if> + </td> + + <td valign="top"> + + <!-- show the general group, or more accurately, the title's group --> + <table width="49%" class="category"> + <thead> + <tr class="category"> + <th colspan="2"> + <xsl:value-of select="$titleCat"/> + </th> + </tr> + </thead> + <tbody> + <!-- the year and nationality have already been shown, but the film + might have multiple values, so go ahead and show them again --> + <xsl:for-each select="key('fieldsByCat', $titleCat)"> + <xsl:if test="@name != 'title'"> + <tr> + <th> + <xsl:value-of select="@title"/> + </th> + <td> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </tr> + </xsl:if> + </xsl:for-each> + </tbody> + </table> + + <!-- now for the cast --> + <xsl:if test="tc:casts"> + <xsl:variable name="castField" select="key('fieldsByName', 'cast')"/> + <table width="49%" class="category"> + <thead> + <tr class="category"> + <th colspan="2"> + <xsl:value-of select="$castField/@title"/> + </th> + </tr> + </thead> + <tbody> + <xsl:if test="$castField/tc:prop[@name = 'column1']"> + <xsl:variable name="castCols" select="$castField/tc:prop[@name = 'columns']"/> + <tr> + <xsl:call-template name="columnTitle"> + <xsl:with-param name="index" select="1"/> + <xsl:with-param name="max" select="$castCols"/> + <xsl:with-param name="elem" select="'th'"/> + <xsl:with-param name="field" select="$castField"/> + </xsl:call-template> + </tr> + </xsl:if> + <xsl:for-each select="$entry/tc:casts/tc:cast"> + <tr> + <xsl:for-each select="tc:column"> + <td> + <xsl:if test="position() = 1"> + <xsl:attribute name="class">person</xsl:attribute><xsl:value-of select="."/> + </xsl:if> + <xsl:if test="position() > 1"> + <xsl:attribute name="class">role</xsl:attribute><xsl:value-of select="."/> + </xsl:if> + <xsl:text> </xsl:text> + </td> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:if> + + <!-- now for every thing else --> + <!-- write categories other than general and images --> + <!-- $castcat might be empty, be careful --> + <xsl:for-each select="$categories[. != $titleCat and + ($castCat = '' or . != $castCat) and + key('fieldsByCat',.)[1]/@type != 10]"> + <table width="49%" class="category"> + <thead> + <tr class="category"> + <th colspan="2"> + <xsl:value-of select="."/> + </th> + </tr> + </thead> + <tbody> + <xsl:for-each select="key('fieldsByCat', .)[@name != 'directors-cut' and + @name != 'widescreen']"> + <tr> + <xsl:choose> + <!-- paragraphs --> + <xsl:when test="@type=2"> + <td colspan="2"> + <p> + <xsl:value-of select="$entry/*[local-name(.)=current()/@name]" disable-output-escaping="yes"/> + </p> + </td> + </xsl:when> + + <!-- tables are field type 8 --> + <!-- ok to put category name inside div instead of table here --> + <xsl:when test="@type = 8"> + <td colspan="2"> + <!-- look at number of columns --> + <xsl:choose> + <xsl:when test="tc:prop[@name = 'columns'] > 1"> + <table> + <xsl:if test="tc:prop[@name = 'column1']"> + <thead> + <tr> + <xsl:call-template name="columnTitle"> + <xsl:with-param name="index" select="1"/> + <xsl:with-param name="max" select="tc:prop[@name = 'columns']"/> + <xsl:with-param name="elem" select="'th'"/> + <xsl:with-param name="field" select="."/> + </xsl:call-template> + </tr> + </thead> + </xsl:if> + <tbody> + <xsl:for-each select="$entry//*[local-name(.) = current()/@name]"> + <tr> + <xsl:for-each select="tc:column"> + <td width="{100 div count(../tc:column)}%"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </td> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:when> + <xsl:otherwise> + <ul> + <xsl:for-each select="$entry//*[local-name(.) = current()/@name]"> + <li> + <xsl:value-of select="."/> + </li> + </xsl:for-each> + </ul> + </xsl:otherwise> + </xsl:choose> + </td> + </xsl:when> + + <!-- everything else --> + <xsl:otherwise> + <th> + <xsl:value-of select="@title"/> + </th> + <td> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="@name"/> + </xsl:call-template> + </td> + </xsl:otherwise> + </xsl:choose> + </tr> + </xsl:for-each> + </tbody> + </table> + </xsl:for-each> +</td> +</tr> +</tbody> +</table> + +</xsl:template> + +</xsl:stylesheet> |