Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undocumented metadata key to H5P content data. #8743

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/hashi/src/H5P/H5PRunner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import get from 'lodash/get';
import isFunction from 'lodash/isFunction';
import pick from 'lodash/pick';
import set from 'lodash/set';
import debounce from 'lodash/debounce';
import unset from 'lodash/unset';
Expand Down Expand Up @@ -102,6 +103,21 @@ export function replacePaths(dep, packageFiles) {
});
}

const metadataKeys = [
'title',
'a11yTitle',
'authors',
'changes',
'source',
'license',
'licenseVersion',
'licenseExtras',
'authorComments',
'yearFrom',
'yearTo',
'defaultLanguage',
];

/*
* Class that manages loading, parsing, and running an H5P file.
* Loads the entire H5P file to the frontend, and then unzips, parses,
Expand Down Expand Up @@ -197,6 +213,7 @@ export default class H5PRunner {
this.setDependencies();
return this.processFiles().then(() => {
console.debug(`H5P file processed in ${performance.now() - start} ms`);
this.metadata = pick(this.rootConfig, metadataKeys);
// Do any URL substitition on CSS dependencies
// and turn them into Blob URLs.
// Also order the dendencies according to our sorted
Expand Down Expand Up @@ -412,6 +429,7 @@ export default class H5PRunner {
title: self.rootConfig.title,
styles: Object.keys(self.loadedCss),
scripts: Object.keys(self.loadedJs),
metadata: self.metadata,
},
};
},
Expand Down