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
Frontend asset loading #49
Frontend asset loading #49
Conversation
Woops, broke coverage. |
9c628bc
to
3572c04
Compare
Current coverage is
|
Woot, the asset-loader module has full code coverage! |
@@ -0,0 +1,20 @@ | |||
{ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Making the frontend asset naming consistent across JS and Python, some linting config. Changes look OK. |
Modify example plugin to use new Plugin object as Base. Ignore injected global __plugin_name in linting.
In order to extract the events data required for async loading.
…or the core app. Return async files from plugin registration.
Adds template tags for the base template sync and async frontend hooks. Adds async example to example plugin.
Pushing latest changes in case anyone wants to look at them. Tests have not been updated, so will break. Documentation needs to be written. |
6d0264b
to
fec6aab
Compare
fec6aab
to
0e74c67
Compare
Update build process accordingly. Update docs.
After some discussion with @indirectlylit and @MCGallaspy, and due to some issues with the approach taken to inspect the Javascript code and extract the Configuration of these hashes now happens from within |
Can you also update this section: https://github.com/rtibbles/kolibri/blob/frontend_asset_loading/docs/dev/frontend.rst#writing-frontend-plugins Also, who is responsible for merging this PR? |
Good catch. Changing. |
@aronasorman is assigned - I'll see if he is happy to sign it off. |
c97dbe5
to
30dd424
Compare
// The Backbone Model extend method is a standalone function that is used to extend many Backbone objects. | ||
// We use it here in preference to rolling our own to allow for extension of Plugins. | ||
|
||
Plugin.extend = Backbone.Model.extend; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
30dd424
to
c048e5d
Compare
@@ -38,6 +38,7 @@ class KolibriCoreFrontEnd(KolibriFrontEndPluginBase): | |||
""" | |||
entry_file = "assets/src/kolibri_core_app.js" | |||
external = True | |||
core = True |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
e2ca7f7
to
2f50a55
Compare
I'm a bit confused by the various webpack config files in the root directory:
Seems like perhaps both |
I will annotate the relevant files to make their roles more clear. Thanks for the feedback! |
7504170
to
c8af859
Compare
return frontend_sync(BASE_FRONTEND_SYNC) | ||
|
||
|
||
def frontend_async(hook): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…sions. Removes unnecessary jsdom dependency.
c8af859
to
2013a7a
Compare
Adds sourcemaps to karma tests for easier debugging.
if chunk['name'].endswith('.js'): | ||
tags.append('<script type="text/javascript" src="{static}/{url}"></script>'.format(static=static, url=url)) | ||
tags.append('<script type="text/javascript" src="{url}"></script>'.format(url=render_as_url(chunk))) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This PR is now a month old. It is also being used in active code development by @MCGallaspy and @DXCanas - I believe all interested parties have had the opportunity to review, and I have responded to all comments. @aronasorman has said to me that he does not have the time or familiarity to give the go ahead, as such, and due to the foregoing that there has been ample review, I will be merging this at EOD today if there are no strenuous objections raised prior to then. |
Yeah, I think further iteration on this can be addressed in subsequent PRs. |
Summary
This is a WIP to implement and provide an example hook for
base.html
of both synchronous and asynchronous frontend asset loading.TODO
Reviewer guidance
This PR also adds in JS Linting during the webpack build process, in order to compensate for the fact that the JSHint precommit hook doesn't work on Windows and had to be removed.
In addition, it simplifies the naming of frontend assets to provide a simpler naming convention, based solely on the name of their Python module in Kolibri, and the name of the Class in which they are defined in
kolibri_plugins.py
.Finally, it provides a Javascript asynchronous frontend asset loader that can load both CSS and Javascript, in order to allow plugins to be registered to the frontend asynchronously and loaded when needed.
Adds a function for creating template tags with a hook to allow arbitrary plugins to plugin synchronously and asynchronously into any template.
Creates tags for these for base.html to allow for extension of base.html frontend functionality and as an example.
Issues addressed
Fixes #41, and fixes #38
Documentation
Much inline documentation. Also updates frontend.rst.