actor.xsl 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. _ _ ____ _
  4. _| || |_/ ___| ___ _ __ _ __ ___ | |
  5. |_ .. _\___ \ / _ \ '_ \| '_ \ / _ \| |
  6. |_ _|___) | __/ |_) | |_) | (_) |_|
  7. |_||_| |____/ \___| .__/| .__/ \___/(_)
  8. |_| |_|
  9. Personal Social Web.
  10. Copyright (C) The #Seppo contributors. All rights reserved.
  11. This program is free software: you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation, either version 3 of the License, or
  14. (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. https://www.w3.org/TR/1999/REC-xslt-19991116
  22. https://www.w3.org/TR/1999/REC-xpath-19991116
  23. -->
  24. <xsl:stylesheet
  25. xmlns="http://www.w3.org/1999/xhtml"
  26. xmlns:as="https://www.w3.org/ns/activitystreams#"
  27. xmlns:h="http://www.w3.org/1999/xhtml"
  28. xmlns:ldp="http://www.w3.org/ns/ldp#"
  29. xmlns:math="http://exslt.org/math"
  30. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  31. xmlns:schema="http://schema.org#"
  32. xmlns:sec="https://w3id.org/security#"
  33. xmlns:seppo="http://seppo.social/2023/ns#"
  34. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  35. exclude-result-prefixes="as ldp math rdf schema sec seppo"
  36. version="1.0">
  37. <!-- xsl:strip-space elements="seppo:isBlocked seppo:isFollowed" / -->
  38. <!-- replace linefeeds with <br> tags -->
  39. <xsl:template name="linefeed2br">
  40. <xsl:param name="string" select="''"/>
  41. <xsl:param name="pattern" select="'&#10;'"/>
  42. <xsl:choose>
  43. <xsl:when test="contains($string, $pattern)">
  44. <xsl:value-of select="substring-before($string, $pattern)"/><br class="br"/><!-- xsl:comment>Why do we see 2 br on Safari and output/@method=html here? http://purl.mro.name/safari-xslt-br-bug</xsl:comment -->
  45. <xsl:call-template name="linefeed2br">
  46. <xsl:with-param name="string" select="substring-after($string, $pattern)"/>
  47. <xsl:with-param name="pattern" select="$pattern"/>
  48. </xsl:call-template>
  49. </xsl:when>
  50. <xsl:otherwise>
  51. <xsl:value-of select="$string"/>
  52. </xsl:otherwise>
  53. </xsl:choose>
  54. </xsl:template>
  55. <xsl:output
  56. method="html"
  57. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  58. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  59. <xsl:variable name="xml_base_absolute" select="/*/@xml:base"/>
  60. <xsl:variable name="xml_base" select="normalize-space($xml_base_absolute)"/>
  61. <xsl:variable name="xml_base_pub" select="concat($xml_base,'/o')"/>
  62. <xsl:variable name="skin_base" select="concat($xml_base,'/themes/current')"/>
  63. <xsl:variable name="cgi_base" select="concat($xml_base,'seppo.cgi')"/>
  64. <xsl:template name="banner-input">
  65. <xsl:param name="id"/>
  66. <xsl:param name="value"/>
  67. <xsl:param name="txt"/>
  68. <xsl:param name="disabled"/>
  69. <label class="btn" for="{$id}">
  70. <xsl:if test="'pending' = $value">
  71. <xsl:attribute name="class">btn pending</xsl:attribute>
  72. </xsl:if>
  73. <input type="checkbox" name="{$id}" id="{$id}">
  74. <xsl:if test="$disabled">
  75. <xsl:attribute name="disabled">disabled</xsl:attribute>
  76. </xsl:if>
  77. <xsl:if test="'no' != $value">
  78. <xsl:attribute name="checked">checked</xsl:attribute>
  79. </xsl:if>
  80. </input>
  81. <span class="if-pending" title="pending"> ⏳ </span>
  82. <xsl:copy-of select="$txt"/>
  83. </label>
  84. </xsl:template>
  85. <xsl:template match="/rdf:RDF">
  86. <html xmlns="http://www.w3.org/1999/xhtml" data-xml-base-pub="{$xml_base_pub}" class="script-inactive">
  87. <xsl:for-each select="as:Person|as:Group">
  88. <xsl:variable name="host1" select="as:url/@rdf:resource"/>
  89. <xsl:variable name="host0" select="substring-after($host1,'://')"/>
  90. <xsl:variable name="host" select="substring-before($host0,'/')"/>
  91. <head>
  92. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  93. <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
  94. <link href="{$skin_base}/style.css" rel="stylesheet" type="text/css"/>
  95. <link href="{$skin_base}/actor.css" rel="stylesheet" type="text/css"/>
  96. <link rel="icon" type="image/jpg" href="{$xml_base}/me-avatar.jpg"/>
  97. <title><xsl:value-of select="as:name"/></title>
  98. </head>
  99. <body>
  100. <div id="banner">
  101. <div id="banner-img">
  102. <img alt="Banner" src="{as:image[1]/as:Image[1]/as:url[1]/@rdf:resource}"/>
  103. </div>
  104. <form name="actor" action="actor.xml" method="post">
  105. <xsl:variable name="notify" select="normalize-space(../*/seppo:notify)"/>
  106. <xsl:variable name="subscribed" select="normalize-space(../*/seppo:subscribed)"/>
  107. <xsl:variable name="blocked" select="normalize-space(../*/seppo:blocked)"/>
  108. <xsl:variable name="token" select="normalize-space(../*/seppo:token)"/>
  109. <input type="hidden" name="token" value="{$token}"/>
  110. <input type="hidden" name="id" value="{as:id/@rdf:resource}"/>
  111. <input type="hidden" name="inbox" value="{ldp:inbox/@rdf:resource}"/>
  112. <input type="hidden" name="~notify" value="{$notify}"/>
  113. <input type="hidden" name="~subscribed" value="{$subscribed}"/>
  114. <input type="hidden" name="~blocked" value="{$blocked}"/>
  115. <a class="btn hidden-logged-out" href="{$xml_base}" rel="first">🏡 <span class="hidden-xs">Home</span></a>
  116. <!-- a class="btn" href="{as:url/@rdf:resource}">📄 Profile</a -->
  117. <a class="btn disabled" href="">✉️ <span class="hidden-xs">Message</span></a>
  118. <!--
  119. <label class="btn pending" title="pending" for="subscribed2">
  120. <input type="checkbox" id="subscribed2" name="subscribed2" checked="checked"/>
  121. <span class="if-pending"> … </span>
  122. <span class="hidden-xs">Subscrubed</span> 👂
  123. </label>
  124. -->
  125. <xsl:call-template name="banner-input">
  126. <xsl:with-param name="id">subscribed</xsl:with-param>
  127. <xsl:with-param name="value" select="$subscribed"/>
  128. <xsl:with-param name="txt"><span class="hidden-xs">Subscribed</span> 👂</xsl:with-param>
  129. </xsl:call-template>
  130. <xsl:call-template name="banner-input">
  131. <xsl:with-param name="id">notify</xsl:with-param>
  132. <xsl:with-param name="value" select="$notify"/>
  133. <xsl:with-param name="txt"><span class="hidden-xs">Notify</span> 📣</xsl:with-param>
  134. <!-- xsl:with-param name="disabled" select="'true'"/ -->
  135. </xsl:call-template>
  136. <xsl:call-template name="banner-input">
  137. <xsl:with-param name="id">blocked</xsl:with-param>
  138. <xsl:with-param name="value" select="$blocked"/>
  139. <xsl:with-param name="txt"><span class="hidden-xs">Blocked</span> 🤐</xsl:with-param>
  140. </xsl:call-template>
  141. <input class="noscript" type="submit"/>
  142. </form>
  143. </div>
  144. <div id="avatar">
  145. <xsl:for-each select="as:icon/as:Image/as:url">
  146. <a href="{../../../as:url/@rdf:resource}"><img id="avatar" alt="Avatar" src="{@rdf:resource}"/></a>
  147. </xsl:for-each>
  148. </div>
  149. <h3 id="name"><a href="{as:url/@rdf:resource}" title="name"><xsl:value-of select="as:name"/></a></h3>
  150. <p><a href="{as:url/@rdf:resource}" title="preferredUsername">@<span id="preferredUsername"><xsl:value-of select="as:preferredUsername"/></span>@<xsl:value-of select="$host"/></a></p>
  151. <p class="clickable" title="summary">
  152. <xsl:call-template name="linefeed2br">
  153. <xsl:with-param name="string" select="as:summary"/>
  154. </xsl:call-template>
  155. </p>
  156. <dl class="clickable">
  157. <xsl:for-each select="as:attachment/schema:PropertyValue[schema:value]">
  158. <dt><xsl:value-of select="as:name"/></dt>
  159. <dd><xsl:value-of select="schema:value"/></dd>
  160. </xsl:for-each>
  161. </dl>
  162. <script src="{$skin_base}/actor.js"></script>
  163. </body>
  164. </xsl:for-each>
  165. </html>
  166. </xsl:template>
  167. </xsl:stylesheet>