schedule2html.xslt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. @@LICENSE
  4. http://www.w3.org/TR/xslt/
  5. -->
  6. <xsl:stylesheet
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. exclude-result-prefixes="xsl"
  9. version="1.0">
  10. <xsl:output
  11. method="html"
  12. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  13. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  14. <xsl:template match="/schedule">
  15. <xsl:variable name="event_base_url">
  16. <xsl:choose>
  17. <xsl:when test="'31c3' = conference/acronym">https://events.ccc.de/congress/2014</xsl:when>
  18. <xsl:when test="'32c3' = conference/acronym">https://events.ccc.de/congress/2015</xsl:when>
  19. <xsl:when test="'33c3' = conference/acronym">https://events.ccc.de/congress/2016</xsl:when>
  20. <xsl:when test="'34c3' = conference/acronym">https://events.ccc.de/congress/2017</xsl:when>
  21. <xsl:when test="'35c3' = conference/acronym">..</xsl:when>
  22. <xsl:otherwise>foo</xsl:otherwise>
  23. </xsl:choose>
  24. </xsl:variable>
  25. <html xmlns="http://www.w3.org/1999/xhtml" manifest="index.manifest">
  26. <head>
  27. <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  28. <!-- https://developer.apple.com/library/IOS/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html#//apple_ref/doc/uid/TP40006509-SW26 -->
  29. <!-- http://maddesigns.de/meta-viewport-1817.html -->
  30. <!-- meta name="viewport" content="width=device-width"/ -->
  31. <!-- http://www.quirksmode.org/blog/archives/2013/10/initialscale1_m.html -->
  32. <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
  33. <!-- meta name="viewport" content="width=400"/ -->
  34. <!--
  35. <link href="../assets/Chaosknoten.svg" rel="shortcut icon" type="image/svg"/>
  36. <link href="../assets/Chaosknoten.svg" rel="apple-touch-icon" type="image/svg"/>
  37. -->
  38. <link rel="apple-touch-icon" href="../assets/tuwat-250x250.png"/>
  39. <link rel="apple-touch-startup-image" href="../assets/tuwat-250x250.png"/>
  40. <link href="../assets/style.css" rel="stylesheet" type="text/css"/>
  41. <title><xsl:value-of select="conference/acronym"/></title>
  42. <style type="text/css">
  43. /*&lt;![CDATA[*/<![CDATA[
  44. @media screen and (max-width: 376px) {
  45. /* http://maddesigns.de/meta-viewport-1817.html */
  46. html {
  47. font-size: 100%;
  48. }
  49. }
  50. @media screen and (max-width: 321px) {
  51. /* http://maddesigns.de/meta-viewport-1817.html */
  52. html {
  53. font-size: 90%;
  54. }
  55. }
  56. ]]>/*]]&gt;*/
  57. </style>
  58. <script type="text/javascript">
  59. //&lt;![CDATA[*/<![CDATA[
  60. function makeICalUri(elem,uid,locatio,dtstart,duration,summary,abstrac,persons,url) {
  61. // var speaker = "";
  62. // if(false) {
  63. // for(i = 0; i < persons.length; i++) {
  64. // if( 0 < speaker.length )
  65. // speaker += ", ";
  66. // speaker += persons.item(i).textContent;
  67. // }
  68. // if( 0 < speaker.length )
  69. // speaker += ": ";
  70. // }
  71. // http://stackoverflow.com/questions/15439922/datauri-for-ical-does-not-work-on-android-or-iphone
  72. var icalstr = "BEGIN:VCALENDAR\r\n\
  73. VERSION:2.0\r\n\
  74. PRODID:-//purl.mro.name/32c3//NONSGML v1.0//EN\r\n\
  75. BEGIN:VEVENT\r\n\
  76. SUMMARY:" + summary + "\r\n\
  77. LOCATION:" + locatio + "\r\n\
  78. DTSTART:" + /* @todo: not timezone safe! */ dtstart.replace(/[-:]/g,'').substring(0, 4+2+2+1+2+2+2) + "\r\n\
  79. DURATION:" + "PT" + duration.substring(0,2) + "H" + duration.substring(3,5) + "M" + "\r\n\
  80. URL;VALUE=URI:" + url + "\r\n\
  81. UID:" + uid + "\r\n\
  82. DESCRIPTION:" + abstrac + "\r\n\
  83. UID:" + uid + "\r\n";
  84. // UID duplicate to frame shaky DESCRIPTION linefeed encoding.
  85. for(i = 0; i < persons.length; i++)
  86. icalstr += "ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR;CN=\"" + persons.item(i).textContent + "\":invalid:nomail" + "\r\n";
  87. icalstr += "END:VEVENT\r\n\
  88. END:VCALENDAR\r\n";
  89. // DTEND:" + "20160101T010100" + "\r\n\
  90. // DESCRIPTION:description\r\n\
  91. elem.download = uid + '.ics';
  92. elem.href = "data:text/calendar," + encodeURIComponent(icalstr);
  93. }
  94. var baseUrl = (document.location + '').replace(/#.*$/,'');
  95. ]]>//]]&gt;
  96. </script>
  97. </head>
  98. <body>
  99. <p><a href="..">..</a></p>
  100. <div id="schedule">
  101. <h1><xsl:value-of select="conference/acronym"/></h1>
  102. <p><xsl:value-of select="version"/></p>
  103. <ul class="days">
  104. <xsl:for-each select="day">
  105. <li><a href="#day_{@index}">Dec <xsl:value-of select="substring(@date,9,2)"/><sup>th</sup> (Day <xsl:value-of select="@index"/>)</a></li>
  106. </xsl:for-each>
  107. </ul>
  108. <xsl:for-each select="day">
  109. <h2 id="day_{@index}">Dec <xsl:value-of select="substring(@date,9,2)"/><sup>th</sup> (Day <xsl:value-of select="@index"/>)</h2>
  110. <xsl:for-each select="room">
  111. <h3><xsl:value-of select="@name"/></h3>
  112. <ul class="event_list">
  113. <xsl:for-each select="event">
  114. <xsl:sort select="date"/>
  115. <xsl:variable name="ev_id" select="concat('event_', @id)"/>
  116. <li>
  117. <div style="display:none">
  118. <span id="{$ev_id}_location"><xsl:value-of select="../@name"/></span>
  119. <span id="{$ev_id}_dtstart"><xsl:value-of select="date"/></span>
  120. <span id="{$ev_id}_duration"><xsl:value-of select="duration"/></span>
  121. <span id="{$ev_id}_abstract"><xsl:value-of select="abstract"/></span>
  122. <span id="{$ev_id}_description"><xsl:value-of select="description"/></span>
  123. <div id="{$ev_id}_attendee">
  124. <xsl:for-each select="persons/person">
  125. <span><xsl:value-of select="."/></span>
  126. </xsl:for-each>
  127. </div>
  128. </div>
  129. <a title="iCal URL" class="ical" id="{$ev_id}_ical" href="">📅</a><xsl:text> </xsl:text>
  130. <a title="{date}" class="dtstart" id="{$ev_id}" href="#{$ev_id}"><xsl:value-of select="substring(date,12,5)"/></a><xsl:text> </xsl:text>
  131. <a title="Video URL" class="video" href="https://media.ccc.de/v/{slug}#video">📹</a><xsl:text> </xsl:text>
  132. <a class="text" id="{$ev_id}_title" href="{$event_base_url}/Fahrplan/events/{@id}.html"><xsl:value-of select="title"/></a>
  133. <script type="text/javascript">
  134. var ev_id = '<xsl:value-of select="$ev_id"/>';
  135. // console.log(ev_id + ' ' + document.getElementById(ev_id + '_dtstart').textContent);
  136. makeICalUri(
  137. document.getElementById(ev_id + '_ical'),
  138. ev_id,
  139. document.getElementById(ev_id + '_location').textContent,
  140. document.getElementById(ev_id + '_dtstart').textContent,
  141. document.getElementById(ev_id + '_duration').textContent,
  142. document.getElementById(ev_id + '_title').textContent,
  143. document.getElementById(ev_id + '_abstract').textContent,
  144. document.getElementById(ev_id + '_attendee').children,
  145. baseUrl + '#' + ev_id
  146. );
  147. </script>
  148. </li>
  149. </xsl:for-each>
  150. </ul>
  151. </xsl:for-each>
  152. </xsl:for-each>
  153. </div>
  154. </body>
  155. </html>
  156. </xsl:template>
  157. </xsl:stylesheet>