yet another TOC change from Bilal still not good
authorHanoh Haim <[email protected]>
Tue, 17 May 2016 12:44:36 +0000 (15:44 +0300)
committerHanoh Haim <[email protected]>
Tue, 17 May 2016 12:44:36 +0000 (15:44 +0300)
trex_book.asciidoc
trex_index.asciidoc
trex_rpc_server_spec.asciidoc
trex_stateless.asciidoc
trex_toc.asciidoc
trex_vm_manual.asciidoc
ws_main.py

index 73b2edf..2bb46b1 100755 (executable)
@@ -10,7 +10,6 @@ TRex
 :toclevels: 4
 
 include::trex_ga.asciidoc[]
-include::trex_toc.asciidoc[]
 
 
 == Introduction
index fe00cbb..41464c9 100644 (file)
@@ -37,6 +37,8 @@ link:trex_manual.html[trex_manual.html] link:trex_book.pdf[trex_manual.pdf]
 link:trex_stateless.html[trex_stateless.html] link:trex_stateless.pdf[trex_stateless.pdf]
 | Tutorial TRex on VirtualBox    | 
 link:trex_vm_manual.html[trex_vm_manual.html] link:trex_vm_manual.pdf[trex_vm_manual.pdf]
+| Cisco DevNet SandBox   | 
+link:https://devnetsandbox.cisco.com/RM/Diagram/Index/2ec5952d-8bc5-4096-b327-c294acd9512d?diagramType=Topology[Sandbox] https://devnetsandbox.cisco.com/RM/Topology[DevNet Sandbox]
 |=================
 
 == Python Automation API 
index 774c591..ebdd5f9 100755 (executable)
@@ -10,8 +10,6 @@ The TRex RPC Server
 :toclevels: 7
 
 include::trex_ga.asciidoc[]
-include::trex_toc.asciidoc[]
-
 
 == Change log
 
index 472b5bf..b6104b7 100755 (executable)
@@ -11,6 +11,8 @@ TRex Stateless support
 :github_stl_examples_path: https://github.com/cisco-system-traffic-generator/trex-core/tree/master/scripts/automation/trex_control_plane/stl/examples
 :toclevels: 6
 
+include::trex_ga.asciidoc[]
+
 // PDF version - image width variable
 ifdef::backend-docbook[]
 :p_width: 450
@@ -29,8 +31,6 @@ ifdef::backend-xhtml11[]
 :p_width_lge: 900
 endif::backend-xhtml11[]
 
-include::trex_ga.asciidoc[]
-include::trex_toc.asciidoc[]
 
 
 == Audience 
index 984ebca..a41d707 100644 (file)
@@ -1,7 +1,7 @@
 
 ifdef::backend-xhtml11[]
 ++++
-
+<div id="toc-section">
         <div id="toctitle">
             <img class="trex_logo" src="images\trex_logo_toc.png"/>
             Table of Contents
@@ -17,6 +17,8 @@ ifdef::backend-xhtml11[]
           
           </div>
         </div>
+</div>
+
 
 
     <!-- load the theme CSS file -->
index ec4c39c..dddf57b 100755 (executable)
@@ -8,8 +8,6 @@ TRex Virtual Machine setup and basic usage
 
 
 include::trex_ga.asciidoc[]
-include::trex_toc.asciidoc[]
-
 
 
 == Introduction
index 87be842..2ac8980 100755 (executable)
@@ -257,6 +257,376 @@ def convert_to_pdf(task):
     return  os.system('a2x --no-xmllint -v -f pdf  -d  article %s -D %s ' %(task.inputs[0].abspath(),out_dir ) )
 
 
+TOC_HEAD = """
+
+<body class="book">
+<div id="toc-section">
+        <div id="toctitle">
+            <img class="trex_logo" src="images/trex_logo_toc.png"/>
+            Table of Contents
+        </div>
+
+        <div id="toggle">
+          <img src="images/icons/toggle.png" title="click to toggle table of contents"/>
+        </div>
+        
+        <div id="toc">
+          <div id="nav-tree">
+          
+          </div>
+        </div>
+</div>
+
+<div id="content-section">
+  <div id="content-section-inner">
+
+"""
+
+TOC_END = """
+
+  </div>
+  <!-- End Of Inner Content Section -->
+</div>
+<!-- End of Content Section -->
+
+</body>
+
+<!-- load the theme CSS file -->
+<link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" rel="stylesheet"/>
+
+<link href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" />
+
+<!-- include the jQuery library -->
+<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js">
+</script>
+
+<!-- include the jQuery UI library -->
+<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js">
+</script>
+
+<!-- include the minified jstree source -->
+<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js">
+</script>
+
+<style type="text/css">
+    #toc {
+      margin-bottom: 2.5em;
+    }
+    
+    #toctitle {
+      color: #527bbd;
+      font-size: 1.1em;
+      font-weight: bold;
+      margin-top: 1.0em;
+      margin-bottom: 0.1em;
+    }
+
+    @media screen {
+      body {
+        margin-left: 20em;
+      }
+    
+      #toc {
+        position: fixed;
+        top: 51px;
+        left: 0;
+        bottom: 0;
+        width: 18em;
+        padding-bottom: 1.5em;
+        margin: 0;
+        overflow-x: auto !important;
+        overflow-y: auto !important;
+        border-right: solid 2px #cfcfcf;
+        background-color: #FAFAFA;
+        white-space: nowrap;
+      }
+    
+      #toctitle {
+        font-size: 17px !important;
+        color: #4d4d4d !important;
+        margin-top: 0px;
+        height: 36px;
+        line-height: 36px;
+        background-color: #e4e2e2;
+        padding: 8px 0px 7px 45px;
+        white-space: nowrap;
+        left: 0px;
+        display: block;
+        position: fixed;
+        z-index: 100;
+        width: 245px;
+        top: 0px;
+        overflow: hidden;
+      }
+      
+      #toc .toclevel1 {
+        margin-top: 0.5em;
+      }
+    
+      #toc .toclevel2 {
+        margin-top: 0.25em;
+        display: list-item;
+        color: #aaaaaa;
+      }
+    
+    }
+
+
+  /* Custom for Nave Tree */
+  #nav-tree{
+    margin-left: 10px !important;
+  }
+  
+  #nav-tree ul > li {
+    color: #000 !important;
+  }
+  
+  .jstree-wholerow.jstree-wholerow-clicked {
+    background-image: url('images/icons/selected_tab_bg.png');
+    background-repeat: repeat-x;
+    color: #fff !important;
+    text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
+  }
+
+        /* For side bar */
+  .ui-resizable-e{
+    height: 100%;
+    width: 4px !important;
+    position: fixed !important;
+    top: 0px !important;
+    cursor: e-resize !important;
+    background: url('images/splitbar.png') repeat scroll right center transparent !important;
+  }
+
+  .jstree-default .jstree-themeicon{
+    display: none !important;
+  }
+
+
+  .jstree-anchor {
+    font-size: 12px !important;
+    color: #91A501 !important;
+  }
+
+
+  .jstree-clicked{
+    color: green !important;
+  }
+  
+
+  #toggle {
+    position: fixed;
+    top: 14px;
+    left: 10px;
+    z-index: 210;
+    width: 24px;
+  }
+
+  #toggle img {
+    opacity:0.3;
+  }
+
+  #toggle img:hover {
+    opacity:0.9;
+  }
+
+  .trex_logo{
+    top: 6px;
+    position: relative;
+  }
+
+   html{
+    overflow: hidden;
+  }
+
+  body{
+    margin-right: 0px !important;
+    margin-top: 0px !important;
+    margin-bottom: 0px !important;
+  }
+
+  #toc-section{
+    position: absolute;
+    z-index: 200;
+  }
+
+  #content-section{
+    overflow: auto;
+  }
+
+  #content-section-inner{
+    max-width: 50em;
+  }
+
+
+ </style>
+
+
+
+<script>
+
+      $(document).ready(function(){
+          var isOpen = true;
+
+        // Initialize NavTree
+        initializeNavTree();
+        // Drag TOC left and right
+        initResizable();
+        // Toggle TOC whe clicking on the menu icon
+        toggleTOC();
+        // Handle Mobile - close TOC
+        checkMobile();
+
+        function initializeNavTree() {
+
+          // TOC tree options
+          var toc_tree = $('#nav-tree');        
+
+          var toc_tree_options = {
+            'core' : {
+              "animation" :false,
+              "themes" : { "stripes" : false },
+              'data' : {
+                "url" : "./input_replace_me.json",  
+                "dataType" : "json" // needed only if you do not supply JSON headers
+              }
+            }
+            ,
+            "plugins" : [ "wholerow" ]
+          };
+
+          $('#nav-tree').jstree(toc_tree_options) ;
+
+          toc_tree.on("changed.jstree", function (e, data) {
+            window.location.href = data.instance.get_selected(true)[0].original.link;
+          });
+        }
+        
+        function initResizable() {
+          var toc = $("#toc");
+          var body = $("body");
+
+          // On resize
+          $("#toc").resizable({
+              resize: function(e, ui) {
+                  resized();
+              },
+              handles: 'e'
+          });
+          
+        // On zoom changed
+          $(window).resize(function() {
+            if(isOpen){
+                resized();
+            }
+          });
+
+
+         // Do it for the first time
+            var tocWidth = $(toc).outerWidth();
+            var windowHeight = $(window).height();
+            $(".ui-resizable-e").css({"right":$(window).width()-parseInt(tocWidth)+"px"});
+            $("#toctitle").css({"width":parseInt(tocWidth)-45+"px"});
+            $("#toc-section").css({"height":windowHeight + "px"});
+            $("#content-section").css({"height":windowHeight + "px"});
+       
+        }
+
+        function resized(){
+          var body = $("body");
+          var tocWidth = $(toc).outerWidth();
+          var windowHeight = $(window).height();
+
+          body.css({"marginLeft":parseInt(tocWidth)+20+"px"});
+          $(".ui-resizable-e").css({"right":$(window).width()-parseInt(tocWidth)+"px"});
+          $("#toctitle").css({"width":parseInt(tocWidth)-45+"px"});
+          $("#toc-section").css({"height":windowHeight + "px"});
+          $("#content-section").css({"height":windowHeight + "px"});
+          
+        }
+
+
+        function toggleTOC(){
+          $( "#toggle" ).click(function() {
+            if ( isOpen ) {
+              // Close it
+               closTOC();
+            } else {
+              // Open it
+              openTOC();
+            }
+            // Toggle status
+            isOpen = !isOpen;
+          });
+        }
+
+
+        // Close TOC by default if it is mobile
+        function checkMobile(){
+          if(isMobileDevice()){
+            closTOC();
+            $(".ui-resizable-e").hide();
+          }
+        }
+
+        // Check it it it is running on mobile device
+        function isMobileDevice() {
+            if(
+                navigator.userAgent.match(/Android/i) ||
+                navigator.userAgent.match(/BlackBerry/i) ||
+                navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
+                navigator.userAgent.match(/Opera Mini/i) ||
+                navigator.userAgent.match(/IEMobile/i) || 
+                navigator.userAgent.match(/iPhone|iPad|iPod/i)
+              )
+            {
+              return true;
+            }
+            else
+            {
+              return false;
+            }
+        }
+
+        // Close TOC
+        function closTOC(){
+            $("#toc").hide("slide", 500);
+            $("#toctitle").hide("slide", 500);
+            if(!isMobileDevice()){
+                $(".ui-resizable-e").hide("slide", 500);
+            }
+            // Show the show/hide button
+            $("#toggle").css("right", "-40px");
+            // Fil width
+            $("body").animate({"margin-left": "50px"}, 500);
+        }
+
+        // Open TOC
+        function openTOC(){
+            $("#toc").show("slide", 500);
+            $("#toctitle").show("slide", 500);
+            if(!isMobileDevice()){
+              $(".ui-resizable-e").show("slide", 500);
+            }
+            // Show the show/hide button
+            $("#toggle").css("right", "15px");
+            // Minimize page width
+            $("body").animate({"margin-left": $(toc).outerWidth()+20+"px"}, 500);
+        }
+
+      });
+
+</script>
+
+"""
+
+def do_replace (input_file,contents,look,str_replaced):
+    if contents.count(look)!=1 :
+        raise Exception('Cannot find {0} in file {1} '.format(look,input_file))
+
+    return  contents.replace(look, str_replaced)
+
+
 
 def toc_fixup_file (input_file,
                     out_file, 
@@ -265,9 +635,13 @@ def toc_fixup_file (input_file,
 
     file = open(input_file)
     contents = file.read()
-    replaced_contents = contents.replace('input_replace_me.json', json_file_name)
+
+    contents = do_replace(input_file,contents,'<body class="book">', TOC_HEAD);
+    contents = do_replace(input_file,contents,'</body>', TOC_END)
+    contents = do_replace(input_file,contents,'input_replace_me.json', json_file_name)
+
     file = open(out_file,'w')
-    file.write(replaced_contents)
+    file.write(contents)
     file.close();
 
 
@@ -280,7 +654,7 @@ def convert_to_html_toc_book(task):
     tmp = os.path.splitext(task.outputs[0].abspath())[0]+'.tmp' 
     json_out_file_short = os.path.splitext(task.outputs[0].name)[0]+'.json' 
 
-    cmd='{0} -a stylesheet={1} -a  icons=true -a docinfo -d book -a max-width=55em  -o {2} {3}'.format(
+    cmd='{0} -a stylesheet={1} -a  icons=true -a docinfo -d book  -o {2} {3}'.format(
             task.env['ASCIIDOC'],
             task.inputs[1].abspath(),
             tmp,
@@ -601,5 +975,10 @@ def publish_both(bld):
     publish_ext(bld)
 
          
-               
+def test(bld):
+    # copy all the files to our web server 
+    toc_fixup_file ('build/trex_stateless.tmp',
+                    'build/trex_stateless.html',
+                    'trex_stateless.json')
+