replies.xsl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <xsl:stylesheet
  2. xmlns="http://www.w3.org/1999/xhtml"
  3. xmlns:a="http://www.w3.org/2005/Atom"
  4. xmlns:media="http://search.yahoo.com/mrss/"
  5. xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
  6. xmlns:thr="http://purl.org/syndication/thread/1.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. exclude-result-prefixes="a media opensearch thr"
  9. xmlns:math="http://exslt.org/math"
  10. extension-element-prefixes="math"
  11. version="1.0">
  12. <!-- xsl:variable name="redirector">https://anonym.to/?</xsl:variable --> <!-- mask the HTTP_REFERER -->
  13. <xsl:variable name="redirector"></xsl:variable>
  14. <xsl:variable name="archive">https://web.archive.org/web/</xsl:variable>
  15. <xsl:include href="util.xsl"/>
  16. <xsl:output
  17. method="html"
  18. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  19. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  20. <!-- http://stackoverflow.com/a/16328207 -->
  21. <xsl:key name="CategorY" match="a:entry/a:category" use="@term" />
  22. <xsl:variable name="self" select="/*/a:link[@rel = 'self']/@href"/>
  23. <xsl:variable name="xml_base_absolute" select="/*/@xml:base"/>
  24. <!-- a bit hairy, but actually works -->
  25. <xsl:variable name="xml_base_relative">../../<xsl:choose>
  26. <xsl:when test="'shaarligo.cgi/search/?q=' = substring($self, 1, 24)"/>
  27. <xsl:when test="'//' = translate($self, 'abcdefghijklmnopqrstuvwxyz0123456789-', '')"/>
  28. <xsl:otherwise>../</xsl:otherwise>
  29. </xsl:choose>
  30. </xsl:variable>
  31. <xsl:variable name="xml_base" select="normalize-space($xml_base_relative)"/>
  32. <xsl:variable name="xml_base_pub" select="concat($xml_base,'o')"/>
  33. <xsl:variable name="skin_base" select="concat($xml_base,'themes/current')"/>
  34. <xsl:variable name="cgi_base" select="concat($xml_base,'shaarligo.cgi')"/>
  35. <xsl:template match="/">
  36. <html xmlns="http://www.w3.org/1999/xhtml" data-xml-base-pub="{$xml_base_pub}">
  37. <head>
  38. <link href="../../themes/current/replies.css" rel="stylesheet" type="text/css" />
  39. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  40. <meta name="generator" content="HTML Tidy for HTML5 for FreeBSD version 5.8.0" />
  41. <meta name="viewport" content="width=device-width,initial-scale=1.0" />
  42. <!-- script src="../live.js"></script -->
  43. <title>Threaded Atom Feeds RFC 4685</title>
  44. </head>
  45. <body>
  46. <xsl:apply-templates select="a:feed"/>
  47. </body>
  48. </html>
  49. </xsl:template>
  50. <xsl:template match="a:feed">
  51. <h1><xsl:value-of select="a:title"/></h1>
  52. <ol class="odd" data-level="1">
  53. <!-- level=0 is reserved for the primary source -->
  54. <xsl:apply-templates select="a:entry[not(thr:in-reply-to)]">
  55. <!-- entries pointing to undefined ids are lost -->
  56. <xsl:with-param name="level" select="1 + 1"/>
  57. </xsl:apply-templates>
  58. </ol>
  59. </xsl:template>
  60. <xsl:template match="a:entry">
  61. <xsl:param name="level" />
  62. <xsl:variable name="entry_published" select="a:published"/>
  63. <xsl:variable name="entry_published_human"><xsl:call-template name="human_time"><xsl:with-param name="time" select="$entry_published"/></xsl:call-template></xsl:variable>
  64. <li>
  65. <p>
  66. <img class="avatar" alt="Avatar" src= "{a:author/a:icon}" />
  67. <a href="{a:id}" data-rfc3339="{a:published}" title="{a:published}">
  68. <xsl:value-of select="$entry_published_human"/>
  69. </a>
  70. <span class="name"><xsl:value-of select="a:author/a:name"/></span>
  71. <a href="{a:author/a:uri}" data-rfc7033="{a:author/a:email}"><xsl:value-of select="a:author/a:email"/></a>
  72. </p>
  73. <p class="plaintext">
  74. <xsl:call-template name="linefeed2br">
  75. <xsl:with-param name="string" select="a:content"/>
  76. </xsl:call-template>
  77. </p>
  78. <xsl:variable name="me" select="a:id"/>
  79. <xsl:variable name="clz">
  80. <xsl:choose>
  81. <xsl:when test="$level mod 2 = 0">even</xsl:when>
  82. <xsl:otherwise>odd</xsl:otherwise>
  83. </xsl:choose>
  84. </xsl:variable>
  85. <xsl:variable name="more" select="following-sibling::a:entry[thr:in-reply-to/@ref = $me]"/>
  86. <xsl:if test="count($more) > 0">
  87. <ol class="{$clz}" data-level="{$level}">
  88. <xsl:apply-templates select="$more">
  89. <xsl:with-param name="lvl" select="$level + 1"/>
  90. </xsl:apply-templates>
  91. </ol>
  92. </xsl:if>
  93. </li>
  94. </xsl:template>
  95. </xsl:stylesheet>