diff --git a/app/builtin-pages/views/library-view.js b/app/builtin-pages/views/library-view.js index c423b6583a..109a46ea0f 100644 --- a/app/builtin-pages/views/library-view.js +++ b/app/builtin-pages/views/library-view.js @@ -80,7 +80,7 @@ async function setup () { window.OS_CAN_IMPORT_FOLDERS_AND_FILES = browserInfo.platform !== 'linux' // load data - let url = window.location.pathname.slice(1) + let url = await parseLibraryUrl() archive = new LibraryDatArchive(url) await archive.setup() @@ -296,38 +296,51 @@ async function loadReadme () { // = function render () { - yo.update( - document.querySelector('.library-wrapper'), yo` -
-
-
- - - - - + if (!archive) { + yo.update( + document.querySelector('.library-wrapper'), yo` +
+
+
+ ${renderView()} +
+
` + ) + } else { + yo.update( + document.querySelector('.library-wrapper'), yo` +
+
+
+ + + + + +
-

Drop to add files

+

Drop to add files

-

- Dropped files will be published directly to - ${shortenHash(archive.url)} -

-
+

+ Dropped files will be published directly to + ${shortenHash(archive.url)} +

+
-
- ${renderHeader()} +
+ ${renderHeader()} -
- ${renderView()} -
+
+ ${renderView()} +
- ${renderFooter()} + ${renderFooter()} +
-
- ` - ) + ` + ) + } } function renderHeader () { @@ -1989,7 +2002,8 @@ async function readViewStateFromUrl () { try { var node - var urlp = parseDatURL(window.location.pathname.slice(1)) + var datUrl = await parseLibraryUrl() + var urlp = parseDatURL(datUrl) var pathParts = urlp.pathname.split('/').filter(Boolean) // select the archive @@ -2044,6 +2058,25 @@ function getSafeDesc () { return _get(archive, 'info.description', '').trim() || yo`No description` } +async function parseLibraryUrl () { + var url + if (window.location.pathname.slice(1).startsWith('workspace:')) { + const wsName = window.location.pathname.slice('/workspace://'.length).split('/')[0] + + const wsInfo = await beaker.workspaces.get(0, wsName) + if (wsInfo) { + url = wsInfo.publishTargetUrl + window.location.pathname = url + window.location.pathname.slice(`/workspace://${wsInfo.name}`.length) + } else { + toplevelError = createToplevelError('Invalid workspace name') + render() + } + } else { + url = window.location.pathname.slice(1) + } + return url +} + function createToplevelError (err) { switch (err.name) { case 'TimeoutError':