From f238c4f975e49af71c945a7a58b6f4766288480a Mon Sep 17 00:00:00 2001
From: Vincent Bechu <vincent.bechu@nexedi.com>
Date: Thu, 11 May 2017 15:41:39 +0200
Subject: [PATCH] erp5_officejs: add bootloader in zip export

---
 .../gadget_officejs_bootloader.html.html      |  6 +++---
 .../gadget_officejs_bootloader.html.xml       |  4 ++--
 .../gadget_officejs_bootloader_js.js          |  1 +
 .../gadget_officejs_bootloader_js.xml         |  4 ++--
 ...officejs_bootloader_presentation_html.html |  4 ++--
 ..._officejs_bootloader_presentation_html.xml | 10 +++++++--
 ...et_officejs_bootloader_serviceworker_js.js |  2 +-
 ...t_officejs_bootloader_serviceworker_js.xml |  4 ++--
 .../gadget_officejs_jio_appcachestorage_js.js | 21 +++++++++++++++++--
 ...gadget_officejs_jio_appcachestorage_js.xml |  4 ++--
 .../gadget_officejs_page_export_js.js         |  5 ++++-
 .../gadget_officejs_page_export_js.xml        |  4 ++--
 .../jio_filesystemstorage_js.js               | 14 +++++++------
 .../jio_filesystemstorage_js.xml              |  4 ++--
 14 files changed, 58 insertions(+), 29 deletions(-)

diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.html
index 8e3ce62425..328bf83c83 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.html
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.html
@@ -8,9 +8,9 @@
 
     <title> OfficeJS Install </title>
 
-    <script src="rsvp.js"></script>
-    <script src="renderjs.js"></script>
-    <script src="jiodev.js"></script>
+    <script src="${latest_version}/rsvp.js"></script>
+    <script src="${latest_version}/renderjs.js"></script>
+    <script src="${latest_version}/jiodev.js"></script>
     <script src="jio_appcachestorage.js"></script>
 
     <script src="gadget_officejs_bootloader.js"></script>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.xml
index 98da94a76a..163ffbcd0c 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader.html.xml
@@ -241,7 +241,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>958.44234.50599.921</string> </value>
+                <value> <string>958.64448.11495.58999</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -259,7 +259,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1492159460.13</float>
+                        <float>1493373509.97</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.js
index 77ba6bac34..f1198d1193 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.js
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.js
@@ -141,6 +141,7 @@ var repair = false;
           if (!gadget.props.sub) {
             window.location.pathname += gadget.props.version_url;
           }
+          return;
         })
         .push(undefined, function (error) {
           if (error instanceof ProgressEvent) {
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.xml
index e872df04c5..22b9b31607 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_js.xml
@@ -236,7 +236,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>958.43127.34376.48742</string> </value>
+                <value> <string>958.61634.43604.13073</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -254,7 +254,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1492093057.34</float>
+                        <float>1493203361.07</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.html
index 626e2e1a10..23dab10703 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.html
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.html
@@ -8,8 +8,8 @@
     <link rel="stylesheet" href="gadget_officejs_bootloader_presentation.css">
 
     <!-- renderjs -->
-    <script src="rsvp.js" type="text/javascript"></script>
-    <script src="renderjs.js" type="text/javascript"></script>
+    <script src="development/rsvp.js" type="text/javascript"></script>
+    <script src="development/renderjs.js" type="text/javascript"></script>
 
     <!-- custom script -->
     <script src="gadget_officejs_bootloader_presentation.js" type="text/javascript"></script>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.xml
index bb9d12d6db..04dbb85efc 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_presentation_html.xml
@@ -101,6 +101,12 @@
               <none/>
             </value>
         </item>
+        <item>
+            <key> <string>text_content_substitution_mapping_method_id</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
         <item>
             <key> <string>title</string> </key>
             <value> <string>Officejs BootLoader Presentation Gadget</string> </value>
@@ -240,7 +246,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>956.64506.921.51985</string> </value>
+                <value> <string>958.64452.27945.28586</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -258,7 +264,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1485770530.16</float>
+                        <float>1493372430.42</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.js
index c8fb33260a..ee9d3a9b31 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.js
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.js
@@ -14,7 +14,7 @@ var global = self, window = self;
   self.DOMError = {};
   self.postMessage = function () {return; };
 
-  self.importScripts('rsvp.js', 'jiodev.js');
+  self.importScripts('development/rsvp.js', 'development/jiodev.js');
 
   self.storage = {};
 
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.xml
index 598fcd6869..0f270d54d6 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_bootloader_serviceworker_js.xml
@@ -227,7 +227,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>958.43172.7083.11724</string> </value>
+                <value> <string>958.61563.34886.11246</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -245,7 +245,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1492095766.17</float>
+                        <float>1493383031.83</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.js
index a973611302..de0ea51d63 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.js
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.js
@@ -5,12 +5,28 @@
 
   function AppCacheStorage(spec) {
     this._manifest = spec.manifest;
+    this._take_installer = spec.take_installer || false;
     this._origin_url = spec.origin_url !== undefined ? spec.origin_url :
       (window.location.origin + window.location.pathname +
       (window.location.pathname.endsWith('/') ? '' : '/') +
       ((spec.version !== undefined) ?
       (spec.version + (spec.version.endsWith('/') ? '' : '/')) : ""));
     this._relative_url_list = [this._origin_url, spec.manifest];
+    if (this._take_installer) {
+      this._relative_url_list = [
+        this._origin_url,
+        "development/" + spec.manifest,
+        this._origin_url + "development/",
+        "gadget_officejs_bootloader.js",
+        "gadget_officejs_bootloader.appcache",
+        "gadget_officejs_bootloader_presentation.html",
+        "gadget_officejs_bootloader_presentation.js",
+        "gadget_officejs_bootloader_presentation.css",
+        "gadget_officejs_bootloader_serviceworker.js",
+        "gadget_erp5_nojqm.css",
+        "jio_appcachestorage.js"
+      ];
+    }
   }
 
   AppCacheStorage.prototype.get = function (id) {
@@ -50,7 +66,8 @@
   };
 
   AppCacheStorage.prototype.repair = function () {
-    var storage = this;
+    var storage = this,
+      prefix = storage._take_installer ? "development/" : "";
     return new RSVP.Queue()
       .push(function () {
         return jIO.util.ajax({
@@ -78,7 +95,7 @@
               relative_url_list[i].charAt(0) !== '#' &&
               relative_url_list[i].charAt(0) !== ' ') {
             relative_url_list[i].replace("\r", "");
-            storage._relative_url_list.push(relative_url_list[i]);
+            storage._relative_url_list.push(prefix + relative_url_list[i]);
           }
           if (relative_url_list[i].indexOf("CACHE:") >= 0) {
             take = true;
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.xml
index 1d92a8c8bd..f633d7c6e6 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_appcachestorage_js.xml
@@ -239,7 +239,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>958.41792.31362.1314</string> </value>
+                <value> <string>958.64585.2539.29713</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -257,7 +257,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1492082677.03</float>
+                        <float>1493380404.6</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.js
index 0d414d5ec5..0b77255141 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.js
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.js
@@ -38,6 +38,8 @@
       var gadget = this,
         file_storage = jIO.createJIO({
         type: "replicate",
+        parallel_operation_attachment_amount: 400,
+        parallel_operation_amount: 400,
         check_remote_attachment_creation: true,
         check_local_creation: false,
         check_local_modification: false,
@@ -49,8 +51,9 @@
           document: site_url,
           sub_storage: {
             type: "appcache",
+            take_installer: true,
             manifest: cache_file,
-            url: site_url
+            origin_url: site_url
           }
         },
         signature_storage: {
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.xml
index 639052d1ed..7f529d5fdd 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_export_js.xml
@@ -227,7 +227,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>958.33101.25469.11605</string> </value>
+                <value> <string>958.64457.39610.60262</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -245,7 +245,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1491491776.79</float>
+                        <float>1493379956.25</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.js
index 9fe7ad7f91..cfd7efbcf1 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.js
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.js
@@ -6,7 +6,10 @@
   function FileSystemStorage(spec) {
     this._document = spec.document;
     this._sub_storage = jIO.createJIO(spec.sub_storage);
-    this._id_dict = {"/": {"index.html": {}}};
+    this._id_dict = {
+      "/": {"index.html": {}},
+      "/development/": {"index.html": {}}
+    };
   }
 
   FileSystemStorage.prototype.get = function (url) {
@@ -20,9 +23,9 @@
   FileSystemStorage.prototype.getAttachment = function (doc_id, attachment_id) {
     return this._sub_storage.getAttachment(
       this._document,
-      (attachment_id === "index.html") ?
-        "/" : (doc_id === "/") ?
-          attachment_id : doc_id + attachment_id
+      (attachment_id === "index.html") ? ((doc_id === "/") ?
+        "/" : "development/") : ((doc_id === "/") ?
+          attachment_id : doc_id + attachment_id)
     );
   };
 
@@ -66,9 +69,8 @@
             }
             if (!context._id_dict.hasOwnProperty(path)) {
               context._id_dict[path] = {};
-            } else {
-              context._id_dict[path][filename] = {};
             }
+            context._id_dict[path][filename] = {};
           }
         }
       });
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.xml
index eb11aff970..edc7758e89 100644
--- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.xml
+++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/jio_filesystemstorage_js.xml
@@ -239,7 +239,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>958.33063.40118.853</string> </value>
+                <value> <string>958.64589.19815.17083</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -257,7 +257,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1491489660.03</float>
+                        <float>1493382071.89</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
-- 
2.30.9