owncloud/core — pull request #13063 by AdamWill (2014-12-30 23:59:31+00:00)
Title: allow css/js asset directory to be relocated ('assetdirectory')

This allows the directory where CSS/JS asset collections are written to be changed, in case SERVERROOT is not writeable. Note it does *not* allow the expected URL to be changed: whatever directory is used, the server must be configured to serve it at WEBROOT/assets. It would be possible to add another config parameter to allow the admin to specify a custom asset URL, but I thought I'd keep the first implementation simple.

**CAUTION** this definitely needs testing in various scenarios. I thought it was easy right up until I ran into an icky issue at the end: the CSS files that use relative paths. [CssRewriteFilter](https://github.com/kriswallsmith/assetic/blob/master/src/Assetic/Filter/CssRewriteFilter.php) is the magic that deals with this, and it's...er...rather complicated :)

If I leave $sourceRoot and $sourcePath untouched then it seems like you get problems when the filesystem and URI relationships don't match. To give the concrete example, I have `SERVERROOT` as `/usr/share/owncloud` and `WEBROOT` as `/owncloud`; I'm moving `assetdir` to `/var/lib/owncloud/assets` . I configure Apache to serve `/var/lib/owncloud/assets` as `/owncloud/assets` and `/usr/share/owncloud` as `/owncloud` . With that config the rewritten CSS ends up looking for the relative path images in `http://server.com/core/img` for some reason, not `http://server.com/owncloud/core/img`. I'm not at all sure if that's a bug in Assetic or what, staring at all the stuff it does to the paths is making my brain go squiffy.

Changing $sourceRoot like this works for both my test cases...for some reason. I'm not claiming to understand precisely why. But it works with the asset dir relocated to `/var/lib/owncloud/assets`, and it works with it left at the default (so it shows up as `/usr/share/owncloud/assets`). It really would need to be tested in various other configs, though. I think I'll also raise an issue with Assetic asking if it's expected to be able to handle this situation.