Commit 65d9808c authored by Ayush Tiwari's avatar Ayush Tiwari

Notebook Upload jsmd

/reviewed-on nexedi/erp5!770
parent 578c1a32
......@@ -19,7 +19,7 @@
<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="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>
<div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div>
</body>
......
......@@ -280,7 +280,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.46890.21036.35140</string> </value>
<value> <string>970.52955.27100.34065</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -298,7 +298,7 @@
</tuple>
<state>
<tuple>
<float>1539004524.37</float>
<float>1539094329.81</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, jIO */
/*global window, rJS, RSVP, jIO, DOMParser */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, jIO) {
(function (window, rJS, RSVP, jIO, DOMParser) {
"use strict";
rJS(window)
......@@ -35,11 +35,12 @@
]);
})
.push(function (result) {
var file_name_list, data, filename, queue;
var file_name_list, data, filename, queue, filetype;
if (result[0].file !== undefined) {
file_name_list = result[0].file.file_name.split('.');
if (file_name_list[file_name_list.length - 1] in window.JSON.parse(result[3])) {
filename = file_name_list[0];
filetype = file_name_list.pop();
if (filetype in window.JSON.parse(result[3])) {
filename = file_name_list.join('.');
data = jIO.util.dataURItoBlob(result[0].file.url);
queue = new RSVP.Queue()
.push(function () {
......@@ -49,6 +50,15 @@
return evt.target.result;
})
.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({
title: filename,
portal_type: result[1],
......@@ -154,4 +164,4 @@
});
});
});
}(window, rJS, RSVP, jIO));
\ No newline at end of file
}(window, rJS, RSVP, jIO, DOMParser));
\ No newline at end of file
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.53127.14817.13977</string> </value>
<value> <string>970.54532.18415.44100</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1539074713.77</float>
<float>1539165482.38</float>
<string>UTC</string>
</tuple>
</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