actor.xsl 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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_url" 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 for="{$id}" role="button">
  70. <xsl:if test="'pending' = $value">
  71. <xsl:attribute name="class">pending</xsl:attribute>
  72. </xsl:if>
  73. <xsl:if test="$disabled">
  74. <xsl:attribute name="aria-disabled">true</xsl:attribute>
  75. </xsl:if>
  76. <input type="checkbox" name="{$id}" id="{$id}">
  77. <!--
  78. <xsl:if test="$disabled">
  79. <xsl:attribute name="disabled">disabled</xsl:attribute>
  80. </xsl:if>
  81. -->
  82. <xsl:if test="'no' != $value">
  83. <xsl:attribute name="checked">checked</xsl:attribute>
  84. </xsl:if>
  85. </input>
  86. <span class="if-pending" title="pending"> ⏳ </span>
  87. <xsl:copy-of select="$txt"/>
  88. </label>
  89. </xsl:template>
  90. <xsl:template match="/rdf:RDF">
  91. <html xmlns="http://www.w3.org/1999/xhtml" data-xml-base-pub="{$xml_base_pub}" class="script-inactive" bgcolor="darkgreen">
  92. <xsl:for-each select="as:Person|as:Group">
  93. <xsl:variable name="host1" select="as:id/@rdf:resource"/>
  94. <xsl:variable name="host0" select="substring-after($host1,'://')"/>
  95. <xsl:variable name="host" select="substring-before($host0,'/')"/>
  96. <head>
  97. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  98. <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
  99. <link href="{$skin_base}/style.css" rel="stylesheet" type="text/css"/>
  100. <link href="{$skin_base}/actor.css" rel="stylesheet" type="text/css"/>
  101. <link rel="icon" type="image/jpg" href="{$xml_base}/me-avatar.jpg"/>
  102. <title><xsl:value-of select="as:name"/></title>
  103. </head>
  104. <body>
  105. <div id="banner">
  106. <div id="banner-img">
  107. <img alt="Banner" src="{as:image[1]/as:Image[1]/as:url[1]/@rdf:resource}"/>
  108. </div>
  109. <form name="actor" action="actor.xml" method="post">
  110. <xsl:variable name="subscriber" select="normalize-space(../*/seppo:is_subscriber)"/>
  111. <xsl:variable name="subscribed" select="normalize-space(../*/seppo:am_subscribed_to)"/>
  112. <xsl:variable name="blocked" select="normalize-space(../*/seppo:is_blocked)"/>
  113. <xsl:variable name="token" select="normalize-space(../*/seppo:token)"/>
  114. <input type="hidden" name="token" value="{$token}"/>
  115. <input type="hidden" name="id" value="{as:id/@rdf:resource}"/>
  116. <input type="hidden" name="inbox" value="{ldp:inbox/@rdf:resource}"/>
  117. <input type="hidden" name="~is_subscriber" value="{$subscriber}"/>
  118. <input type="hidden" name="~am_subscribed_to" value="{$subscribed}"/>
  119. <input type="hidden" name="~is_blocked" value="{$blocked}"/>
  120. <!-- a href="{$cgi_url}/timeline/p/" rel="start" role="button" title="Timeline">🕞</a -->
  121. <a href="{$cgi_url}/timeline/p/" rel="start" role="button" title="Home">🏡</a>
  122. <!-- a href="{as:url/@rdf:resource}" role="button">📄 Profile</a -->
  123. <a aria-disabled="true" href="" role="button">✉️ <span class="hidden-xs">Message</span></a>
  124. <!--
  125. <label class="pending" title="pending" for="subscribed2" role="button">
  126. <input type="checkbox" id="subscribed2" name="subscribed2" checked="checked"/>
  127. <span class="if-pending"> … </span>
  128. <span class="hidden-xs">Subscrubed to</span> 👂
  129. </label>
  130. -->
  131. <xsl:call-template name="banner-input">
  132. <xsl:with-param name="id">am_subscribed_to</xsl:with-param>
  133. <xsl:with-param name="value" select="$subscribed"/>
  134. <xsl:with-param name="txt"><span class="hidden-xs">Subscribed to</span> 👂</xsl:with-param>
  135. </xsl:call-template>
  136. <xsl:call-template name="banner-input">
  137. <xsl:with-param name="id">is_subscriber</xsl:with-param>
  138. <xsl:with-param name="value" select="$subscriber"/>
  139. <xsl:with-param name="txt"><span class="hidden-xs">is Subscriber</span> 📣</xsl:with-param>
  140. <xsl:with-param name="disabled" select="'true'"/>
  141. </xsl:call-template>
  142. <xsl:call-template name="banner-input">
  143. <xsl:with-param name="id">is_blocked</xsl:with-param>
  144. <xsl:with-param name="value" select="$blocked"/>
  145. <xsl:with-param name="txt"><span class="hidden-xs">Blocked</span> 🤐</xsl:with-param>
  146. </xsl:call-template>
  147. <input class="noscript" type="submit"/>
  148. </form>
  149. </div>
  150. <div id="avatar">
  151. <xsl:for-each select="as:icon/as:Image/as:url">
  152. <a href="{../../../as:url/@rdf:resource}"><img id="avatar" alt="Avatar" src="{@rdf:resource}"/></a>
  153. </xsl:for-each>
  154. </div>
  155. <h3 id="name"><a href="{as:url/@rdf:resource}" title="name"><xsl:value-of select="as:name"/></a></h3>
  156. <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>
  157. <p class="clickable" title="summary">
  158. <xsl:call-template name="linefeed2br">
  159. <xsl:with-param name="string" select="as:summary"/>
  160. </xsl:call-template>
  161. </p>
  162. <dl class="clickable">
  163. <xsl:for-each select="as:attachment/schema:PropertyValue[schema:value]">
  164. <dt><xsl:value-of select="as:name"/></dt>
  165. <dd><xsl:value-of select="schema:value"/></dd>
  166. </xsl:for-each>
  167. </dl>
  168. <script src="{$skin_base}/actor.js"></script>
  169. </body>
  170. </xsl:for-each>
  171. </html>
  172. </xsl:template>
  173. </xsl:stylesheet>