doap2html.xslt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Turn DOAP rdf into html.
  4. Copyright (c) 2013-2021 Marcus Rohrmoser mobile Software http://mro.name/~me. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without modification, are permitted
  6. provided that the following conditions are met:
  7. 1. Redistributions of source code must retain the above copyright notice, this list of conditions
  8. and the following disclaimer.
  9. 2. The software must not be used for military or intelligence or related purposes nor
  10. anything that's in conflict with human rights as declared in http://www.un.org/en/documents/udhr/ .
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  12. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  13. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  14. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  16. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  17. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  18. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. http://www.w3.org/TR/xslt
  20. http://www.w3.org/TR/xpath/
  21. -->
  22. <xsl:stylesheet
  23. xmlns:dct="http://purl.org/dc/terms/"
  24. xmlns:doap="http://usefulinc.com/ns/doap#"
  25. xmlns:foaf="http://xmlns.com/foaf/0.1/"
  26. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  27. xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
  28. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  29. xmlns="http://www.w3.org/1999/xhtml"
  30. xmlns:date="http://exslt.org/date"
  31. version="1.0">
  32. <xsl:output
  33. method="html"
  34. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  35. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  36. <xsl:variable name="base_url" select="/*/@xml:base"/>
  37. <xsl:template match="/rdf:RDF">
  38. <xsl:apply-templates select="doap:Project[1]"/>
  39. </xsl:template>
  40. <xsl:template match="doap:Project">
  41. <html xmlns="http://www.w3.org/1999/xhtml">
  42. <head>
  43. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  44. <style type="text/css">
  45. /*<![CDATA[*/
  46. html {
  47. font-family: sans-serif;
  48. background: hsl(30, 50%, 93%);
  49. color: hsl(30, 50%, 44%);
  50. }
  51. body {
  52. margin: auto;
  53. max-width: 43rem;
  54. }
  55. a, a:visited {
  56. color: hsl(115, 50%, 35%);
  57. text-decoration: none;
  58. }
  59. h1 > a, h2 > a {
  60. font-size: 60%;
  61. vertical-align: baseline;
  62. position: relative;
  63. top: -0.7em;
  64. }
  65. #sep {
  66. text-align: center;
  67. }
  68. #poweredby {
  69. font-size: 80%;
  70. color: #888;
  71. border-top: 2px solid darkgrey;
  72. padding-top: 1ex;
  73. }
  74. p[lang="en"]::after { content: "🇬🇧"; }
  75. pre[lang="en"]::before { content: "🇬🇧"; }
  76. p[lang="fr"]::after { content: "🇫🇷"; }
  77. @media (prefers-color-scheme: dark) {
  78. html {
  79. background: hsl(30, 20%, 23%);
  80. }
  81. }
  82. /*]]>*/
  83. </style>
  84. <title><xsl:value-of select="doap:name"/> – DOAP</title>
  85. </head>
  86. <body>
  87. <div id="name">
  88. <h1><xsl:value-of select="doap:name"/><xsl:text> </xsl:text><a href="#name">¶</a></h1>
  89. </div>
  90. <div id="shortdesc">
  91. <xsl:for-each select="doap:shortdesc">
  92. <p xml:lang="{@xml:lang}" lang="{@xml:lang}">
  93. <em><xsl:value-of select="."/></em>
  94. <!-- sup><a href="http://lexvo.org/id/iso639-1/{@xml:lang}"><xsl:value-of select="@xml:lang"/></a></sup -->
  95. </p>
  96. </xsl:for-each>
  97. </div>
  98. <div id="description">
  99. <xsl:for-each select="doap:description">
  100. <p xml:lang="{@xml:lang}" lang="{@xml:lang}">
  101. <xsl:value-of select="."/>
  102. <!-- sup><a href="http://lexvo.org/id/iso639-1/{@xml:lang}"><xsl:value-of select="@xml:lang"/></a></sup -->
  103. </p>
  104. </xsl:for-each>
  105. </div>
  106. <ul>
  107. <xsl:for-each select="doap:readme">
  108. <li class="readme"><a href="{@rdf:resource}">Readme</a></li>
  109. </xsl:for-each>
  110. <xsl:for-each select="doap:homepage">
  111. <li class="homepage"><a href="{@rdf:resource}">Homepage</a></li>
  112. </xsl:for-each>
  113. <xsl:for-each select="doap:mailing-list">
  114. <li class="mailing-list"><a href="{@rdf:resource}">Mailing List</a></li>
  115. </xsl:for-each>
  116. <xsl:for-each select="doap:bug-database">
  117. <li class="bug-database"><a href="{@rdf:resource}">Bug Database</a></li>
  118. </xsl:for-each>
  119. <xsl:for-each select="doap:wiki">
  120. <li class="wiki"><a href="{@rdf:resource}">Wiki</a></li>
  121. </xsl:for-each>
  122. <xsl:for-each select="doap:license">
  123. <li class="license"><a href="{@rdf:resource}">License</a></li>
  124. </xsl:for-each>
  125. <xsl:for-each select="doap:service-endpoint">
  126. <li class="service-endpoint"><a href="{@rdf:resource}">Service Endpoint</a></li>
  127. </xsl:for-each>
  128. </ul>
  129. <div id="implements">
  130. <h2>Implements <a href="#implements">¶</a></h2>
  131. <ul>
  132. <xsl:for-each select="doap:implements">
  133. <li class="implements">
  134. <a href="{@rdf:resource}"><xsl:value-of select="@rdf:resource"/></a>
  135. </li>
  136. </xsl:for-each>
  137. </ul>
  138. </div>
  139. <div id="programming-language">
  140. <h2>Programming Language <a href="#programming-language">¶</a></h2>
  141. <p>
  142. <xsl:for-each select="doap:programming-language">
  143. <span><xsl:value-of select="."/></span>,
  144. </xsl:for-each>
  145. </p>
  146. </div>
  147. <div id="repositories">
  148. <h2>Repositories <a href="#repositories">¶</a></h2>
  149. <ul>
  150. <xsl:for-each select="doap:repository/*[doap:location]/doap:browse">
  151. <li>
  152. <a href="{@rdf:resource}"><xsl:value-of select="@rdf:resource"/></a>
  153. </li>
  154. </xsl:for-each>
  155. <xsl:for-each select="doap:repository/*[not(doap:location)]/doap:browse">
  156. <li>
  157. <a href="{@rdf:resource}"><xsl:value-of select="@rdf:resource"/></a>
  158. </li>
  159. </xsl:for-each>
  160. </ul>
  161. </div>
  162. <p id="sep">* * *</p>
  163. <p id="poweredby">RDF (<a href="https://en.wikipedia.org/wiki/DOAP">DOAP</a>): <tt>$ <a href=
  164. "http://librdf.org/raptor/rapper.html">rapper</a> --guess --output turtle '<span id=
  165. "my-url">https://example.com/url-to-here</span>'</tt></p><script type="text/javascript">
  166. //<![CDATA[
  167. document.getElementById('my-url').innerText = location.href;
  168. //]]>
  169. </script>
  170. </body>
  171. </html>
  172. </xsl:template>
  173. </xsl:stylesheet>