Skip to content

Commit

Permalink
Semi-sanely resolve local paths to URLs according to jupyter-widgets/…
Browse files Browse the repository at this point in the history
  • Loading branch information
snickell committed Apr 21, 2020
1 parent 9afefb1 commit 8c5808f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions js/rej-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ __webpack_public_path__ = PageConfig.getOption('fullStaticUrl') + '/'

import App from './App'

const toLabURL = (localPath) => localPath ? `${PageConfig.getBaseUrl()}files/${localPath}` : null

export class RejWidget extends VueWidget {
computedProps(props) {
window.rej = this
return {
...props,
imageryURL: toLabURL(props.imageryPath),
referenceURL: toLabURL(props.referencePath),
imageryURL: this.getDownloadUrlFor(props.imageryPath),
referenceURL: this.getDownloadUrlFor(props.referencePath),
ptsCallback: ptsFile => {
debugger;
console.log("Sending it by message")
Expand Down
8 changes: 8 additions & 0 deletions js/utils/vue-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export class VueWidget extends DOMWidgetView {
this.el.appendChild(el)
this.vm.$mount(el)
}
async getDownloadUrlFor(fsPath) {
// Resolve widgets using rendermime, as per the following workaround:
// https://github.com/jupyter-widgets/ipywidgets/issues/2800#issuecomment-616844788
// TODO: follow this issue, submit a PR to implement this properly if we have time
const resolver = this.model.widget_manager.rendermime.resolver
const resolvedPath = await resolver.resolveUrl(fsPath)
return await resolver.getDownloadUrl(resolvedPath)
}
// TODO: implement
// this.vue.$destroy()
}

0 comments on commit 8c5808f

Please sign in to comment.