Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiocontents-nbextension
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastian
jiocontents-nbextension
Commits
3231315b
Commit
3231315b
authored
Nov 17, 2017
by
Sebastian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update: Jio is now working, web worker not necessary anymore
parent
027d65d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
37 deletions
+104
-37
gadget_erp5_jio.js
gadget_erp5_jio.js
+1
-0
gadget_jiocontents.js
gadget_jiocontents.js
+42
-9
gadget_jupyter_page.html
gadget_jupyter_page.html
+2
-1
jiocontents.js
jiocontents.js
+59
-27
No files found.
gadget_erp5_jio.js
View file @
3231315b
...
...
@@ -11,6 +11,7 @@
return
storage
[
method_name
].
apply
(
storage
,
argument_list
)
.
push
(
undefined
,
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
401
))
{
console
.
log
(
"
Not Auth'ed!
"
);
login_page
=
error
.
target
.
getResponseHeader
(
'
WWW-Authenticate
'
);
// Only connect to https to login
if
(
regexp
.
test
(
login_page
))
{
...
...
gadget_jiocontents.js
View file @
3231315b
...
...
@@ -5,14 +5,23 @@
(
function
(
window
,
rJS
)
{
"
use strict
"
;
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
console
.
log
(
"
Jio Contents Gadget yes yes.
"
);
return
gadget
;
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
console
.
log
(
"
Rendering jio CONTENTS
"
);
this
.
jio_allDocs
({
function
toNotebookModel
(
obj
)
{
console
.
log
(
obj
);
return
{
"
name
"
:
obj
.
value
.
title
,
// TODO: THIS PATH TO NOTEBOOK FILE
"
path
"
:
"
foo/bar/notebook1.ipynb
"
,
//"path": "/localhost/Test-Notebook.ipynb",
"
type
"
:
"
notebook
"
,
"
format
"
:
"
json
"
,
"
writable
"
:
true
,
"
last_modified
"
:
"
2013-10-02T11:29:27.616675+00:00
"
,
"
created
"
:
"
2013-10-01T12:21:20.123456+00:00
"
,
"
content
"
:
null
};
}
function
handleEvent
(
e
)
{
this
.
jio_allDocs
({
query
:
'
portal_type: "Web JSON"
'
,
select_list
:
[
'
text_content
'
,
'
title
'
,
'
reference
'
],
//, 'modification_date'], NOT WORKING
// sort_on: [["modification_date", "descending"]], // NOT WORKING
...
...
@@ -21,11 +30,35 @@
.
push
(
function
(
result
)
{
console
.
log
(
"
Querying Web JSON List
"
);
console
.
log
(
result
.
data
.
rows
);
var
nbs
=
[];
for
(
var
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
++
)
{
nbs
.
push
(
toNotebookModel
(
result
.
data
.
rows
[
i
]));
}
var
root_dir
=
{
"
name
"
:
""
,
"
path
"
:
""
,
"
last_modified
"
:
"
2017-09-06T03:33:29.781159Z
"
,
"
created
"
:
"
2017-09-06T03:33:29.781159Z
"
,
"
content
"
:
nbs
,
};
console
.
log
(
root_dir
);
e
.
detail
.
resolve
(
root_dir
);
},
function
(
err
)
{
e
.
detail
.
reject
();
console
.
log
(
err
);
});
}
rJS
(
window
)
.
ready
(
function
(
gadget
)
{
console
.
log
(
"
Jio Contents Gadget yes yes.
"
);
document
.
jiocontentsReady
=
true
;
return
gadget
;
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
})
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
);
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
)
.
onEvent
(
"
custom_event
"
,
handleEvent
,
false
,
true
);
}(
window
,
rJS
));
gadget_jupyter_page.html
View file @
3231315b
...
...
@@ -24,7 +24,8 @@
<div
data-gadget-url=
"gadget_jiocontents.html"
data-gadget-scope=
"jiocontents_gadget"
data-gadget-sandbox=
"public"
></div>
data-gadget-sandbox=
"public"
class=
"jiocontents_gadget"
></div>
<div>
Hello renderJS + Jupyter
</div>
...
...
jiocontents.js
View file @
3231315b
...
...
@@ -10,25 +10,53 @@ define(function(require) {
var
baseUrl
=
"
nbextensions/jiocontents
"
;
var
gadget_div
=
document
.
createElement
(
"
div
"
);
gadget_div
.
setAttribute
(
"
data-gadget-url
"
,
baseUrl
+
"
/gadget_jupyter_page.html
"
);
gadget_div
.
setAttribute
(
"
class
"
,
"
gadget-jupyter-page-container
"
);
document
.
body
.
append
(
gadget_div
);
var
gadget_main_div
=
document
.
createElement
(
"
div
"
);
gadget_main_div
.
setAttribute
(
"
data-gadget-url
"
,
baseUrl
+
"
/gadget_jupyter_page.html
"
);
gadget_main_div
.
setAttribute
(
"
class
"
,
"
gadget-jupyter-page-container
"
);
document
.
body
.
append
(
gadget_main_div
);
document
.
jiocontentsReady
=
false
;
var
s1
=
document
.
createElement
(
"
script
"
);
s1
.
type
=
"
text/javascript
"
;
s1
.
onload
=
function
()
{
console
.
log
(
"
loaded rsvp
"
);
var
s2
=
document
.
createElement
(
"
script
"
);
s2
.
type
=
"
text/javascript
"
;
s2
.
onload
=
function
()
{
console
.
log
(
"
loaded renderjs
"
);
rJS
.
manualBootstrap
();
}
s2
.
src
=
baseUrl
+
"
/renderjs.js
"
;
document
.
head
.
append
(
s2
);
};
s1
.
onload
=
function
()
{
console
.
log
(
"
loaded rsvp
"
);
var
s2
=
document
.
createElement
(
"
script
"
);
s2
.
type
=
"
text/javascript
"
;
s2
.
onload
=
function
()
{
console
.
log
(
"
loaded renderjs
"
);
rJS
.
manualBootstrap
();
};
s2
.
src
=
baseUrl
+
"
/renderjs.js
"
;
document
.
head
.
append
(
s2
);
};
s1
.
src
=
baseUrl
+
"
/rsvp.js
"
;
document
.
head
.
append
(
s1
);
/*
.then on this method to be sure the rjs-setup was completed and
.onEvent are available to receive events
*/
function
waitForReadyPromise
()
{
if
(
document
.
jiocontentsReady
)
{
return
Promise
.
resolve
();
// rjs-setup is already complete
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
timerId
=
window
.
setInterval
(
function
()
{
if
(
document
.
jiocontentsReady
)
{
window
.
setTimeout
(
function
()
{
resolve
();
},
200
);
// to allow for aquiredmethod to load
clearInterval
(
timerId
);
}
},
100
);
// Check every 100ms to see if rjs-setup is complete and eventlistener available
window
.
setTimeout
(
function
()
{
if
(
!
document
.
jiocontentsReady
)
{
reject
();
}
},
3000
)
// Reject after 3sec
});
}
function
getJiocontentsDiv
()
{
return
document
.
querySelector
(
"
.jiocontents_gadget
"
);
}
var
Contents
=
function
(
options
)
{
/**
...
...
@@ -116,15 +144,19 @@ define(function(require) {
* content: true or false; // whether to include the content
*/
Contents
.
prototype
.
get
=
function
(
path
,
options
)
{
console
.
log
(
"
GET:
"
+
path
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
jioworker
=
new
Worker
(
"
nbextensions/jiocontents/jioworker.js
"
);
jioworker
.
onmessage
=
function
(
e
)
{
resolve
(
e
.
data
);
};
jioworker
.
postMessage
([
"
get
"
,
path
]);
});
return
waitForReadyPromise
()
.
then
(
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
ev
=
new
CustomEvent
(
"
custom_event
"
,
{
detail
:
{
path
:
path
,
resolve
:
resolve
,
reject
:
reject
}
});
getJiocontentsDiv
().
dispatchEvent
(
ev
);
});
})
}
...
...
@@ -274,8 +306,8 @@ define(function(require) {
* @param {String} path The path to list notebooks in
*/
Contents
.
prototype
.
list_contents
=
function
(
path
)
{
return
this
.
get
(
path
,
{
type
:
'
directory
'
});
return
this
.
get
(
path
,
{
type
:
'
directory
'
});
};
return
{
'
Contents
'
:
Contents
};
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment