3

What is the correct method to manage css file versioning using collective.xdv?

Now I use nginx to serve css directly. I tried to import them in the css_registry, but if I change a file the merged css doesn't update, I mean, its version number (eg. the 4931 in rescsstylesheets-cachekey4931.css) doesn't get incremented.

I use plone 4.04, any hints?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
martino
  • 71
  • 3

4 Answers4

3

that's not a version number. that's portal_css tool that merges and caches CSS files together for better performance.

While developing you have to enable CSS/JS debug in order to see changes in real time. Go to ZMI -> portal_css/javascript and check "debug mode" flag to be on.

If I'm not wrong, from plone 4.x you have this enabled by default if you are running your instance in debug mode (bin/instance fg or bin/client fg). If this doesn't occur, check into you zope.conf for "debug-mode = on".

simahawk
  • 2,421
  • 1
  • 16
  • 22
3

Clicking save in the portal_css ZMI management screen will redo the merging and change the version number in the resources.

Laurence Rowe
  • 2,909
  • 17
  • 20
  • 1
    Ok but if I don't add any css the version doesn't change. Anyway I don't want to use GUI – martino Apr 04 '11 at 15:11
  • 1
    CSS file version numbering is out of scope for XDV / Diazo. Either use the inbuilt Plone one or add your own version number to the css link. – Laurence Rowe Apr 08 '11 at 15:45
1

You can easily serve CSS files from Zope. If you use plone.app.caching, the static resources (CSS and JS) will be cached in browser forever.

Then you simply copy over CSS from Plone in your rules.xml like this:

<!-- use styles and JavaScript resources from Plone ResourceRegistries -->
<drop theme="/html/head/link" />
<drop theme="/html/head/style" />
<append theme="/html/head" content="/html/head/link | /html/head/style" />
zupo
  • 1,556
  • 1
  • 13
  • 17
  • 1
    Ok, but I don't want that browser cache css forever, is there a method to handle css versioning? I mean, if I change css I need to deploy a new stable version, incrementing that cachekey number, or changing CSS name anyway. – martino Apr 04 '11 at 10:24
  • 1
    I see. If you want a new cache-key (aka. 'version') you can also enable debug mode in portal_css and immediately re-disable it. That should generate a new cache-key. – zupo Apr 04 '11 at 18:59
1

You can do this:

from Products.CMFCore.utils import getToolByName
csstool = getToolByName(context, 'portal_css')
csstool.manage_saveStylesheets()

You can learn more from the Zope API using old-but-good Products.DocFinderTab:

http://svn.plone.org/svn/collective/Products.DocFinderTab/

Davi Lima
  • 800
  • 1
  • 6
  • 20