From e3754ba4ccaf8b996ea9137735c42980677a67d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 01:00:16 +0000 Subject: [PATCH 01/70] Bump stylus-loader from 7.1.2 to 7.1.3 Bumps [stylus-loader](https://github.com/webpack-contrib/stylus-loader) from 7.1.2 to 7.1.3. - [Release notes](https://github.com/webpack-contrib/stylus-loader/releases) - [Changelog](https://github.com/webpack-contrib/stylus-loader/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/stylus-loader/compare/v7.1.2...v7.1.3) --- updated-dependencies: - dependency-name: stylus-loader dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d19c7173cc..d16912ec71 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "less-loader": "^11.0.0", "npm-run-all": "^4.1.3", "stylus": "^0.59.0", - "stylus-loader": "^7.1.2", + "stylus-loader": "^7.1.3", "workbox-webpack-plugin": "^6.5.4" }, "false": {}, diff --git a/yarn.lock b/yarn.lock index 1d65477512..3be7dc115a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12600,13 +12600,12 @@ stylelint@14.10.0: v8-compile-cache "^2.3.0" write-file-atomic "^4.0.1" -stylus-loader@^7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/stylus-loader/-/stylus-loader-7.1.2.tgz#bf9556757344469f857e2edd79d1b9f69e364f69" - integrity sha512-terrqvQV0ie1q2XKHnStfLOztCyKj6CYO7NqFIP2ijIsGGgCX4cbyn49DjaTwpkc91QBnMMSYkK7JAIL5gvmIg== +stylus-loader@^7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/stylus-loader/-/stylus-loader-7.1.3.tgz#1fdfa0d34e8c05a569bc0902e1ecdb857d764964" + integrity sha512-TY0SKwiY7D2kMd3UxaWKSf3xHF0FFN/FAfsSqfrhxRT/koXTwffq2cgEWDkLQz7VojMu7qEEHt5TlMjkPx9UDw== dependencies: fast-glob "^3.2.12" - klona "^2.0.6" normalize-path "^3.0.0" stylus@^0.59.0: From 7b4608cb4d7319bfe5602681ac25c409e178d3f5 Mon Sep 17 00:00:00 2001 From: Manav Aggarwal Date: Mon, 12 Jun 2023 22:42:15 +0530 Subject: [PATCH 02/70] - add jszip yarn package; - implement code to extract .h5p files metadata; --- .../frontend/shared/vuex/file/utils.js | 75 +++++++++++++++---- package.json | 1 + yarn.lock | 10 +++ 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/contentcuration/contentcuration/frontend/shared/vuex/file/utils.js b/contentcuration/contentcuration/frontend/shared/vuex/file/utils.js index 97970945e1..e650eedc0b 100644 --- a/contentcuration/contentcuration/frontend/shared/vuex/file/utils.js +++ b/contentcuration/contentcuration/frontend/shared/vuex/file/utils.js @@ -1,4 +1,5 @@ import SparkMD5 from 'spark-md5'; +import JSZip from 'jszip'; import { FormatPresetsList, FormatPresetsNames } from 'shared/leUtils/FormatPresets'; const BLOB_SLICE = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice; @@ -7,8 +8,10 @@ const MEDIA_PRESETS = [ FormatPresetsNames.AUDIO, FormatPresetsNames.HIGH_RES_VIDEO, FormatPresetsNames.LOW_RES_VIDEO, + FormatPresetsNames.H5P, ]; const VIDEO_PRESETS = [FormatPresetsNames.HIGH_RES_VIDEO, FormatPresetsNames.LOW_RES_VIDEO]; +const H5P_PRESETS = [FormatPresetsNames.H5P]; export function getHash(file) { return new Promise((resolve, reject) => { @@ -61,6 +64,42 @@ export function storageUrl(checksum, file_format) { return `/content/storage/${checksum[0]}/${checksum[1]}/${checksum}.${file_format}`; } +export async function getH5PMetadata(fileInput, metadata) { + // const file = fileInput.files[0]; + // console.log(typeof(files), file); + const zip = new JSZip(); + zip + .loadAsync(fileInput) + .then(function(zip) { + const h5pJson = zip.file('h5p.json'); + // console.log(h5pJson); + if (h5pJson) { + return h5pJson.async('text'); + } else { + throw new Error('h5p.json not found in the H5P file.'); + } + }) + .then(function(h5pContent) { + const data = JSON.parse(h5pContent); + if (Object.prototype.hasOwnProperty.call(data, 'title')) { + metadata.Title = data['title']; + } + if (Object.prototype.hasOwnProperty.call(data, 'language') && data['language'] !== 'und') { + metadata.language = data['language']; + } + if (Object.prototype.hasOwnProperty.call(data, 'authors')) { + metadata.author = data['authors']; + } + if (Object.prototype.hasOwnProperty.call(data, 'license')) { + metadata.license = data['license']; + } + }) + .catch(function(error) { + console.error('Error loading or extracting H5P file:', error); + }); + return metadata; +} + /** * @param {{name: String, preset: String}} file * @param {String|null} preset @@ -85,24 +124,32 @@ export function extractMetadata(file, preset = null) { return Promise.resolve(metadata); } + const isH5P = H5P_PRESETS.includes(metadata.preset); + // Extract additional media metadata const isVideo = VIDEO_PRESETS.includes(metadata.preset); return new Promise(resolve => { - const mediaElement = document.createElement(isVideo ? 'video' : 'audio'); - // Add a listener to read the metadata once it has loaded. - mediaElement.addEventListener('loadedmetadata', () => { - metadata.duration = Math.floor(mediaElement.duration); - // Override preset based off video resolution - if (isVideo) { - metadata.preset = - mediaElement.videoHeight >= 720 - ? FormatPresetsNames.HIGH_RES_VIDEO - : FormatPresetsNames.LOW_RES_VIDEO; - } + if (isH5P) { + getH5PMetadata(file, metadata); + console.log(metadata); resolve(metadata); - }); - // Set the src url on the media element - mediaElement.src = URL.createObjectURL(file); + } else { + const mediaElement = document.createElement(isVideo ? 'video' : 'audio'); + // Add a listener to read the metadata once it has loaded. + mediaElement.addEventListener('loadedmetadata', () => { + metadata.duration = Math.floor(mediaElement.duration); + // Override preset based off video resolution + if (isVideo) { + metadata.preset = + mediaElement.videoHeight >= 720 + ? FormatPresetsNames.HIGH_RES_VIDEO + : FormatPresetsNames.LOW_RES_VIDEO; + } + resolve(metadata); + }); + // Set the src url on the media element + mediaElement.src = URL.createObjectURL(file); + } }); } diff --git a/package.json b/package.json index d19c7173cc..cc935f11b9 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "intl": "1.2.5", "jquery": "^2.2.4", "jspdf": "https://github.com/parallax/jsPDF.git#b7a1d8239c596292ce86dafa77f05987bcfa2e6e", + "jszip": "^3.10.1", "kolibri-constants": "^0.1.41", "kolibri-design-system": "https://github.com/learningequality/kolibri-design-system#e9a2ff34716bb6412fe99f835ded5b17345bab94", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index 1d65477512..2d19dd5ae9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8967,6 +8967,16 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" +jszip@^3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2" + integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g== + dependencies: + lie "~3.3.0" + pako "~1.0.2" + readable-stream "~2.3.6" + setimmediate "^1.0.5" + jszip@^3.7.1: version "3.10.0" resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.0.tgz#faf3db2b4b8515425e34effcdbb086750a346061" From ccf5f9e1b6b2e195caaee0292d1c762de41c278b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jun 2023 01:36:59 +0000 Subject: [PATCH 03/70] Bump fonttools from 4.27.1 to 4.40.0 Bumps [fonttools](https://github.com/fonttools/fonttools) from 4.27.1 to 4.40.0. - [Release notes](https://github.com/fonttools/fonttools/releases) - [Changelog](https://github.com/fonttools/fonttools/blob/main/NEWS.rst) - [Commits](https://github.com/fonttools/fonttools/compare/4.27.1...4.40.0) --- updated-dependencies: - dependency-name: fonttools dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index e9c4bd9d4b..bbf36f418d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -90,7 +90,7 @@ flask-basicauth==0.2.0 # via locust flask-cors==3.0.10 # via locust -fonttools==4.27.1 +fonttools==4.40.0 # via -r requirements-dev.in gevent==21.12.0 # via From 4af8e7db0e07d88c5fc1d814dbe6153c59a4efe5 Mon Sep 17 00:00:00 2001 From: Samson Akol Date: Fri, 16 Jun 2023 22:44:09 +0300 Subject: [PATCH 04/70] Fixes error that appears in the console on drag nested resource to to its root --- .../channelEdit/views/CurrentTopicView.vue | 94 ++++++++++++++----- 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue index 24505beedd..d953290801 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue @@ -1,14 +1,33 @@ @@ -30,7 +56,11 @@ - +
-
+
{{ selectionText }}
@@ -120,7 +154,12 @@