Closed (fixed)
Project:
H5P - Create and Share Rich Content and Applications
Version:
7.x-1.16
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
26 Jul 2016 at 12:28 UTC
Updated:
28 Jul 2016 at 05:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
icc commentedCool!
Currently, you'll have to add it to the semantics.json in order for it to work. Hopefully, we can get a more flexible solution in the future.
For testing purposes, you could add it through the semantics_alter hook, so you won't have to update CoursePresentation and the database.
I'm looking forward to seeing it on H5P.org :-)
Comment #3
supriyarajgopal commentedComment #4
supriyarajgopal commentedHello icc,
Thank you so much for the prompt response!
As suggested, I included my custom content type library in using semantics_alter() hook by which I can now see an empty box-like thing to add in Course Presentation.
However, as soon as I click on it to add a 'Click to reveal' element (that's what my custom library is called :] ), I get the error "Unable to find constructor for: H5P.ClickToReveal 1.0" in h5p/library/js/h5p.js file. My custom clicktoreveal.js file does have a definition for constructor (Code can be found here).
Moving my library from sites/default/files/h5p/development folder to sites/default/files/h5p/libraries folder didn't make a difference.
And this happens only when I try to include it from Course Presentation; stand-alone implementation of my custom library works just fine. Am I missing adding something or should this be done in Course Presentation library?
I would also like to know how to add an icon for my custom content type in Course Presentation action bar.
Any help is greatly appreciated!
Regards,
Supriya Rajgopal
Comment #5
icc commentedAh yes, you'll need to add it to the preloadedDependencies in library.json of h5p-editor-course-presentation in order for it to work in the editor.
For a custom icon it will have to be inserted into the H5PCoursePresentation font and then updated in the styles/cp.css. You can also of course use font awesome.
Feel free to create a Pull Request on GitHub after you've made the changes needed to Course Presentation for your library to work.
Comment #6
supriyarajgopal commentedicc,
Thank you for this! I added
in library.json of H5PEditor.CoursePresentation-1.10. Still the same error even after clearing cache. :(
Please correct me if I am wrong: Creating a pull request on GitHub will ensure that I will not have to hack the Course Presentation library whenever an upgrade is released, correct?
Comment #7
icc commentedYes, you are correct :-)
Comment #8
supriyarajgopal commentedicc,
Even after adding
{
"machineName": "H5P.ClickToReveal",
"majorVersion": 1,
"minorVersion": 0
},
in library.json of H5PEditor.CoursePresentation-1.10, I get the same error even after clearing cache :( Again, moving my library from development folder to libraries has no effect.
Kindly advise.
Comment #9
icc commentedIs your H5PEditor.CoursePresentation-1.10 in the development folder?
Comment #10
supriyarajgopal commentedNo, H5PEditor.CoursePresentation-1.10 is in ites\default\files\h5p\libraries folder whereas H5P.ClickToReveal-1.0 is in sites\default\files\h5p\development folder.
Comment #11
icc commentedYou'll have to put both CoursePresentation in the development folder for the changes to take effect. For regular content types library.json is only read on upload. The development folder reads it for every request.
Comment #12
supriyarajgopal commentedicc,
While my site clears its cache...how about putting H5P.ClickToReveal library inside sites\default\files\h5p\libraries folder instead? Wouldn't that work. Mostly not but why?
Comment #13
icc commentedWhen you upload libraries all the JSON files are read into the database and the files placed in the library folder. I.e. changing any of the JSON files inside the libraries folder will have no effect. The development folder, on the other hand, is read on every page request and uses the files and not the database. Any library places in the development folder will override any libraries in the libraries folder. Using the development mode has a huge performance impact and must never be used on production sites.
Comment #14
supriyarajgopal commentedSuper!
After placing all 3 files viz. H5P.ClickToReveal, H5P.CoursePresentation-1.10 and H5PEditor.CoursePresentation-1.10 in sites\default\files\h5p\development folder, everything is working perfectly!
P.S. I had to comment two calls to 'self.resize()' in clicktoreveal.js file for the editor to load in Course Presentation.
Many thanks icc!
Regards,
Supriya Rajgopal
Comment #15
supriyarajgopal commented