[Zope-CMF] CSS and .js files: where to put 'em?

Greg Ward gward@python.net
Thu, 13 Feb 2003 14:39:13 -0500


I'm working on a site where every page has to pull in a couple of .css
and .js files -- ie. I'll have something like this:

  <link rel="Stylesheet" type="text/css" href="/styles.css">

  <script language="JavaScript1.2" src="/javascripts/sample_data.js"></script>

in the standard <head> provided by my main_template.  I loathe editing
stuff through the web, so I'm doing as much as I can in a filesystem
Product specific to this site.

It seems to me that the CSS files really should go in the skin, ie. in
MyProduct/skins/MySite/*.css, which is visible to Zope via a Filesystem
Directory View (just like all the standard CMF skin layers).  However,
the FS directory view strips off the .css extension -- so I have to do
this:

  <link rel="Stylesheet" type="text/css" href="styles">

Yuck.  Is there a good way to keep the .css extension there?  I like
meaningful filenames.  (I found a bad way: name the file
"styles.css.css" in the filesystem.  Yuck, yuck, and double-yuck.)

Another source of yuckiness: this doesn't play nice with caches.
Documents in every folder of the site will reference "styles", so the
browser will be stuck downloading the same CSS file using many different
URLs, and will therefore be unable to cache it.  That doesn't bother me
nearly as much as the cache-unfriendliness of putting images in the
skin, but it's still not good.

Finally, does it even make sense to put JavaScript source files in the
skin?  The obvious benefit is that then they're in the filesystem, where
all source code belongs.  But presumably I'll have the same problems as
with .css files.  So should they be in a Zope folder instead (as they
currently are)?  Anyone have strong opinions one way or the other?

Thanks --

        Greg
-- 
Greg Ward <gward@python.net>                         http://www.gerg.ca/
Predestination was doomed from the start.