Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
8.5KB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:dt="http://xsltsl.org/date-time"
  5. exclude-result-prefixes="dt">
  6. <xsl:import href="translations.xsl" />
  7. <xsl:import href="static-elements.xsl" />
  8. <xsl:import href="date-time.xsl" />
  9. <xsl:output method="xml" encoding="utf-8" indent="yes" />
  10. <!-- define content type templates-->
  11. <xsl:template name="news">
  12. <xsl:param name="display-year" select="'no'" />
  13. <xsl:param name="show-date" select="'yes'" />
  14. <xsl:param name="compact-view" select="'no'" />
  15. <xsl:variable name="link">
  16. <xsl:value-of select="link" />
  17. </xsl:variable>
  18. <xsl:variable name="day">
  19. <xsl:value-of select="substring(@date,9,2)" />
  20. </xsl:variable>
  21. <xsl:variable name="month">
  22. <xsl:call-template name="dt:get-month-name">
  23. <xsl:with-param name="month" select="substring(@date,6,2)" />
  24. </xsl:call-template>
  25. </xsl:variable>
  26. <xsl:variable name="year">
  27. <xsl:value-of select="substring(@date,1,4)" />
  28. </xsl:variable>
  29. <xsl:variable name="title">
  30. <xsl:choose>
  31. <xsl:when test="$link != ''">
  32. <a href="{link}">
  33. <xsl:value-of select="title" />
  34. </a>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <xsl:value-of select="title" />
  38. </xsl:otherwise>
  39. </xsl:choose>
  40. </xsl:variable>
  41. <xsl:variable name="date">
  42. <xsl:value-of select="$day" />
  43. <xsl:text> </xsl:text>
  44. <xsl:value-of select="$month" />
  45. <xsl:if test="$display-year = 'yes'">
  46. <xsl:text> </xsl:text>
  47. <xsl:value-of select="$year" />
  48. </xsl:if>
  49. <xsl:text>: </xsl:text>
  50. </xsl:variable>
  51. <!--<div class="entry">-->
  52. <xsl:element name="div">
  53. <xsl:attribute name="class">entry</xsl:attribute>
  54. <!-- title -->
  55. <h3>
  56. <xsl:call-template name="generate-id-attribute">
  57. <xsl:with-param name="title" select="title" />
  58. </xsl:call-template>
  59. <xsl:copy-of select="$title" />
  60. </h3>
  61. <!-- news date -->
  62. <xsl:if test="$show-date = 'yes'">
  63. <p class="date">
  64. <xsl:copy-of select="$date" />
  65. </p>
  66. </xsl:if>
  67. <!-- news text -->
  68. <xsl:if test="$compact-view = 'no'">
  69. <div class="text">
  70. <xsl:apply-templates select="body/node()" />
  71. </div>
  72. </xsl:if>
  73. </xsl:element>
  74. </xsl:template>
  75. <!-- Show a single newsletter item -->
  76. <xsl:template name="newsletter">
  77. <xsl:variable name="link">
  78. <xsl:value-of select="link" />
  79. </xsl:variable>
  80. <li>
  81. <a href="{link}">
  82. <xsl:value-of select="title" />
  83. </a>
  84. </li>
  85. </xsl:template>
  86. <!-- Show a single event -->
  87. <xsl:template name="event">
  88. <xsl:param name="header" select="''" />
  89. <xsl:param name="display-details" select="'no'" />
  90. <xsl:param name="display-year" select="'no'" />
  91. <!-- Create variables -->
  92. <xsl:variable name="start">
  93. <xsl:value-of select="@start" />
  94. </xsl:variable>
  95. <xsl:variable name="start_day">
  96. <xsl:value-of select="substring($start,9,2)" />
  97. </xsl:variable>
  98. <xsl:variable name="start_month">
  99. <xsl:call-template name="dt:get-month-name">
  100. <xsl:with-param name="month"
  101. select="substring($start,6,2)" />
  102. </xsl:call-template>
  103. </xsl:variable>
  104. <xsl:variable name="end">
  105. <xsl:value-of select="@end" />
  106. </xsl:variable>
  107. <xsl:variable name="end_day">
  108. <xsl:value-of select="substring($end,9,2)" />
  109. </xsl:variable>
  110. <xsl:variable name="end_month">
  111. <xsl:call-template name="dt:get-month-name">
  112. <xsl:with-param name="month"
  113. select="substring($end,6,2)" />
  114. </xsl:call-template>
  115. </xsl:variable>
  116. <xsl:variable name="end_year">
  117. <xsl:value-of select="substring($end,1,4)" />
  118. </xsl:variable>
  119. <xsl:variable name="link">
  120. <xsl:value-of select="link" />
  121. </xsl:variable>
  122. <xsl:variable name="page">
  123. <xsl:value-of select="page" />
  124. </xsl:variable>
  125. <!-- Before the first event, include the header -->
  126. <xsl:if test="position() = 1 and $header != ''">
  127. <h2>
  128. <xsl:call-template name="generate-id-attribute">
  129. <xsl:with-param name="title" select="/buildinfo/document/text[@id = $header]" />
  130. </xsl:call-template>
  131. <xsl:value-of select="/buildinfo/document/text[@id = $header]" />
  132. </h2>
  133. </xsl:if>
  134. <!-- Now, the event block -->
  135. <xsl:element name="div">
  136. <xsl:attribute name="class">entry</xsl:attribute>
  137. <xsl:attribute name="id">
  138. <xsl:value-of select="@filename" />
  139. </xsl:attribute>
  140. <!-- event map -->
  141. <xsl:if test="./place">
  142. <xsl:variable name="map-id" select="position()"/>
  143. <div id="map-{$map-id}" class="map"></div>
  144. <script type="text/javascript">
  145. /* &lt;![CDATA[ */
  146. map_init('map-<xsl:value-of select="$map-id"/>', <xsl:value-of select="./place/lat"/>, <xsl:value-of select="./place/lon"/>)
  147. /* ]]&gt; */
  148. </script>
  149. <noscript><!-- TODO --></noscript>
  150. </xsl:if>
  151. <!-- event title with or without link -->
  152. <h3>
  153. <xsl:call-template name="generate-id-attribute">
  154. <xsl:with-param name="title" select="title" />
  155. </xsl:call-template>
  156. <xsl:choose>
  157. <xsl:when test="$link != ''">
  158. <a href="{link}">
  159. <xsl:value-of select="title" />
  160. </a>
  161. </xsl:when>
  162. <xsl:when test="$page != ''">
  163. <a href="{page}">
  164. <xsl:value-of select="title" />
  165. </a>
  166. </xsl:when>
  167. <xsl:otherwise>
  168. <xsl:value-of select="title" />
  169. </xsl:otherwise>
  170. </xsl:choose>
  171. </h3>
  172. <!-- event date -->
  173. <xsl:choose>
  174. <xsl:when test="$start != $end">
  175. <p class="date">
  176. <xsl:value-of select="$start_day" />
  177. <xsl:text> </xsl:text>
  178. <xsl:if test="$start_month != $end_month">
  179. <xsl:value-of select="$start_month" />
  180. </xsl:if>
  181. <xsl:text> to </xsl:text>
  182. <xsl:value-of select="$end_day" />
  183. <xsl:text> </xsl:text>
  184. <xsl:value-of select="$end_month" />
  185. <xsl:if test="$display-year = 'yes'">
  186. <xsl:text> </xsl:text>
  187. <xsl:value-of select="$end_year" />
  188. </xsl:if>
  189. </p>
  190. </xsl:when>
  191. <xsl:otherwise>
  192. <p class="date">
  193. <xsl:value-of select="$start_day" />
  194. <xsl:text> </xsl:text>
  195. <xsl:value-of select="$start_month" />
  196. <xsl:if test="$display-year = 'yes'">
  197. <xsl:text> </xsl:text>
  198. <xsl:value-of select="$end_year" />
  199. </xsl:if>
  200. </p>
  201. </xsl:otherwise>
  202. </xsl:choose>
  203. <!-- and possibly details about the event -->
  204. <xsl:if test="$display-details = 'yes'">
  205. <div class="details">
  206. <xsl:apply-templates select="body/node()" />
  207. </div>
  208. </xsl:if>
  209. </xsl:element>
  210. </xsl:template>
  211. <!-- Show a person's avatar -->
  212. <xsl:template name="avatar">
  213. <xsl:param name="id" />
  214. <xsl:param name="haveavatar" select="'no'" />
  215. <xsl:variable name="fullname">
  216. <xsl:value-of select="name" />
  217. </xsl:variable>
  218. <xsl:variable name="img-path">
  219. <xsl:choose>
  220. <xsl:when test="$haveavatar='yes'"><xsl:value-of select="concat( '/about/', $id, '/', $id, '-avatar.jpg' )" /></xsl:when>
  221. <xsl:otherwise>/graphics/default-avatar.png</xsl:otherwise>
  222. </xsl:choose>
  223. </xsl:variable>
  224. <xsl:variable name="alt-text">
  225. <xsl:choose>
  226. <xsl:when test="$haveavatar = 'yes'">
  227. <xsl:value-of select="concat( '[ ', $fullname, ' ]' )" />
  228. </xsl:when>
  229. <xsl:otherwise>[ <xsl:call-template name="gettext">
  230. <xsl:with-param name="id" select="'no-avatar'" />
  231. </xsl:call-template> ]</xsl:otherwise>
  232. </xsl:choose>
  233. </xsl:variable>
  234. <xsl:element name="img">
  235. <xsl:attribute name="src">
  236. <xsl:value-of select="$img-path" />
  237. </xsl:attribute>
  238. <xsl:attribute name="alt">
  239. <xsl:value-of select="$alt-text" />
  240. </xsl:attribute>
  241. </xsl:element>
  242. </xsl:template>
  243. </xsl:stylesheet>