]> granicus.if.org Git - docbook-dsssl/commitdiff
ndexer: Removed the creation of separate js file for each alphabetic letter. Now...
authorKasun Gajasinghe <kasunbg@gmail.com>
Sun, 18 Jul 2010 11:36:57 +0000 (11:36 +0000)
committerKasun Gajasinghe <kasunbg@gmail.com>
Sun, 18 Jul 2010 11:36:57 +0000 (11:36 +0000)
Removed un
Brought build property names to a standard convention.
New property "stylesheet-path".

--Kasun Gajasinghe

xsl/webhelp/build.properties
xsl/webhelp/build.xml
xsl/webhelp/indexer/lib/nw-cms.jar
xsl/webhelp/indexer/src/com/nexwave/nquindexer/SaxHTMLIndex.java
xsl/webhelp/indexer/src/com/nexwave/nquindexer/WriteJSFiles.java
xsl/webhelp/template/common/css/positioning.css
xsl/webhelp/template/content/search/addition.js [deleted file]
xsl/webhelp/template/content/search/indexLoader.js [deleted file]
xsl/webhelp/xsl/webhelp.xsl

index a2bb4ef6a859b64690f422e76ce0e216d1d34b41..1acbf6eedc78595bb06ab1128bcfc7030bd3c045 100755 (executable)
@@ -1,5 +1,8 @@
 input-xml=docsrc/readme.xml
-frameset.base.dir=doc
+stylesheet-path=xsl/webhelp.xsl
+
+# Output directory
+base-dir=doc
 
 # Modify this so that it points to your copy of the Saxon 6.5 jar.
 xslt-processor-classpath=c:/workhead/export/saxon/6.5/lib/saxon.jar
index f7566c31edebe957a8a4968be27fe326e233560c..b707abc636d9f2671fbbf3db172c0c037fdaab19 100755 (executable)
 
   <target name="chunk" depends="clean">
        
-       <mkdir dir="${frameset.base.dir}"/>
+       <mkdir dir="${base-dir}"/>
        <xslt
          in="${input-xml}"
-         out="${frameset.base.dir}/dummy.html"
+         out="${base-dir}/dummy.html"
          style="${ant.file.dir}/xsl/webhelp.xsl"
          scanincludeddirectories="false"
          classpath="${xslt-processor-classpath}">
          <param name="exclude.search.from.chunked.html" expression="${exclude.search.from.chunked.html}"
                if="exclude.search.from.chunked.html"/>
          <param name="output_file_name" expression="${output_file_name}"/>
-         <param name="frameset.base.dir" expression="${frameset.base.dir}" if="frameset.base.dir"/>
+         <param name="webhelp.base.dir" expression="${base-dir}" if="base-dir"/>
          <param name="indexer.language" expression="${indexer-language}" if="indexer-language"/>
          <param name="chunk.frameset.start.filename" expression="${chunk.frameset.start.filename}"
                if="chunk.frameset.start.filename"/>
        </xslt>
        
-       <delete file="${frameset.base.dir}/dummy.html"/>
+       <delete file="${base-dir}/dummy.html"/>
 
        <!-- Copy common content such as js files of tree, css etc. to template folder. They will be copied to doc folder. They are NOT page specific! -->
-       <copy todir="${frameset.base.dir}">
+       <copy todir="${base-dir}">
          <fileset dir="${ant.file.dir}/template">
                <include name="**/*"/>
                <exclude name="**/content/search/*.props"/>
          </fileset>
        </copy>
        <!-- We separate this out so we only copy the stopwords list for the indexer language -->
-       <copy todir="${frameset.base.dir}">
+       <copy todir="${base-dir}">
          <fileset dir="${ant.file.dir}/template">
                <include name="**/content/search/default.props"/>
                <include name="**/content/search/punctuation.props"/>
        </copy>
        
        <!--Deletes all the stemmers that are copied to doc/ folder. Then, adds only the needed stemmer-->
-       <delete dir="${frameset.base.dir}/content/search/stemmers"/>
+       <delete dir="${base-dir}/content/search/stemmers"/>
        <copy todir="doc/content/search/stemmers/"
          file="template/content/search/stemmers/${indexer-language}_stemmer.js"/>
 
        <!-- Very simple-minded copy to handle the source document's images -->
        <!-- TODO: Look at html help code that produces a manifest file...list of images -->
        <!--       Customize webhelp.xsl to produce ant file to copy images used? -->
-       <copy todir="${frameset.base.dir}/content" failonerror="false">
+       <copy todir="${base-dir}/content" failonerror="false">
          <fileset dir="${input-images-dir}"/>
        </copy> 
 
          <classpath refid="nw-cms.jar.path"/>
        </taskdef>
 
-       <echo>Indexing html files in ${frameset.base.dir}/content</echo>
+       <echo>Indexing html files in ${base-dir}/content</echo>
 
-       <indexertask htmldir="${frameset.base.dir}/content" indexerLanguage="${indexer-language}"/>
+       <indexertask htmldir="${base-dir}/content" indexerLanguage="${indexer-language}"/>
 
        <delete>
-         <fileset dir="${frameset.base.dir}/content/search" includes="*.props"/>
+         <fileset dir="${base-dir}/content/search" includes="*.props"/>
        </delete>
 
        <delete file="xx.html"/>
   </target>
 
   <target name="clean">
-       <delete dir="${frameset.base.dir}"/>
+       <delete dir="${base-dir}"/>
   </target>
 
   <target name="help">
index 2d7fb6941b0d6e3fd8d5851862127ef0aadd57f9..fb52693bb53917e8191954dc917af92af9f7a8f8 100755 (executable)
Binary files a/xsl/webhelp/indexer/lib/nw-cms.jar and b/xsl/webhelp/indexer/lib/nw-cms.jar differ
index 391cf5599006f58434f06d570e0b85809f66f484..606dac5a27657014b39537c53d28a2a2d4faefdf 100755 (executable)
@@ -5,6 +5,8 @@ import java.util.*;
 \r
 // specific dita ot\r
 import com.nexwave.nsidita.DocFileInfo;\r
+\r
+//Stemmers\r
 import com.nexwave.stemmer.snowball.SnowballStemmer;\r
 import com.nexwave.stemmer.snowball.ext.EnglishStemmer;\r
 import com.nexwave.stemmer.snowball.ext.GermanStemmer;\r
@@ -20,8 +22,7 @@ import com.nexwave.stemmer.snowball.ext.GermanStemmer;
  * @author Kasun Gajasinghe <http://kasunbg.blogspot.com>\r
  */\r
 public class SaxHTMLIndex extends SaxDocFileParser{\r
-       \r
-       //members\r
+\r
     //KasunBG: apparently tempDico stores all the keywords and a pointer to the files containing the index in a Map\r
     //example: ("keyword1", "0,2,4"), ("docbook", "1,2,5") \r
        private Map<String,String> tempDico;\r
index 0700bf34233fc015d3fb040784b5dd0cbafe6425..5c6c45166e4d611491f3594b4cb209173e56d0b1 100755 (executable)
@@ -162,113 +162,47 @@ public class WriteJSFiles {
                tstr = (String)keyIt.next();\r
                \r
                File fileOut= new File(fileOutStr);\r
-               \r
-               /* if the key is not a letter, \r
-                * create an index file called 0.js in the output directory\r
-                */\r
-               if (tstr.matches("^[^a-z]{1}.*$")) {\r
-                       \r
-                       try {\r
-                               // open a outputstream, here a file\r
-                               fOut= new FileOutputStream(fileOut.getParent()+ File.separator + "0" + fileOut.getName());\r
-                               // open a buffer output stream\r
-                               bout= new BufferedOutputStream(fOut);\r
-                               // open a streamwriter\r
-                       out = new OutputStreamWriter(bout, "UTF-8");\r
-                       \r
-                       /* Populate a javascript hashmap: \r
-                        The key is a word to look for in the index,\r
-                        The value is the numbers of the files in which the word exists.\r
-                        Example: w["key"]="file1,file2,file3";*/\r
-                       out.write("\n");\r
-                               while ((keyIt.hasNext()) && (tstr.matches("^[^a-z]{1}.*$"))) {\r
-                                       out.write("w[\""+tstr+"\"]"+"= \""+indexMap.get(tstr)+"\";\n");\r
-                                       tstr = (String) keyIt.next();\r
-                               }\r
-\r
-                               out.write("\n");\r
-                       out.flush();  // Don't forget to flush!\r
-                       out.close();\r
-                       }\r
 \r
-                       catch (UnsupportedEncodingException e) {\r
-                               System.out.println(txt_VM_encoding_not_supported);\r
-                       }\r
-                       catch (IOException e) {\r
-                         System.out.println(e.getMessage());        \r
-                   }\r
-               }\r
-               \r
-               \r
-               /* If the key is a letter, \r
-                * create an index file called letter.js in the output directory\r
+        /* Writes the index to Three JS files, namely: index-1.js, index-2.js, index-3.js\r
+                * Index will be distributed evenly in these three files. \r
                 * tstr is the current key\r
-                * keyIt is the iterator of the key set*/\r
-               \r
-               char tempLetter = tstr.charAt(0);\r
-               while (keyIt.hasNext() && (tstr.matches("^[a-z]{1}.*$")) ) {\r
-               \r
-                       try {\r
-                               // open a outputstream, here a file\r
-                               fOut= new FileOutputStream(fileOut.getParent()+ File.separator + tempLetter + fileOut.getName());\r
-                               bout= new BufferedOutputStream(fOut);\r
-                       out = new OutputStreamWriter(bout, "UTF-8");\r
-                       \r
-                       /* Populate a javascript hashmap: \r
-                        The key is a word to look for in the index,\r
-                        The value is the numbers of the files in which the word exists.\r
-                        Example: w["key"]="file1,file2,file3";*/\r
-                       out.write("\n");\r
-                               while ((keyIt.hasNext()) && (tempLetter == tstr.charAt(0))) {\r
-       \r
-                                       out.write("w[\""+tstr+"\"]"+"= \""+indexMap.get(tstr)+"\";\n");\r
-                                       tstr = (String) keyIt.next();\r
-                               }\r
-                               tempLetter = tstr.charAt(0);\r
-                       out.write("\n");\r
-                       out.flush();  // Don't forget to flush!\r
-                       out.close();\r
-                       }\r
-                   catch (UnsupportedEncodingException e) {\r
-                         System.out.println(txt_VM_encoding_not_supported);\r
-                       }\r
-                       catch (IOException e) {\r
-                         System.out.println(e.getMessage());        \r
-                   }\r
-               }\r
-               \r
-               /* After processing the keys starting with a letter, \r
-                * do a last pass for other remaining char.\r
-               */\r
-               \r
-               try {\r
-                       // open a outputstream, here a file\r
-                       fOut= new FileOutputStream(fileOut.getParent()+ File.separator + "1" + fileOut.getName());\r
-                       bout= new BufferedOutputStream(fOut);\r
-               out = new OutputStreamWriter(bout, "UTF-8");\r
-               \r
-               /* Populate a javascript hashmap: \r
-                The key is a word to look for in the index,\r
-                The value is the numbers of the files in which the word exists.\r
-                Example: w["key"]="file1,file2,file3";*/\r
-               out.write("\n");\r
-                       while ((keyIt.hasNext())) {\r
-                               out.write("w[\""+tstr+"\"]"+"= \""+indexMap.get(tstr)+"\";\n");\r
-                               tstr = (String) keyIt.next();\r
-                       }\r
-                       out.write("w[\""+tstr+"\"]"+"= \""+indexMap.get(tstr)+"\";\n");\r
-                       tempLetter = tstr.charAt(0);\r
-               out.write("\n");\r
-               out.flush();  // Don't forget to flush!\r
-               out.close();\r
-               }\r
-           catch (UnsupportedEncodingException e) {\r
-                 System.out.println(txt_VM_encoding_not_supported);\r
-               }\r
-               catch (IOException e) {\r
-                 System.out.println(e.getMessage());        \r
-           }\r
+                * keyIt is the iterator of the key set\r
+                * */\r
+        int indexSize = sortedKeys.size(); \r
+        for (int i = 1; i <= 3; i++) {\r
+            try {\r
+                // open a outputstream, here a file\r
+                fOut = new FileOutputStream(fileOut.getParent() + File.separator + "index-" + i + fileOut.getName());\r
+                bout = new BufferedOutputStream(fOut);\r
+                out = new OutputStreamWriter(bout, "UTF-8");\r
 \r
+                try {\r
+                    /* Populate a javascript hashmap:\r
+                      The key is a word to look for in the index,\r
+                      The value is the numbers of the files in which the word exists.\r
+                      Example: w["key"]="file1,file2,file3";*/\r
+                    int count = 0;\r
+                    out.write("//Auto generated index for searching.\n");\r
+                    while (keyIt.hasNext()) {        //&& (tempLetter == tstr.charAt(0)) \r
+                        out.write("w[\"" + tstr + "\"]" + "=\"" + indexMap.get(tstr) + "\";\n");\r
+                        tstr = (String) keyIt.next();\r
+                        count++;\r
+                        if (indexSize / count < 3){\r
+                            break;\r
+                        }\r
+                    } \r
+                    out.write("\n");\r
+                    out.flush();  // Don't forget to flush!\r
+                    out.close();\r
+                }\r
+                catch (UnsupportedEncodingException e) {\r
+                    System.out.println(txt_VM_encoding_not_supported);\r
+                }\r
+            }\r
+            catch (IOException e) {\r
+                System.out.println(e.getMessage());\r
+            }\r
+        } \r
            System.out.println(txt_indices_location + fileOutStr);\r
        }\r
 }\r
index e9889a6620f69b75c76f67b85a29b53154995982..9721da741cf43aa70429056fef381dcc4f0e7f9e 100755 (executable)
@@ -1,18 +1,7 @@
-body {
-    font: 12px Verdana, Geneva, sans-serif;
-}
-
-p, ul, ol, li {
-    font: 10pt Verdana, Geneva, sans-serif;
-}
-
-h1 {
-    font: bold 15pt Arial, Helvetica, geneva;
-}
-
-h2 {
-    font: bold 14pt Arial, Helvetica, geneva;
-}
+body { font: 12px Verdana, Geneva, sans-serif; }
+p, ul, ol, li { font: 10pt Verdana, Geneva, sans-serif; }
+h1 { font: bold 15pt Arial, Helvetica, geneva; } 
+h2 { font: bold 14pt Arial, Helvetica, geneva; }
 
 #header {
     background: white url(../images/gov-header-bg.gif) repeat-x;
@@ -54,13 +43,11 @@ h2 {
     z-index: 1000;
 }
 
-#content h1, #content h2 {
-    color: #cc0000;
-}
+#content h1, #content h2 { color: #cc0000; }
 
-.navfooter {
-    bottom: 2%;
-}
+.navfooter { bottom: 2%; }
+
+/*  Show Hide TOC tree */
 
 .pointLeft {
     background: url("../images/showHideTreeIcons.png") 0 0 no-repeat;
@@ -68,6 +55,7 @@ h2 {
     width: 15px;
     display: block;
     font-size: 0;
+    cursor: pointer;
 }
 
 .pointRight {
@@ -75,48 +63,37 @@ h2 {
     height: 28px;
     display: block;
     font-size: 0;
-}
+    cursor: pointer;
+} 
 
-/* Search results */
+/* Search results Styling */
 
 .searchExpression {
     color: #0050A0;
     background-color: #EBEFF8;
     font-size: 12pt;
-
 }
 
-ul.searchresult li a {
+.searchresult li a {
     text-decoration: none;
     color: #0050A0;
-
 }
 
-ul.searchresult li {
+.searchresult li {
     color: #0050A0;
 }
-
-.shortdesc {
-    color: #0053AC;
-    margin-bottom: 30px;
-    margin-left: 20px;
-}
-
 .shortdesclink {
     color: gray;
     font-size: 9pt;
 }
-
 .searchText {
     border: #BFCEE9 solid 1pt;
     width: 11em
 }
-
 .searchButton {
     background: #EBEFF8;
     color: #0050A0;
     border: #BFCEE9 solid 1pt;
     font-weight: bold;
     font-size: 10pt
-}
-
+}
\ No newline at end of file
diff --git a/xsl/webhelp/template/content/search/addition.js b/xsl/webhelp/template/content/search/addition.js
deleted file mode 100755 (executable)
index 62af017..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*----------------------------------------------------------------------------\r
- * NexWave javascript for NSI search\r
- *----------------------------------------------------------------------------\r
-  This file is part of the htmlsearch plugin for the DITA-OT\r
-  adapted for NSI documentation.\r
-  Copyright (c) 2007-2008 NexWave Solutions All Rights Reserved. \r
-   www.nexwave.biz Nadege Quaine\r
-*/\r
-var w = new Object();\r
-\r
-var mzBrowser;\r
-var IEBrowser;\r
-\r
-if (navigator.appName.indexOf("Netscape") >= 0) {\r
-    mzBrowser = true;\r
-    IEBrowser = false;\r
-\r
-}else if (navigator.appName.indexOf("Internet Explorer") >=0) {\r
-    mzBrowser = false;\r
-    IEBrowser = true;\r
-}else if (navigator.appName.indexOf("Opera") >=0) {\r
-       operaBrowser = true;\r
-}else{\r
-    alert(txt_browser_not_supported)\r
-}\r
-\r
diff --git a/xsl/webhelp/template/content/search/indexLoader.js b/xsl/webhelp/template/content/search/indexLoader.js
deleted file mode 100755 (executable)
index 4173202..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*----------------------------------------------------------------------------\r
- * NexWave javascript for NSI search\r
- *----------------------------------------------------------------------------\r
-  This file is part of the htmlsearch plugin for the DITA-OT\r
-  adapted for NSI documentation.\r
-  Copyright (c) 2007-2008 NexWave Solutions All Rights Reserved. \r
-   www.nexwave.biz Nadege Quaine\r
-*/\r
-if (true) {\r
-    var tab = new Array("htmlFileList","htmlFileInfoList","0","1","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");\r
-    \r
-    var headEl =  document.getElementsByTagName('head').item(0);\r
-    for (el in tab) {\r
-        script =  document.createElement('script');\r
-       \r
-        var scriptTag = document.getElementById('loadScript' + tab[el]);\r
-        if(scriptTag) headEl.removeChild(scriptTag);\r
-        \r
-        script.src = "search/" + tab[el]+ ".js";\r
-        script.id = 'loadScript'+tab[el];\r
-        script.type = 'text/javascript';\r
-        script.defer = true;\r
-        headEl.appendChild(script);\r
-    } \r
-}\r
-\r
-\r
index c87a685e9dea797f4d4ef46a2df1f75f21fd67b1..91d3b586909ab9a09ac29b6ca76d1396a238f260 100755 (executable)
@@ -19,7 +19,7 @@
     <xsl:param name="chunk.frameset.start.filename">index.html</xsl:param>
     <xsl:param name="output_file_name">readme</xsl:param>
     <xsl:param name="chunked.toc.all.open">1</xsl:param>
-    <xsl:param name="frameset.base.dir">doc</xsl:param>
+    <xsl:param name="webhelp.base.dir">doc</xsl:param>
     <xsl:param name="generate.web.xml">0</xsl:param>
     <xsl:param name="direction.align.start">left</xsl:param>
     <xsl:param name="direction.align.end">right</xsl:param>
@@ -31,7 +31,7 @@
     <xsl:param name="navig.showtitles">0</xsl:param>
 
     <xsl:param name="manifest.in.base.dir" select="0"/>
-    <xsl:param name="base.dir" select="concat($frameset.base.dir,'/content/')"/>
+    <xsl:param name="base.dir" select="concat($webhelp.base.dir,'/content/')"/>
     <xsl:param name="suppress.navigation">0</xsl:param>
     <xsl:param name="generate.index" select="1"/>
     <xsl:param name="inherit.keywords" select="'0'"/>
@@ -69,7 +69,7 @@
             //The id for tree cookie
             var treeCookieId = "<xsl:value-of select="$tree.cookie.id"/>";
             var language = "<xsl:value-of select="$indexer.language"/>";
-
+            var w = new Object();
             //Localization
             txt_filesfound = '<xsl:call-template name="gentext">
                 <xsl:with-param name="key" select="'txt_filesfound'"/>
         <link rel="stylesheet" type="text/css" href="../common/jquery/treeview/jquery.treeview.css"/>
 
         <script type="text/javascript" src="../common/jquery/jquery-1.4.2.min.js">
-            <xsl:comment></xsl:comment>
+            <xsl:comment> </xsl:comment>
         </script>
         <script type="text/javascript" src="../common/jquery/jquery-ui-1.8.2.custom.min.js">
-            <xsl:comment></xsl:comment>
+            <xsl:comment> </xsl:comment>
         </script>
         <script type="text/javascript" src="../common/jquery/jquery.cookie.js">
-            <xsl:comment></xsl:comment>
+            <xsl:comment> </xsl:comment>
         </script>
         <script type="text/javascript" src="../common/jquery/treeview/jquery.treeview.min.js">
-            <xsl:comment></xsl:comment>
+            <xsl:comment> </xsl:comment>
         </script>
         <!--Scripts/css stylesheets for Search-->
-        <script type="text/javascript" src="search/addition.js">
-            <xsl:comment></xsl:comment>
+        <script type="text/javascript" src="search/htmlFileList.js">
+            <xsl:comment> </xsl:comment>
         </script>
-
-        <script type="text/javascript" src="search/indexLoader.js">
-            <xsl:comment></xsl:comment>
+        <script type="text/javascript" src="search/htmlFileInfoList.js">
+            <xsl:comment> </xsl:comment>
         </script>
-
         <script type="text/javascript" src="search/nwSearchFnt.js">
+            <xsl:comment> </xsl:comment>
+        </script>
+        
+        <!--script type="text/javascript" src="search/addition.js">
             <xsl:comment></xsl:comment>
         </script>
+        <script type="text/javascript" src="search/indexLoader.js">
+            <xsl:comment></xsl:comment>
+        </script-->
+
 
         <!--
            NOTE: Stemmer javascript files should be in format <language>_stemmer.js.
         <script type="text/javascript" src="{concat('search/stemmers/',$indexer.language,'_stemmer.js')}">
             <xsl:comment>//make this scalable to other languages as well.</xsl:comment>
         </script>
+
+        <!--Index Files:
+            Index is broken in to three equal sized(number of index items) files. This is to help parallel downloading
+            of files to make it faster.-->
+        <script type="text/javascript" src="search/index-1.js">
+            <xsl:comment> </xsl:comment>
+        </script>
+        <script type="text/javascript" src="search/index-2.js">
+            <xsl:comment> </xsl:comment>
+        </script>
+        <script type="text/javascript" src="search/index-3.js">
+            <xsl:comment> </xsl:comment>
+        </script>
+        <!--End of index files -->
     </xsl:template>
 
     <xsl:template name="user.header.navigation">
     </xsl:template>
 
     <xsl:template name="user.header.content">
-        <div>
-            <a id="showHideButton" onclick="showHideToc();" class="pointLeft" title="Hide TOC tree">.</a>
-        </div>
+            <a id="showHideButton" onclick="showHideToc();"
+               class="pointLeft" title="Hide TOC tree" style="padding-top:3px; padding-bottom:3px;">.</a>
     </xsl:template>
 
     <xsl:template name="user.footer.navigation">
                     <xsl:attribute name="id">webhelp-currentid</xsl:attribute>
                 </xsl:if>
                 <span class="file">
-                    <a href="{substring-after($href,concat($frameset.base.dir,'/content/'))}">
+                    <a href="{substring-after($href,concat($webhelp.base.dir,'/content/'))}">
                         <xsl:value-of select="$title"/>
                     </a>
                 </span>
                 <!--       </xsl:if> -->
                 <xsl:choose>
                     <xsl:when test="$chunk.frameset.start.filename">
-                        <xsl:value-of select="concat($frameset.base.dir,'/',$chunk.frameset.start.filename)"/>
+                        <xsl:value-of select="concat($webhelp.base.dir,'/',$chunk.frameset.start.filename)"/>
                     </xsl:when>
                     <xsl:otherwise>
                         <xsl:value-of select="'index.html'"/>
     <xsl:template name="web.xml">
         <xsl:call-template name="write.chunk">
             <xsl:with-param name="filename">
-                <xsl:value-of select="concat($frameset.base.dir,'/web.xml')"/>
+                <xsl:value-of select="concat($webhelp.base.dir,'/web.xml')"/>
             </xsl:with-param>
             <xsl:with-param name="method" select="'xml'"/>
             <xsl:with-param name="encoding" select="'utf-8'"/>