Skip to content

Commit

Permalink
Merge pull request #75 from djsegal/master
Browse files Browse the repository at this point in the history
Get WebIO working on Binder
  • Loading branch information
shashi authored Mar 29, 2018
2 parents bd90aa4 + 2cf426e commit a2e7a92
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
8 changes: 7 additions & 1 deletion assets/webio/dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,13 @@ module.exports = isArray || function (val) {
if (!webComponentsSupported) {
var script = document.createElement('script');
script.async = true;
script.src = '/pkg/WebIO/webio/dist/webcomponents-lite.min.js';

if ( document.getElementsByTagName("base").length === 0 ) {
script.src = '/pkg/WebIO/webio/dist/webcomponents-lite.min.js';
} else {
script.src = 'pkg/WebIO/webio/dist/webcomponents-lite.min.js';
}

document.head.appendChild(script);
document.addEventListener("WebComponentsReady", function () {
if (customElements.get("unsafe-script") === undefined) {
Expand Down
8 changes: 7 additions & 1 deletion assets/webio/unsafe_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
if (!webComponentsSupported) {
var script = document.createElement('script');
script.async = true;
script.src = '/pkg/WebIO/webio/dist/webcomponents-lite.min.js';

if ( document.getElementsByTagName("base").length === 0 ) {
script.src = '/pkg/WebIO/webio/dist/webcomponents-lite.min.js';
} else {
script.src = 'pkg/WebIO/webio/dist/webcomponents-lite.min.js';
}

document.head.appendChild(script);
document.addEventListener("WebComponentsReady", function () {
if (customElements.get("unsafe-script") === undefined) {
Expand Down
27 changes: 25 additions & 2 deletions src/providers/ijulia_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,38 @@ function WebIO.register_renderable(T::Type)
end

function main()
display(HTML("<script src='/pkg/WebIO/webio/dist/bundle.js'></script>"))
display(HTML("<script src='/pkg/WebIO/providers/ijulia_setup.js'></script>"))
display(HTML("""
<script class='js-collapse-script'>
var curMatch =
window.location.href
.match(/(.*)\\/notebooks\\/.*\\.ipynb/);
curMatch = curMatch ||
window.location.href
.match(/(.*)\\/apps\\/.*\\.ipynb/);
if ( curMatch ) {
\$('head').append('<base href="' + curMatch[1] + '/">');
}
</script>
"""))

display(HTML("<script class='js-collapse-script' src='pkg/WebIO/webio/dist/bundle.js'></script>"))
display(HTML("<script class='js-collapse-script' src='pkg/WebIO/providers/ijulia_setup.js'></script>"))

display(HTML("""
<script class='js-collapse-script'>
\$('.js-collapse-script').parent('.output_subarea').css('padding', '0');
</script>
"""))

comm = Comm(:webio_comm)
conn = IJuliaConnection(comm)
comm.on_msg = function (msg)
data = msg.content["data"]
WebIO.dispatch(conn, data)
end

nothing
end

Expand Down

0 comments on commit a2e7a92

Please sign in to comment.