-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Allow bundles to be rendered after "theme" and "custom" bundles. #4054
Conversation
@thet thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
# Allow bundles to have "theme" resp. "theme" and "custom" as dependency | ||
# so that bundles can be rendered after theme and custom resources. | ||
js_names += ["theme"] | ||
css_names += ["theme", "custom"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below in https://github.com/plone/Products.CMFPlone/pull/4054/files#diff-9e095767a08db89a248c84c46d31c75898eed2d7dc40b0757a835bb2af0ed95bR143 and https://github.com/plone/Products.CMFPlone/pull/4054/files#diff-9e095767a08db89a248c84c46d31c75898eed2d7dc40b0757a835bb2af0ed95bR165
If "theme" or "custom" does not exist (both added in line 192+) the bundle dependency cannot be resolved and the bundle is not included in the rendered output.
@jenkins-plone-org please run jobs |
This needs to be documented, but I'm not sure where. Perhaps in Theming of Classic UI? That section is so sad. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good enhancement. Anyway, this needs some documentation, since it is not obvious.
I think this should go into https://6.docs.plone.org/classic-ui/static-resources.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow I could not get this to work correctly. I checked out your branch and tested it with the plone-fullscreen
bundle:
- I added
custom
to depends, but the CSS was not added... also the.js
is missing (because custom is only defined for CSS but the bundle has JS also) - I added
theme
to depends and get the following traceback:
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 391, in publish_module
Module ZPublisher.WSGIPublisher, line 285, in publish
Module ZPublisher.mapply, line 98, in mapply
Module ZPublisher.WSGIPublisher, line 68, in call_object
Module zope.browserpage.simpleviewclass, line 44, in __call__
Module Products.Five.browser.pagetemplatefile, line 127, in __call__
Module Products.Five.browser.pagetemplatefile, line 59, in __call__
Module zope.pagetemplate.pagetemplate, line 134, in pt_render
Module Products.PageTemplates.engine, line 368, in __call__
Module z3c.pt.pagetemplate, line 198, in render
Module chameleon.zpt.template, line 328, in render
Module chameleon.template, line 229, in render
Module chameleon.utils, line 20, in raise_with_traceback
Module chameleon.template, line 200, in render
Module 1ac8f88237956af17a352f1fc406ccdd, line 1880, in render
Module 985090d925cc459bf0e69fde89f3e030, line 903, in render_master
Module 615bdf9739ecd0ffd4d4eee8b7a6ebd5, line 498, in render_master
Module zope.contentprovider.tales, line 76, in __call__
Module zope.viewlet.manager, line 157, in update
Module zope.viewlet.manager, line 163, in _updateViewlets
Module Products.CMFPlone.resources.browser.resource, line 260, in update
Module webresource._api, line 719, in render
Module webresource._api, line 678, in resolve
webresource._api.ResourceMissingDependencyError: webresource._api.ResourceMissingDependencyError: Resource defines missing dependency: <PloneScriptResource name="plone-fullscreen", depends="['theme']">
what am I missing here?
IMO custom should stay the last one. |
+1 I think that would be the expected behavior. If I change something TTW it should override everything else (without using |
I too agree |
0ffa287
to
758e21f
Compare
@jenkins-plone-org please run jobs |
…cluding default arguments.
758e21f
to
d2c378f
Compare
@jenkins-plone-org please run jobs |
Bundles can now depend on the automatically added "theme" and "custom" bundles from plone.app.theming and be rendered after those (e.g. after the plonetheme.barceloneta CSS). This allows to override a theme with custom CSS from a bundle instead of having to add the CSS customizations to the registry via the "custom_css" settings. As a consequence, theme customization can now be done in the filesystem in ordinary CSS files instead of being bound to a time consuming workflow which involces upgrading the registry after every change.
d2c378f
to
ce0815c
Compare
@jenkins-plone-org please run jobs |
Should I use the news item as the documentation for this new feature? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working on the documentation, I found a bug in the control panel that should be corrected either in this PR or a related one in the correct repository, if not this one.
- Visit https://classic.demo.plone.org/@@theming-controlpanel#autotoc-item-autotoc-2 (Site Setup > Theming > Advanced settings > Custom Styles)
- Click the link Theming documentation, which goes to a 404.
The correct link and label are Theming of Classic UI.
PR created to address the bug in the control panel UI at plone/plone.app.theming#248. While I'm in there, should I update any other control panel message? |
bundle.jscompilation = f"http://foo.bar/{name}.js" | ||
bundle.csscompilation = f"http://foo.bar/{name}.css" | ||
bundle.depends = depends | ||
return bundle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to move this code outside of the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it's used in two different classes.
Keep it as it is or better move it back in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in the other class it is defined as a method... https://github.com/plone/Products.CMFPlone/pull/4054/files#diff-8ef40cff64bf27605c753443d198309a61a480a09ec62d66fed8152c607cb600R264
IMO leave it like it was or make the test classes inherit from a common class.
# Fix "all" dependencies to be rendered after the last known non-all resource. | ||
for resource in depends_all_js: | ||
# Change all "all" to last known JS resource | ||
dependencies = map( | ||
lambda dep: dep if dep != "all" else last_js_bundle, resource.depends | ||
) | ||
# Remove None values, e.g. if no known JS resource was found | ||
dependencies = filter(lambda dep: dep is not None, dependencies) | ||
resource.depends = list(dependencies) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that use map
and filter
with two custom lambdas and then casting to a list can be replaced with a much more clear for cycle and probably performant for cycle.
Branch: refs/heads/master Date: 2024-12-03T19:42:58-08:00 Author: Steve Piercy (stevepiercy) <[email protected]> Commit: plone/plone.app.theming@1933dd8 Update link and label to Theming of Classic UI documentation See plone/Products.CMFPlone#4054 Files changed: M src/plone/app/theming/browser/controlpanel.pt Repository: plone.app.theming Branch: refs/heads/master Date: 2024-12-03T20:09:51-08:00 Author: Steve Piercy (stevepiercy) <[email protected]> Commit: plone/plone.app.theming@dc15462 Create 248.bugfix Files changed: A news/248.bugfix Repository: plone.app.theming Branch: refs/heads/master Date: 2024-12-04T06:32:57-08:00 Author: Steve Piercy (stevepiercy) <[email protected]> Commit: plone/plone.app.theming@907d61d Merge pull request #248 from plone/docs-classic-ui-theming Update link and label to Theming of Classic UI documentation Files changed: A news/248.bugfix M src/plone/app/theming/browser/controlpanel.pt
Branch: refs/heads/master Date: 2024-12-03T19:42:58-08:00 Author: Steve Piercy (stevepiercy) <[email protected]> Commit: plone/plone.app.theming@1933dd8 Update link and label to Theming of Classic UI documentation See plone/Products.CMFPlone#4054 Files changed: M src/plone/app/theming/browser/controlpanel.pt Repository: plone.app.theming Branch: refs/heads/master Date: 2024-12-03T20:09:51-08:00 Author: Steve Piercy (stevepiercy) <[email protected]> Commit: plone/plone.app.theming@dc15462 Create 248.bugfix Files changed: A news/248.bugfix Repository: plone.app.theming Branch: refs/heads/master Date: 2024-12-04T06:32:57-08:00 Author: Steve Piercy (stevepiercy) <[email protected]> Commit: plone/plone.app.theming@907d61d Merge pull request #248 from plone/docs-classic-ui-theming Update link and label to Theming of Classic UI documentation Files changed: A news/248.bugfix M src/plone/app/theming/browser/controlpanel.pt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependencies = map( | ||
lambda dep: dep if dep != "all" else last_css_bundle, resource.depends | ||
) | ||
# Remove None values, e.g. if no known JS resource was found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove None values, e.g. if no known JS resource was found
This is for CSS right?
The code in this cycle and in the one above looks the same.
If the treatment for the resources is equal maybe it is better to move it to a method?
Closed this in favor of #4076 |
JS and CSS resources can now be rendered after all other resources in their
resource group including the theme (e.g. the Barceloneta theme CSS).
There is a exception for custom CSS which can be defined in the theming
controlpanel. This one is always rendered as last style resource.
To render a resource after all other give it the "depends" value of "all". This
indicates that the resource depends on all other being rendered before. The
resource is then rendered as last resource of it's resource group.
This allows to override a theme with custom CSS from a bundle instead of having
to add the CSS customizations to the registry via the "custom_css" settings.
As a consequence, theme customization can now be done in the filesystem in
ordinary CSS files instead of being bound to a time consuming workflow which
involces upgrading the custom_css registry after every change.
Docs
plone/documentation#1802
plone/documentation#1803