diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-07 09:36:26 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-07 09:36:26 +0100 |
commit | 4628e98cfcbab9284a6900519b09e052820a75b8 (patch) | |
tree | a41274c3dfb88553a9fa46ec0120f1173be1b801 /lib | |
parent | 2daf90dae64aaf1143a133ba99505a8a9d39ff9f (diff) | |
parent | bb79aac78a4c94c963c1995c5306be2acac64263 (diff) | |
download | nextcloud-server-4628e98cfcbab9284a6900519b09e052820a75b8.tar.gz nextcloud-server-4628e98cfcbab9284a6900519b09e052820a75b8.zip |
Merge pull request #13063 from AdamWill/assets-relocate
allow css/js asset directory to be relocated ('assetdirectory')
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/template.php | 5 | ||||
-rw-r--r-- | lib/private/templatelayout.php | 9 | ||||
-rw-r--r-- | lib/repair/assetcache.php | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/private/template.php b/lib/private/template.php index 78ebb506385..d407eb8384c 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -233,13 +233,14 @@ class OC_Template extends \OC\Template\Base { */ public static function isAssetPipelineEnabled() { // asset management enabled? - $useAssetPipeline = \OC::$server->getConfig()->getSystemValue('asset-pipeline.enabled', false); + $config = \OC::$server->getConfig(); + $useAssetPipeline = $config->getSystemValue('asset-pipeline.enabled', false); if (!$useAssetPipeline) { return false; } // assets folder exists? - $assetDir = \OC::$SERVERROOT . '/assets'; + $assetDir = $config->getSystemValue('assetdirectory', \OC::$SERVERROOT) . '/assets'; if (!is_dir($assetDir)) { if (!mkdir($assetDir)) { \OCP\Util::writeLog('assets', diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index 44c997c321e..44a8cd3a803 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -155,10 +155,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]; @@ -176,14 +177,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]; @@ -204,7 +205,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); } diff --git a/lib/repair/assetcache.php b/lib/repair/assetcache.php index d7677a10d11..1bc2b91ad86 100644 --- a/lib/repair/assetcache.php +++ b/lib/repair/assetcache.php @@ -22,7 +22,7 @@ class AssetCache extends BasicEmitter implements \OC\RepairStep { $this->emit('\OC\Repair', 'info', array('Asset pipeline disabled -> nothing to do')); return; } - $assetDir = \OC::$SERVERROOT . '/assets'; + $assetDir = \OC::$server->getConfig()->getSystemValue('assetdirectory', \OC::$SERVERROOT) . '/assets'; \OC_Helper::rmdirr($assetDir, false); $this->emit('\OC\Repair', 'info', array('Asset cache cleared.')); } |