From d1c6f3deb3770d0cfeeed1b4f17e315fa7bcd0e2 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Thu, 18 Apr 2024 07:08:09 +0200
Subject: [PATCH] Offline slide+webhelp usage

---
 .../slide/slideAssets/js/docbookSupp.js       |  24 +---
 ws/Docbook/CustomLayer/slide/xsl/slideHdm.xsl |  11 +-
 .../CustomLayer/webhelp/hdmextensions.xsl     |   9 +-
 .../Tdata/Common/Components/exampleSlides.xml |  26 +++-
 ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl | 128 ++++++++++--------
 ws/Docbook/Preprocess/make.rules              |   1 +
 6 files changed, 110 insertions(+), 89 deletions(-)

diff --git a/ws/Docbook/CustomLayer/slide/slideAssets/js/docbookSupp.js b/ws/Docbook/CustomLayer/slide/slideAssets/js/docbookSupp.js
index 17db3b63c..3204f2f48 100644
--- a/ws/Docbook/CustomLayer/slide/slideAssets/js/docbookSupp.js
+++ b/ws/Docbook/CustomLayer/slide/slideAssets/js/docbookSupp.js
@@ -14,30 +14,10 @@ Reveal.initialize({
     },
     // Optional reveal.js plugins
     dependencies: [
-        {
-            src: 'reveal.js/lib/js/classList.js', condition: function () {
-                return !document.body.classList;
-            }
-        },
-        {
-            src: 'reveal.js/plugin/markdown/marked.js', condition: function () {
-                return !!document.querySelector('[data-markdown]');
-            }
-        },
-        {
-            src: 'reveal.js/plugin/markdown/markdown.js', condition: function () {
-                return !!document.querySelector('[data-markdown]');
-            }
-        },
-        {
-            src: 'https://freedocs.mi.hdm-stuttgart.de/lib/highlight.js/highlight.min.js',
-            async: true,
-            callback: function () {
-                hljs.highlightAll();
-            }
-        },
+
         {src: 'reveal.js/plugin/zoom-js/zoom.js', async: true},
         {src: 'reveal.js/plugin/notes/notes.js', async: true},
+        {src: 'reveal.js/plugin/highlight/highlight.js', async: true},
         {src: 'reveal.js/plugin/math/math.js', async: true}
     ]
 });
diff --git a/ws/Docbook/CustomLayer/slide/xsl/slideHdm.xsl b/ws/Docbook/CustomLayer/slide/xsl/slideHdm.xsl
index 3f071f1f5..606e3faa9 100644
--- a/ws/Docbook/CustomLayer/slide/xsl/slideHdm.xsl
+++ b/ws/Docbook/CustomLayer/slide/xsl/slideHdm.xsl
@@ -132,9 +132,12 @@
                         </div>
                     </div>
 
-                    <script src="reveal.js/js/reveal.js"/>
-                    <script src="common/jquery/jquery-1.7.2.min.js"/>
-                    <script src="slideAssets/js/docbookSupp.js"/>
+                    <script src="common/jquery/jquery-1.7.2.min.js"></script>
+
+                    <script src="reveal.js/js/reveal.js"></script>
+
+                    <script src="slideAssets/js/docbookSupp.js"></script>
+
                 </body>
             </html>
         </xsl:document>
@@ -707,7 +710,7 @@
 
             <xsl:choose>
 
-                <xsl:when test="not(@language) or @language = 'none'">
+                <xsl:when test="not(@language) or @language = 'none' or .//* " >
                     <xsl:apply-templates/>
                 </xsl:when>
 
diff --git a/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl b/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl
index c3ce8fc70..e414c92ab 100644
--- a/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl
+++ b/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl
@@ -27,13 +27,12 @@
       </script>
     </xsl:if>
     
-    <xsl:if test="//d:programlisting[@language and @language != 'none']|//d:screen[@language and @language != 'none']|//d:synopsis[@language and @language != 'none']">
-      <link rel="stylesheet" type="text/css" href="https://freedocs.mi.hdm-stuttgart.de/lib/highlight.js/styles/idea.min.css"/>
-      <script type="text/javascript" src="https://freedocs.mi.hdm-stuttgart.de/lib/highlight.js/highlight.min.js"></script>
+    <xsl:if test="//d:programlisting[@language and @language != 'none']|//d:screen[@language and
+               @language != 'none']|//d:synopsis[@language and @language != 'none']">
+      <link rel="stylesheet" type="text/css"  href="highlightjs/styles/default.min.css"/>
+      <script type="text/javascript"  src="highlightjs/highlight.min.js"></script>
       <script type="text/javascript">hljs.highlightAll();</script>
     </xsl:if>
-    
-    
   </xsl:template>
   
   <!-- No logo related parameter on offer, sigh! -->
diff --git a/ws/Docbook/Extensions/Tdata/Common/Components/exampleSlides.xml b/ws/Docbook/Extensions/Tdata/Common/Components/exampleSlides.xml
index e933f832e..68d10c1c2 100644
--- a/ws/Docbook/Extensions/Tdata/Common/Components/exampleSlides.xml
+++ b/ws/Docbook/Extensions/Tdata/Common/Components/exampleSlides.xml
@@ -166,9 +166,29 @@
         </calloutlist>
       </figure>
 
-      <tip>
-        <para>You may require a <code>return</code> statement as well.</para>
-      </tip>
+      <figure xml:id="fig_javaApiClassReference">
+        <title>Java API class reference</title>
+
+        <itemizedlist>
+          <listitem>
+            <para>A normal <classname
+            xlink:href="https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Scanner.html">Scanner</classname>
+            reference</para>
+          </listitem>
+
+          <listitem>
+            <para>Referencing <link
+            xlink:href="javaapi://java.util.String">List</link> by Java
+            package syntax</para>
+          </listitem>
+
+          <listitem>
+            <para>Simplified <link
+            xlink:href="javaapi://java.lang.String">String</link> reference
+            for <package>java.lang</package> default package</para>
+          </listitem>
+        </itemizedlist>
+      </figure>
 
       <qandaset defaultlabel="qanda" xml:id="qandaCalloutRelated">
         <title>General class syntax related exercise</title>
diff --git a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
index d4c12c1a3..9d39ba91b 100644
--- a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
+++ b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
-  xmlns:xlink="http://www.w3.org/1999/xlink"
-  xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook">
-  
-  
+                xmlns:xlink="http://www.w3.org/1999/xlink"
+                xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook">
+
+
   <xsl:include href="common.xsl"/>
-  
+
   <xsl:param name="generateIdPrefix">__sdwordm4342cs__</xsl:param>
   <xsl:param name="nl">
     <xsl:text>
@@ -14,7 +14,7 @@
 
   <xsl:output indent="no"/>
   <xsl:param name="lastAnswerId" select="document('lastAnswerId.xml',/)/lastAnswer/@id" />
-  
+
   <!-- Excluding glossary self references  -->
   <xsl:key name="internRef" match="//*[@linkend and not(ancestor::db:glossary)]" use="@linkend"/>
 
@@ -36,29 +36,47 @@
       </xsl:for-each>
     </xsl:result-document>
 
-  <!-- Create list of external links -->
-  <xsl:result-document href="target/externalLinkList.txt" method="text">
-    <xsl:for-each select="//*/@xlink:href">
-      <xsl:for-each select="ancestor::*/@xml:base">
-        <xsl:call-template name="hdm.get.leftmost.of.separator">
-          <xsl:with-param name="path" select="."/>
-          <xsl:with-param name="separator" select="'/'"/>
-        </xsl:call-template>
-        <xsl:text>/</xsl:text>
+    <!-- Create list of external links -->
+    <xsl:result-document href="target/externalLinkList.txt" method="text">
+      <xsl:for-each select="//*/@xlink:href">
+        <xsl:for-each select="ancestor::*/@xml:base">
+          <xsl:call-template name="hdm.get.leftmost.of.separator">
+            <xsl:with-param name="path" select="."/>
+            <xsl:with-param name="separator" select="'/'"/>
+          </xsl:call-template>
+          <xsl:text>/</xsl:text>
+        </xsl:for-each>
+        <xsl:value-of select="."/>
+        <xsl:value-of select="$nl"/>
       </xsl:for-each>
-      <xsl:value-of select="."/>
-      <xsl:value-of select="$nl"/>
-    </xsl:for-each>
-  </xsl:result-document>
+    </xsl:result-document>
 
-</xsl:template>
+  </xsl:template>
 
-<xsl:template match="node() | @*">
+  <xsl:template match="node() | @*">
     <xsl:copy>
       <xsl:apply-templates select="node()| @*"/>
     </xsl:copy>
   </xsl:template>
-  
+
+  <xsl:template match="@db:href">
+    <xsl:choose>
+      <xsl:when test="starts-with(., 'javaapi://')">
+        <xsl:variable name="javaClassReference" select="substring-after(., 'javaapi://')"/>
+        <xsl:text>https://docs.oracle.com/en/java/javase/17/docs/api/java.base/</xsl:text>
+
+        <xsl:value-of select="$javaClassReference"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <text>otherwise</text>
+        <xsl:value-of select="."/>
+      </xsl:otherwise>
+    </xsl:choose>
+
+  </xsl:template>
+
+
+
   <xsl:template match="*" mode="hdmIdGenerate">
     <xsl:choose>
       <xsl:when test="@xml:id">
@@ -70,7 +88,7 @@
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
-  
+
   <!-- Providing list of exercises -->
   <xsl:template match="db:book[not(db:part)]|db:part">
     <xsl:copy>
@@ -78,7 +96,7 @@
       <xsl:if test=".//db:qandaset">
         <appendix>
           <title>List of Exercises</title>
-          
+
           <table border="1" xml:id="{@xml:id}tableExercise">
             <caption>
               <xsl:text>Exercises in </xsl:text>
@@ -99,7 +117,7 @@
               <th>Title</th>
               <th>Status of completion</th>
             </tr>
-            
+
             <xsl:for-each-group select=".//db:qandaset" group-by="ancestor::db:chapter/@xml:id">
               <xsl:for-each select="current-group()">
                 <tr>
@@ -117,8 +135,8 @@
                   <td/> <!-- empty status of completion -->
                 </tr>
               </xsl:for-each>
-              
-            </xsl:for-each-group>                    
+
+            </xsl:for-each-group>
           </table>
           <!-- Not really useful:
             
@@ -126,14 +144,14 @@
           -->
         </appendix>
       </xsl:if>
-    </xsl:copy>        
+    </xsl:copy>
   </xsl:template>
-  
+
   <xsl:template match="db:qandaset" mode="qandaNumber">
-    <xsl:variable name="parentId" select="ancestor::db:part/@xml:id"/>    
+    <xsl:variable name="parentId" select="ancestor::db:part/@xml:id"/>
     <xsl:value-of select="count(preceding::db:qandaset[ancestor::db:part/@xml:id = $parentId]) + 1"/>
   </xsl:template>
-    
+
   <xsl:template match="db:chapter" mode="genQuandaset">
     <section xml:id="{@xml:id}_qanda">
       <title>
@@ -146,20 +164,20 @@
       </title>
       <itemizedlist>
         <xsl:for-each select="descendant::db:qandaset">
-            <listitem>
-              <para>
-                <link linkend="{@xml:id}">
-                  <xsl:apply-templates select="." mode="selectOwnOrInheritedTitle"/>
-                </link>
-              </para>
-            </listitem>
-        </xsl:for-each>                    
-      </itemizedlist>  
+          <listitem>
+            <para>
+              <link linkend="{@xml:id}">
+                <xsl:apply-templates select="." mode="selectOwnOrInheritedTitle"/>
+              </link>
+            </para>
+          </listitem>
+        </xsl:for-each>
+      </itemizedlist>
     </section>
   </xsl:template>
-  
+
   <!-- Excluding non-referenced <bibliography> and <glossary> elements -->
-  
+
   <xsl:template match="db:bibliography/db:biblioentry[not(key('internRef', @xml:id))]">
     <xsl:comment>
       <xsl:text>Excluding non referenced bibliography entry '</xsl:text>
@@ -169,9 +187,9 @@
       <xsl:text>'</xsl:text>
     </xsl:comment>
   </xsl:template>
-  
+
   <xsl:template match="db:glossary//db:glosslist">
-    
+
     <xsl:choose>
       <xsl:when test=".//db:glossentry[key('internRef', @xml:id) or key('internRef', .//*/@xml:id)]">
         <xsl:comment>Non-empty glosslist</xsl:comment>
@@ -183,11 +201,11 @@
         <xsl:comment>
           <xsl:text>No @xml:id or all glosslist entries are not being referenced, excluding whole list.</xsl:text>
         </xsl:comment>
-        <xsl:apply-templates select="db:glossentry"/>        
+        <xsl:apply-templates select="db:glossentry"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
-  
+
   <xsl:template match="db:glossary/db:glosslist//db:glossentry[not(key('internRef', @xml:id)) and not(key('internRef', .//*/@xml:id))]">
     <xsl:comment>
       <xsl:text>Excluding non referenced glossary entry '</xsl:text>
@@ -197,7 +215,7 @@
       <xsl:text>'</xsl:text>
     </xsl:comment>
   </xsl:template>
-  
+
   <!-- 
     <xsl:template match="db:bibliography">
     <db:bibliography>
@@ -212,14 +230,14 @@
     </db:glosslist>
     </xsl:template>
   -->
-  
-  <!-- make annotations -->  
+
+  <!-- make annotations -->
   <xsl:template match="db:annotation[@role='make']">
     <xsl:apply-templates select="*" mode="make"/>
   </xsl:template>
-  
+
   <xsl:template match="db:para[@role='eclipse']" mode='make'>
-    
+
     <itemizedlist>
       <listitem>
         <para>
@@ -230,7 +248,7 @@
           <xsl:text>.</xsl:text>
         </para>
       </listitem>
-      
+
       <listitem>
         <para>
           <xsl:text>See </xsl:text>
@@ -238,10 +256,10 @@
           <xsl:text>.</xsl:text>
         </para>
       </listitem>
-      
+
     </itemizedlist>
   </xsl:template>
-  
+
   <xsl:template match="*" mode="make">
     <db:para>
       <xsl:text>No template of mode='make' defined for element'</xsl:text>
@@ -249,5 +267,5 @@
       <xsl:text>'</xsl:text>
     </db:para>
   </xsl:template>
-  
+
 </xsl:stylesheet>
diff --git a/ws/Docbook/Preprocess/make.rules b/ws/Docbook/Preprocess/make.rules
index b6cbc041e..e9cbec722 100644
--- a/ws/Docbook/Preprocess/make.rules
+++ b/ws/Docbook/Preprocess/make.rules
@@ -120,6 +120,7 @@ SAXONCMD=java -cp "${DBOOK_XSL}/tools/lib/saxon9he.jar:/usr/share/java/xercesImp
 	rsync -a ${DBOOK_XSL_CUSTOM}/webhelp/common/jquery-jcarousel common
 	cp ${DBOOK_XSL_CUSTOM}/webhelp/common/images/favicon.ico .
 	rsync -a --exclude='mathjax/.git' --exclude='mathjax/docs' --exclude='mathjax/.gitignore' /usr/share/hdmwebhelp/extern/libs/mathjax .
+	tar zxf /usr/share/hdm-docbook-xsl/CustomLayer/lib/highlightjs-11.9.0.tgz
 	cd ${DBOOK_XSL}/webhelp/template/search; \
            cp nwSearchFnt.js default.props punctuation.props en-us.props stemmers/en_stemmer.js \
            ${DIR}/search
-- 
GitLab