config.xslt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ShaarliGo, microblogging detox
  4. Copyright (C) 2017-2021 Marcus Rohrmoser, http://purl.mro.name/ShaarliGo
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. http://www.w3.org/TR/xslt/
  16. -->
  17. <xsl:stylesheet
  18. xmlns="http://www.w3.org/1999/xhtml"
  19. xmlns:h="http://www.w3.org/1999/xhtml"
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21. version="1.0">
  22. <!-- replace linefeeds with <br> tags -->
  23. <xsl:template name="linefeed2br">
  24. <xsl:param name="string" select="''"/>
  25. <xsl:param name="pattern" select="'&#10;'"/>
  26. <xsl:choose>
  27. <xsl:when test="contains($string, $pattern)">
  28. <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>
  29. <xsl:call-template name="linefeed2br">
  30. <xsl:with-param name="string" select="substring-after($string, $pattern)"/>
  31. <xsl:with-param name="pattern" select="$pattern"/>
  32. </xsl:call-template>
  33. </xsl:when>
  34. <xsl:otherwise>
  35. <xsl:value-of select="$string"/>
  36. </xsl:otherwise>
  37. </xsl:choose>
  38. </xsl:template>
  39. <xsl:template name="human_time">
  40. <xsl:param name="time">-</xsl:param>
  41. <xsl:value-of select="substring($time, 9, 2)"/><xsl:text>. </xsl:text>
  42. <xsl:variable name="month" select="substring($time, 6, 2)"/>
  43. <xsl:choose>
  44. <xsl:when test="'01' = $month">Jan</xsl:when>
  45. <xsl:when test="'02' = $month">Feb</xsl:when>
  46. <xsl:when test="'03' = $month">Mar</xsl:when>
  47. <xsl:when test="'04' = $month">Apr</xsl:when>
  48. <xsl:when test="'05' = $month">May</xsl:when>
  49. <xsl:when test="'06' = $month">Jun</xsl:when>
  50. <xsl:when test="'07' = $month">Jul</xsl:when>
  51. <xsl:when test="'08' = $month">Aug</xsl:when>
  52. <xsl:when test="'09' = $month">Sep</xsl:when>
  53. <xsl:when test="'10' = $month">Oct</xsl:when>
  54. <xsl:when test="'11' = $month">Nov</xsl:when>
  55. <xsl:when test="'12' = $month">Dec</xsl:when>
  56. <xsl:otherwise>?</xsl:otherwise>
  57. </xsl:choose><xsl:text> </xsl:text>
  58. <xsl:value-of select="substring($time, 1, 4)"/><xsl:text> </xsl:text>
  59. <xsl:value-of select="substring($time, 12, 5)"/><!-- xsl:text> Uhr</xsl:text -->
  60. </xsl:template>
  61. <xsl:template name="degrees">
  62. <xsl:param name="num" select="0"/>
  63. <xsl:choose>
  64. <xsl:when test="$num &lt; 0">-<xsl:call-template name="degrees"><xsl:with-param name="num" select="-$num"/></xsl:call-template></xsl:when>
  65. <xsl:when test="$num &gt;= 0">
  66. <xsl:variable name="deg" select="floor($num)"/>
  67. <xsl:variable name="min" select="floor(($num * 60) mod 60)"/>
  68. <xsl:variable name="sec" select="format-number((($num * 36000) mod 600) div 10, '0.0')"/>
  69. <xsl:value-of select="$deg"/>° <!--
  70. --><xsl:value-of select="$min"/>' <!--
  71. --><xsl:value-of select="$sec"/>"
  72. </xsl:when>
  73. <xsl:otherwise>?</xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:template>
  76. <xsl:output
  77. method="html"
  78. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  79. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  80. <xsl:variable name="xml_base">../../</xsl:variable>
  81. <xsl:variable name="xml_base_pub" select="concat($xml_base,'o')"/>
  82. <xsl:variable name="skin_base" select="concat($xml_base,'themes/current')"/>
  83. <xsl:variable name="cgi_base" select="concat($xml_base,'shaarligo.cgi')"/>
  84. <xsl:template match="/h:html/h:body/h:form">
  85. <html xmlns="http://www.w3.org/1999/xhtml">
  86. <head>
  87. <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  88. <!-- https://developer.apple.com/library/IOS/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html#//apple_ref/doc/uid/TP40006509-SW26 -->
  89. <!-- http://maddesigns.de/meta-viewport-1817.html -->
  90. <!-- meta name="viewport" content="width=device-width"/ -->
  91. <!-- http://www.quirksmode.org/blog/archives/2013/10/initialscale1_m.html -->
  92. <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
  93. <!-- meta name="viewport" content="width=400"/ -->
  94. <link href="{$skin_base}/style.css" rel="stylesheet" type="text/css"/>
  95. <title><xsl:value-of select="title"/></title>
  96. </head>
  97. <body onload="document.{@name}.title.focus();">
  98. <div class="container">
  99. <p class="col-sm-10 col-sm-offset-2"><img
  100. width="600px" height="100px"
  101. alt="Very nice, the web server is well configured, ./app/ is protected."
  102. title="If a film quote is visible here, ./app/ lies unprotected on the net."
  103. src="../../app/i-must-be-403.svg"/></p>
  104. <xsl:if test="h:input[@name='setlogin']/@value = ''">
  105. <p class="col-sm-10 col-sm-offset-2">Oops, it looks pretty fresh in here.</p>
  106. </xsl:if>
  107. <form id="{@id}" name="{@name}" class="form-horizontal" method="POST">
  108. <!-- https://www.tjvantoll.com/2012/08/05/html5-form-validation-showing-all-error-messages/ -->
  109. <div class="form-group">
  110. <label for="title" class="control-label col-sm-2">Title</label>
  111. <div class="col-sm-8">
  112. <input tabindex="100" name="title" autofocus="autofocus" type="text" placeholder="My ShaarliGo 🐳" required="true" pattern="\S(.*\S)?" value="{h:input[@name='title']/@value}" class="form-control"/>
  113. </div>
  114. </div>
  115. <div class="form-group">
  116. <label for="setlogin" class="control-label col-sm-2">User</label>
  117. <div class="col-sm-8">
  118. <input tabindex="200" name="setlogin" type="text" placeholder="Username of this new ShaarliGo" required="true" pattern="\S(.*\S)?" _oninvalid="setCustomValidity('Das ist nicht Dein Ernst oder?')" value="{h:input[@name='setlogin']/@value}" class="form-control"/>
  119. </div>
  120. </div>
  121. <xsl:if test="h:input[@name='oldpassword']/@value != ''">
  122. <div class="if_has_pwd form-group">
  123. <label for="oldpassword" class="control-label col-sm-2">Pwd (old)</label>
  124. <div class="col-sm-8">
  125. <input tabindex="300" name="oldpassword" type="password" placeholder="The old password" required="true" minlength="12" pattern="\S(.*\S)?" value="{h:input[@name='oldpassword']/@value}" class="form-control"/>
  126. </div>
  127. </div>
  128. </xsl:if>
  129. <div class="form-group">
  130. <label for="setpassword" class="control-label col-sm-2">Pwd</label>
  131. <div class="col-sm-8">
  132. <input tabindex="400" name="setpassword" type="password" placeholder="good passwords: xkcd.com/936" required="true" minlength="12" pattern="\S(.*\S)?" value="{h:input[@name='setpassword']/@value}" class="form-control"/>
  133. </div>
  134. </div>
  135. <div class="if_has_pwd form-group">
  136. <label for="confirmpassword" class="control-label col-sm-2">Repeat pwd</label>
  137. <div class="col-sm-8">
  138. <input tabindex="500" name="confirmpassword" type="password" placeholder="the same once more" required="true" minlength="12" pattern="\S(.*\S)?" value="{h:input[@name='confirmpassword']/@value}" class="form-control"/>
  139. </div>
  140. </div>
  141. <!-- evtl. Zeitzone, continent / city? -->
  142. <div class="form-group">
  143. <div class="col-sm-8 col-sm-offset-2">
  144. <button tabindex="900" type="submit" class="btn btn-primary">Goooooo!</button>
  145. </div>
  146. </div>
  147. </form>
  148. </div>
  149. </body>
  150. </html>
  151. </xsl:template>
  152. </xsl:stylesheet>