diff options
author | Adam Williamson <awilliam@redhat.com> | 2014-12-30 12:03:07 -0800 |
---|---|---|
committer | Adam Williamson <awilliam@redhat.com> | 2015-01-05 15:24:23 -0800 |
commit | bb79aac78a4c94c963c1995c5306be2acac64263 (patch) | |
tree | 80e6ceda42dba2a0cb326879b61d81d9d7815e99 /lib/private/templatelayout.php | |
parent | c0ad6e818b118a22c5312e6ded97ebb0eeee5cda (diff) | |
download | nextcloud-server-bb79aac78a4c94c963c1995c5306be2acac64263.tar.gz nextcloud-server-bb79aac78a4c94c963c1995c5306be2acac64263.zip |
allow css/js asset directory to be relocated (#13053)
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 may 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.
Diffstat (limited to 'lib/private/templatelayout.php')
-rw-r--r-- | lib/private/templatelayout.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index fa025721e53..db2230e4202 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -154,10 +154,11 @@ class OC_TemplateLayout extends OC_Template { } public function generateAssets() { + $assetDir = \OC::$server->getConfig()->getSystemValue('assetdirectory', \OC::$SERVERROOT); $jsFiles = self::findJavascriptFiles(OC_Util::$scripts); $jsHash = self::hashFileNames($jsFiles); - if (!file_exists("assets/$jsHash.js")) { + if (!file_exists("$assetDir/assets/$jsHash.js")) { $jsFiles = array_map(function ($item) { $root = $item[0]; $file = $item[2]; @@ -172,14 +173,14 @@ class OC_TemplateLayout extends OC_Template { $jsCollection = new AssetCollection($jsFiles); $jsCollection->setTargetPath("assets/$jsHash.js"); - $writer = new AssetWriter(\OC::$SERVERROOT); + $writer = new AssetWriter($assetDir); $writer->writeAsset($jsCollection); } $cssFiles = self::findStylesheetFiles(OC_Util::$styles); $cssHash = self::hashFileNames($cssFiles); - if (!file_exists("assets/$cssHash.css")) { + if (!file_exists("$assetDir/assets/$cssHash.css")) { $cssFiles = array_map(function ($item) { $root = $item[0]; $file = $item[2]; @@ -200,7 +201,7 @@ class OC_TemplateLayout extends OC_Template { $cssCollection = new AssetCollection($cssFiles); $cssCollection->setTargetPath("assets/$cssHash.css"); - $writer = new AssetWriter(\OC::$SERVERROOT); + $writer = new AssetWriter($assetDir); $writer->writeAsset($cssCollection); } |