Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thet
Copy link
Member

@thet thet commented Nov 8, 2024

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.

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.
@thet thet requested a review from petschki November 8, 2024 18:49
@mister-roboto
Copy link

@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:

@jenkins-plone-org please run jobs

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!

@thet thet requested review from jensens and ale-rt November 8, 2024 18:50
# 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"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thet
Copy link
Member Author

thet commented Nov 8, 2024

@jenkins-plone-org please run jobs

@stevepiercy
Copy link
Contributor

This needs to be documented, but I'm not sure where. Perhaps in Theming of Classic UI? That section is so sad.

Copy link
Member

@jensens jensens left a 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.

@jensens
Copy link
Member

jensens commented Nov 9, 2024

This needs to be documented, but I'm not sure where. Perhaps in Theming of Classic UI? That section is so sad.

I think this should go into https://6.docs.plone.org/classic-ui/static-resources.html

Copy link
Member

@petschki petschki left a 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:

  1. 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)
  2. 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?

@ale-rt
Copy link
Member

ale-rt commented Nov 11, 2024

IMO custom should stay the last one.

@petschki
Copy link
Member

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 !important all the time)

@jensens
Copy link
Member

jensens commented Nov 11, 2024

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 !important all the time)

I too agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants