From 352d07e5fd3de8353c447da8ceeb62fe7aabaf04 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 16 Jul 2021 22:03:30 -0700 Subject: [PATCH] Simplify file URL generation. Only reference zipcontent in special case. --- kolibri/core/assets/src/core-app/urls.js | 24 +++++--------- .../views/ContentRenderer/DownloadButton.vue | 3 +- kolibri/core/content/utils/paths.py | 33 +++++-------------- .../src/views/Html5AppRendererIndex.vue | 4 ++- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/kolibri/core/assets/src/core-app/urls.js b/kolibri/core/assets/src/core-app/urls.js index e5d9b35bd0a..cc72cae68b7 100644 --- a/kolibri/core/assets/src/core-app/urls.js +++ b/kolibri/core/assets/src/core-app/urls.js @@ -48,27 +48,21 @@ const urls = { } return generateUrl(this.__mediaUrl, { url }); }, - storageUrl(fileId, extension, embeddedFilePath = '') { + zipContentUrl(fileId, extension, embeddedFilePath = '') { const filename = `${fileId}.${extension}`; - if (['zip', 'h5p'].includes(extension)) { - if (!this.__zipContentUrl) { - throw new ReferenceError('Zipcontent Url is not defined'); - } - return generateUrl(this.__zipContentUrl, { - url: `${filename}/${embeddedFilePath}`, - origin: this.__zipContentOrigin, - port: this.__zipContentPort, - }); - } - if (!this.__contentUrl) { + if (!this.__zipContentUrl) { throw new ReferenceError('Zipcontent Url is not defined'); } - return generateUrl(this.__contentUrl, { url: `${filename[0]}/${filename[1]}/${filename}` }); + return generateUrl(this.__zipContentUrl, { + url: `${filename}/${embeddedFilePath}`, + origin: this.__zipContentOrigin, + port: this.__zipContentPort, + }); }, - downloadUrl(fileId, extension) { + storageUrl(fileId, extension) { const filename = `${fileId}.${extension}`; if (!this.__contentUrl) { - throw new ReferenceError('Content Url is not defined'); + throw new ReferenceError('Zipcontent Url is not defined'); } return generateUrl(this.__contentUrl, { url: `${filename[0]}/${filename[1]}/${filename}` }); }, diff --git a/kolibri/core/assets/src/views/ContentRenderer/DownloadButton.vue b/kolibri/core/assets/src/views/ContentRenderer/DownloadButton.vue index 68e3ad8c772..e04187f096f 100644 --- a/kolibri/core/assets/src/views/ContentRenderer/DownloadButton.vue +++ b/kolibri/core/assets/src/views/ContentRenderer/DownloadButton.vue @@ -11,7 +11,6 @@