Skip to content

Commit

Permalink
Merge pull request #8743 from rtibbles/h5ps_and_h5qs
Browse files Browse the repository at this point in the history
Add undocumented metadata key to H5P content data.
  • Loading branch information
rtibbles authored Nov 19, 2021
2 parents 8463da9 + 625ae0c commit 26d058f
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit 26d058f

Please sign in to comment.