Sharing .h5p exports

Forums: 

Hello again,

I am using Drupal on Ubuntu 18.04. When I create new content, it displays correctly and appears as a new .h5p archive in the exports folder.

I recently tried to share a sample .h5p archive with a colleague and he couldn't open it although he is able to create new ones using the same source code we share using GitHub. I tried uploading the .h5p archive myself using the same environment I am using to develop and it didn't work either. A very long list of files (including the LICENSE file but mostly node_modules) are preventing the upload (first screenshot).

Even when I moved the project out of the development folder and cloned a clean version from GitHub into it without any problematic files, it won't work without installing node_modules which consequently appear to be automatically included in the .h5p export.

If I extract the contents of the .h5p archive (shown in h5p_archive1.png), delete the LICENSE, README, and node_modules directory from our project folder (H5P-ISAAC-1.0, shown in h5p_archive2.png) and recompress it (to .zip and rename to .h5p), the H5P library dependencies still prevent the upload (last screenshot).

Have I missed some way of excluding these directories when creating new content?

Much appreciated,
Eric

serettig's picture

Can you tell us which content type you want to export? I've never seen the H5P.ISAAC library before, but it seems to be the culprit: It includes all the files in the node_modules directory, which include files with extensions which aren't allowed (in your screenshot the LICENSE files which don't have any extension at all). Whether a library includes prohobited extensions is only checked, when uploading a package manually. That's why both of you can clone the repository from GitHub and still create content with it. When you export the content, the illegal files will be included, though and the validator rejects the package when you try to upload it somewhere else.

The best way would be if you could use a "distribution" h5p package provided by the library author. It should only include the typically allowed file types (they can be configured by the site owners). Delete the repository you've cloned from GitHub and upload the package instead. Then you should have a clean installation of the library.

If you create a h5p package manually (extracting and zipping again), most zip utilities add entries for directories. The h5p package validator rejects those entries, as it only allows files of a certain extension. As directories have no extension, they are rejected. You must make sure that your zip tool dones't add directory entries! There was a thread on this in the forum a few month ago, maybe you can find it.

If you are the author of H5P.ISAAC, you can create a "distribution" h5p package, by cloning the repository into the Drupal library directory, deleting all disallowed files there and then exporting a sample package with the normal H5P mechanism. That way both validation errors you show, should be avoided.

Sebastian

Thanks Sebastian.

ISAAC is the name of our project. My colleague and I are sharing the progress by pushing the latest code to GitHub, but it's not ready to be released yet.

The goal is not to have to create h5p packages manually, but to share ones created by Drupal with each other. So if I create a particular content entry with a specific question, image, target answers, etc., I want to share it with my colleague so he can upload it to his Drupal development environment, to view and interact with it himself.

Is the "distribution" h5p package similar to the library archive Oliver mentioned in his comment? As I wrote to him, would it be enough to edit our library in one directory, but clone the latest version without the problematic files into the library folder? That's what I understand from your explanation.

Hope that makes sense. I'm still pretty new to front-end development and haven't otherwise used any of these tools.

Regards,
Eric

serettig's picture

Can you tell us which content type you want to export? I've never seen the H5P.ISAAC library before, but it seems to be the culprit: It includes all the files in the node_modules directory, which include files with extensions which aren't allowed (in your screenshot the LICENSE files which don't have any extension at all). Whether a library includes prohobited extensions is only checked, when uploading a package manually. That's why both of you can clone the repository from GitHub and still create content with it. When you export the content, the illegal files will be included, though and the validator rejects the package when you try to upload it somewhere else.

The best way would be if you could use a "distribution" h5p package provided by the library author. It should only include the typically allowed file types (they can be configured by the site owners). Delete the repository you've cloned from GitHub and upload the package instead. Then you should have a clean installation of the library.

If you create a h5p package manually (extracting and zipping again), most zip utilities add entries for directories. The h5p package validator rejects those entries, as it only allows files of a certain extension. As directories have no extension, they are rejected. You must make sure that your zip tool dones't add directory entries! There was a thread on this in the forum a few month ago, maybe you can find it.

If you are the author of H5P.ISAAC, you can create a "distribution" h5p package, by cloning the repository into the Drupal library directory, deleting all disallowed files there and then exporting a sample package with the normal H5P mechanism. That way both validation errors you show, should be avoided.

Sebastian

otacke's picture

Hi Eric!

If you're running your system in library development mode, H5P will pull files from the development folder instead from the library folder. It doesn't filter for files that are not allowed in the H5P specs (see documentation), so e.g. your node_modules folder will end up there. If you want to share your newly developed libraries with others, the easiest way is to use the h5p-cli tool to build a library archive that others can upload on the library screen (not the H5P Content Type Hub) of a different H5P system.

Best,

Oliver 

Thanks Oliver. The library won't be ready to be shared for quite a while as it is still in its early stages.

I'm not sure the CLI is what I want, unless I am misunderstanding its purpose (sharing and updating the H5P public repository).

I turned on the development folder because at some point its what the Drupal setup instructions told me to do. Should I turn this off, and only include a copy of the the latest and greatest version (without disallowed files) in the library folder? Or should I just include a copy of the latest version (without disallowed files) in the development folder I currently have, and work on a copy in another directory entirely?

Thanks again!
Eric

otacke's picture

Hi Eric!

The H5P CLI tool helps you with a couple of things you'll have to do when creating H5P files. One of them is packing libraries that can be shared (stripping files that shouldn't be in there, packing multiple libraries together, etc). There is a documentation page dedicated to the CLI tool ;-) https://h5p.org/h5p-cli-guide.

There's nothing wrong with having the development folder activated, but you should know what it does. See previous post.

If you're developing a new content type, it makes total sense to have it. Put all libraries that you need to change in there (including git files, node modules, linter configs, etc.), do your thing, and remove everything when you're done. Best way to not break your system and to not constantly having to flush your system's cache whenever you want to test a change. You just need to know, that if you have a library in the dev folder, H5P will use this one instead of the one from the library folder and put all its contents into the downloadable content file - that will the be invalid if you have node modules, etc.

Best,

Oliver 

Best,

Oliver 

Hi Oliver,

Thanks again. I see the use in the CLI now, but if I understand correctly: h5p pack can not package an instance of a content type, but rather an entire content type definition.

I am trying to share a sample instance I have created with our content type (photo attached), not the entire actual library. Just to be clear: my colleague also has our library up and running just fine. We are just trying to share an example question & answer.

I can either copy the .h5p from the exports folder, or download it directly by clicking "reuse" in the bottom left corner. As a sanity check, I just created a sample instance from an established library (Fill in the Blanks) and wasn't able to upload that, either (photo attached). Is this what you meant in your comment about not uploading to the H5P content hub? Is it not possible to share/upload these .h5p content packages?

Eventually we want to integrate with Moodle, but in the mean time it would be nice to share these specific instances with each other. Is that possible with the Drupal development environment?

Thanks so much for your patience.

Regards,
Eric

otacke's picture

Hi edemattos!

There is a distinction between content files (including assets, libraries and parameters) and library files (just libraries) although they both use the same .h5p suffix.

The former can be downloaded using the "Reuse" button or directly from the file system's H5P export path. Those can be uploaded in the H5P Content Type Hub instead of creating content from scratch - here library files won't work.

It's the other way round on the H5P libraries settings page. Here you can upload libraries, but not content files. And whatever you want to upload here, should have been created using the H5P CLI tool (or manually if you really prefer fiddling with folders and zip). 

You're second screenshot rather indicates a problem with your server, not with your files.

Cheers,
Oliver

Thank you both for your responses. I think I made some progress.

Further info: our library is based on the H5P.Question type boilerplate. I moved node_modules to just outside the main directory (the development folder) and deleted the LICENSE and README files. That seems to have helped as I am now only getting three errors, about missing machineName, majorVersion, and minorVersion... which is odd, since they are there in library.json (screenshots attached).

serettig's picture

This is odd. Maybe try ordering the attributes in a different way?

Try:

"title": "ISAAC",
"description": "...",
"machineName": "H5P.ISAAC",
"majorVersion": 1,
"minorVersion": 0,
"patchVersion": 0,
...

Unfortunately your tip didn't work. I've attached a sample .h5p package. Even with this one which seemingly adheres to the requirements, I am still getting those same three errors.

H5P file: