Commit ab35e1df authored by Ayush Tiwari's avatar Ayush Tiwari

[erp5_officejs] Add upload of jsmd based html file for Notebook App

parent 578c1a32
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Notebooks</script> <script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Notebooks</script>
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">notebook_module</script> <script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">notebook_module</script>
<script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration"></script> <script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration"></script>
<script data-renderjs-configuration="upload_dict" type="text/x-renderjs-configuration">{"txt": "txt"}</script> <script data-renderjs-configuration="upload_dict" type="text/x-renderjs-configuration">{"txt": "txt", "html": "html"}</script>
<script data-renderjs-configuration="dropbox_app_key" type="text/x-renderjs-configuration">82g9eir551nhovs</script> <script data-renderjs-configuration="dropbox_app_key" type="text/x-renderjs-configuration">82g9eir551nhovs</script>
<div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div> <div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div>
</body> </body>
......
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>970.46890.21036.35140</string> </value> <value> <string>970.52955.27100.34065</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1539004524.37</float> <float>1539094329.81</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, jIO */ /*global window, rJS, RSVP, jIO, DOMParser */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, jIO) { (function (window, rJS, RSVP, jIO, DOMParser) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -35,11 +35,12 @@ ...@@ -35,11 +35,12 @@
]); ]);
}) })
.push(function (result) { .push(function (result) {
var file_name_list, data, filename, queue; var file_name_list, data, filename, queue, filetype;
if (result[0].file !== undefined) { if (result[0].file !== undefined) {
file_name_list = result[0].file.file_name.split('.'); file_name_list = result[0].file.file_name.split('.');
if (file_name_list[file_name_list.length - 1] in window.JSON.parse(result[3])) { filetype = file_name_list.pop();
filename = file_name_list[0]; if (filetype in window.JSON.parse(result[3])) {
filename = file_name_list.join('.');
data = jIO.util.dataURItoBlob(result[0].file.url); data = jIO.util.dataURItoBlob(result[0].file.url);
queue = new RSVP.Queue() queue = new RSVP.Queue()
.push(function () { .push(function () {
...@@ -49,6 +50,15 @@ ...@@ -49,6 +50,15 @@
return evt.target.result; return evt.target.result;
}) })
.push(function (data_content) { .push(function (data_content) {
if (filetype === 'html') {
// In case the filetype is html, try looking for an elemnt
// with id `jsmd`, because iodide notebook saves the jsmd
// data in it.
var parser, htmlDoc;
parser = new DOMParser();
htmlDoc = parser.parseFromString(data_content, "text/html");
data_content = htmlDoc.getElementById('jsmd').textContent;
}
return gadget.jio_post({ return gadget.jio_post({
title: filename, title: filename,
portal_type: result[1], portal_type: result[1],
...@@ -154,4 +164,4 @@ ...@@ -154,4 +164,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP, jIO)); }(window, rJS, RSVP, jIO, DOMParser));
\ No newline at end of file \ No newline at end of file
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>970.53127.14817.13977</string> </value> <value> <string>970.54532.18415.44100</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1539074713.77</float> <float>1539165482.38</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment