1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Rendering stylesheet for Liferea (item view: item rendering)
*
* Copyright (C) 2006-2012 Lars Windolf <lars.windolf@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" version="1.0" indent="yes"/>
<!-- the local pixmap directory (e.g. /usr/share/liferea/pixmaps/) -->
<xsl:param name="pixmapsDir"/>
<xsl:param name="baseUrl"/>
<xsl:param name="summary"/> <!-- 1=summary rendering, 0=normal rendering -->
<xsl:param name="showFeedName"/>
<xsl:param name="single"/> <!-- 1=single item rendering, 0=2 pane mode -->
<xsl:param name="txtDirection"/> <!-- text direction, either "ltr" or "rtl" -->
<xsl:param name="appDirection"/> <!-- text direction, either "ltr" or "rtl" -->
<xsl:template match="/itemset">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
</head>
<xsl:element name="body">
<!-- base URL of the itemset -->
<div href="{$baseUrl}">
<xsl:for-each select="item">
<xsl:choose>
<xsl:when test="$summary = '1'">
<xsl:call-template name="item_summary"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div> <!-- end of base URL div -->
</xsl:element>
</html>
</xsl:template>
<!-- ==================================================================== -->
<!---single item detailed mode rendering -->
<xsl:template name="item">
<!-- base URL of parent feed -->
<div href="{/itemset/feed/feedSource}">
<!-- the item -->
<xsl:variable name="onMouseOver">
<xsl:text disable-output-escaping='yes'>doShow('</xsl:text>
<xsl:value-of select="sourceId"/>-<xsl:value-of select="nr"/>
<xsl:text disable-output-escaping='yes'>');</xsl:text>
</xsl:variable>
<!-- entering header starts delayed show of the item menu -->
<!-- leaving header stops show counter -->
<div onmouseover="{$onMouseOver}" onmouseout="stopShow();">
<!-- header table -->
<table class="itemhead" cellspacing="0" cellpadding="0" dir="{$txtDirection}">
<tr>
<td valign="middle" class="headleft">
<!-- Feed link as favicon -->
<xsl:variable name="favicon">
<xsl:choose>
<xsl:when test="not(sourceFavicon)">
<xsl:value-of select="/itemset/feed/favicon"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="sourceFavicon"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a class="favicon" href="{/itemset/feed/attributes/attribute[ @name = 'homepage' ]}">
<img src="{$favicon}"/>
</a>
</td>
<td width="100%" valign="middle" class="headright">
<!-- Item title as link -->
<a class="itemhead" href="{source}">
<xsl:value-of select="title"/>
<!-- the title added above might be empty, in this
case we add the date of the post -->
<xsl:if test="title = ''">
<xsl:value-of select="timestr"/>
</xsl:if>
</a>
</td>
</tr>
</table>
<!-- header metadata (author + categories + date + source feed) -->
<table class='headmeta' cellspacing="0" cellpadding="0" dir="{$appDirection}">
<xsl:if test="attributes/attribute[ @name = 'slash' ]">
<tr>
<td valign="top" class='slash'>
<xsl:apply-templates select="attributes/attribute[ @name = 'slash']"/>
</td>
</tr>
</xsl:if>
<xsl:if test="attributes/attribute[ @name = 'realSourceUrl' ]">
<tr>
<td valign="top" class='source'>
<_span>Source</_span>
<b><span class='source'>
<a href="{attributes/attribute[ @name = 'realSourceUrl' ]}">
<xsl:value-of select="attributes/attribute[ @name = 'realSourceTitle' ]"/>
</a>
</span></b>
</td>
</tr>
</xsl:if>
<!-- In summary mode we are potential presenting multiple feeds
and we should display the source feed title for the item. -->
<xsl:if test="$summary = '1' or $showFeedName = '1'">
<tr>
<td valign="top" class='source'>
<_span>Feed</_span>
<b><span class='source'>
<a href="{/itemset/feed/attributes/attribute[ @name = 'homepage' ]}">
<xsl:value-of select="/itemset/feed/feedTitle"/>
</a>
</span></b>
</td>
</tr>
</xsl:if>
<xsl:if test="attributes/attribute[ @name = 'category' ]">
<tr>
<td valign="top" class='categories'>
<_span>Filed under</_span>
<b><span class='categories'>
<xsl:for-each select="attributes/attribute[ @name = 'category' ]">
<xsl:if test="position() != 1">, </xsl:if>
<xsl:value-of select="." disable-output-escaping='yes'/>
</xsl:for-each>
</span></b>
</td>
</tr>
</xsl:if>
<xsl:if test="attributes/attribute[ @name = 'author' ]">
<tr>
<td valign="top" class='author'>
<_span>Author</_span>
<b><span class='author'>
<xsl:value-of select="attributes/attribute[ @name = 'author' ]" disable-output-escaping='yes'/>
</span></b>
</td>
</tr>
</xsl:if>
<xsl:if test="attributes/attribute[ @name = 'sharedby' ]">
<tr>
<td valign="top" class='sharedby'>
<_span>Shared by</_span>
<b><span class='sharedby'>
<xsl:value-of select="attributes/attribute[ @name = 'sharedby' ]" disable-output-escaping='yes'/>
</span></b>
</td>
</tr>
</xsl:if>
<!-- Indicate Atom "via" and "related" links -->
<xsl:for-each select="attributes/attribute[ @name = 'via' ]">
<tr>
<td valign="top" class='source'>
<_span>Via</_span>
<b><span class='source'>
<a href="{.}">
<xsl:value-of select="."/>
</a>
</span></b>
</td>
</tr>
</xsl:for-each>
<xsl:for-each select="attributes/attribute[ @name = 'related' ]">
<tr>
<td valign="top" class='source'>
<_span>Related</_span>
<b><span class='source'>
<a href="{.}">
<xsl:value-of select="."/>
</a>
</span></b>
</td>
</tr>
</xsl:for-each>
<!-- Indicate all duplicates -->
<xsl:for-each select="duplicates/duplicateNode">
<tr>
<td valign="top" class='source'>
<_span>Also posted in</_span>
<b><span class='source'>
<xsl:value-of select="."/>
</span></b>
</td>
</tr>
</xsl:for-each>
<xsl:if test="attributes/attribute[ @name = 'creator' ]">
<tr>
<td valign="top" class='creator'>
<_span>Creator</_span>
<b><span class='creator'>
<xsl:value-of select="attributes/attribute[ @name = 'creator' ]" disable-output-escaping='yes'/>
</span></b>
</td>
</tr>
</xsl:if>
<xsl:if test="attributes/attribute[ @name = 'point' ]">
<xsl:variable name="lat" select="substring-before(attributes/attribute[ @name = 'point' ],' ')"/>
<xsl:variable name="lng" select="substring-after(attributes/attribute[ @name = 'point' ],' ')"/>
<tr>
<td valign="top" class='point'>
<_span>Coordinates</_span>
<b><span class='point'><xsl:value-of select="$lat"/>, <xsl:value-of select="$lng"/></span></b>
</td>
</tr>
<tr>
<td valign="top" class='point'>
<_span>Map</_span>
<b><span class='point'>
<a href="https://www.openstreetmap.org/?mlat={$lat}&mlon={$lng}#map=12/{$lat}/{$lng}">OpenStreeMap</a>
</span></b>
</td>
</tr>
</xsl:if>
</table> <!-- end of header metadata -->
<xsl:variable name="shading">
<xsl:if test="$single = '0' and readStatus = '0'">itemshaded</xsl:if>
<xsl:if test="$single = '0' and readStatus != '0'">itemunshaded</xsl:if>
</xsl:variable>
<div id="shading" class="{$shading}">
<div class='content'>
<!-- the item's content -->
<p dir="{$txtDirection}">
<!-- optional gravatar -->
<xsl:if test="attributes/attribute[ @name = 'gravatar' ]">
<img align='left' class='gravatar' src="{attributes/attribute[ @name = 'gravatar' ]}"/>
</xsl:if>
<!-- the real text content -->
<xsl:value-of select="description" disable-output-escaping='yes'/>
</p>
<!-- photo namespace handling -->
<xsl:if test="attributes/attribute[ @name = 'photo' ]">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="input" select="attributes/attribute[ @name = 'photo' ]" />
<xsl:with-param name="substr" select="','" />
</xsl:call-template>
</xsl:attribute>
</xsl:element>
</xsl:if>
<!-- comment handling -->
<xsl:if test="attributes/attribute[ @name = 'commentFeedUri' ] and not(./commentsSuppressed) and $single = 1">
<p>
<xsl:if test="count(comments/item) != 0">
<b><_span>Comments</_span></b>
</xsl:if>
<!-- Display "comment feed updating" hint -->
<xsl:if test="comments/updateState = 'updating'">
(<span>
<_span>Updating...</_span>
</span>)
</xsl:if>
</p>
<!-- Display error box if necessary -->
<xsl:if test="comments/updateError">
<p>
<div id="errors">
<div id="updateError">
<xsl:value-of select="comments/updateError"/>
</div>
</div>
</p>
</xsl:if>
<p>
<xsl:apply-templates select="comments/item">
<xsl:sort select="time"/>
</xsl:apply-templates>
</p>
</xsl:if>
</div>
</div> <!-- end of base URL div -->
</div> <!-- item -->
</div> <!-- shading -->
</xsl:template>
<!-- ==================================================================== -->
<!-- slashdot namespace -->
<xsl:template match="attributes/attribute[ @name = 'slash']">
<span class="slashSection"><_span>Section</_span></span>
<span class="slashValue"><xsl:value-of select="substring-before(., ',')"/></span>
<span class="slashDepartment"><_span>Department</_span></span>
<span class="slashValue"><xsl:value-of select="substring-after(., ',')"/></span>
</xsl:template>
<!-- ==================================================================== -->
<!-- comment rendering -->
<xsl:template match="comments/item">
<div class="comment" dir="{$txtDirection}">
<div class="comment_title"><xsl:value-of select="title"/></div>
<div class="comment_body"><xsl:value-of select="description" disable-output-escaping='yes'/></div>
</div>
</xsl:template>
<!-- ==================================================================== -->
<!--- single item summary mode rendering -->
<xsl:template name="item_summary">
<xsl:variable name="summaryShading">
<xsl:choose>
<xsl:when test="readStatus = '0'">summaryshaded</xsl:when>
<xsl:otherwise>summaryunshaded</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="{$summaryShading}">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="summarytime" valign="top">
<xsl:value-of select="timestr"/>
</td>
<td width="100%">
<!-- Item title as link -->
<a href="{source}">
<xsl:value-of select="title"/>
</a>
<!-- summary mode means most of the items have no description,
but lets output them for those who have one... -->
<xsl:if test="description">
<br/><br/>
<xsl:value-of select="description" disable-output-escaping='yes'/>
</xsl:if>
</td>
</tr>
</table>
<hr class='summary'/>
</div>
</xsl:template>
<!-- ==================================================================== -->
<!--- substring after last occurance also from "XSLT Cookbook"... -->
<xsl:template name="substring-after-last">
<xsl:param name="input" />
<xsl:param name="substr" />
<!-- Extract the string which comes after the first occurence -->
<xsl:variable name="temp" select="substring-after($input,$substr)"/>
<xsl:choose>
<!-- If it still contains the search string then recursively process -->
<xsl:when test="$substr and contains($temp,$substr)">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="input" select="$temp" />
<xsl:with-param name="substr" select="$substr" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$temp" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|