Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
4628e98c
Commit
4628e98c
authored
Jan 07, 2015
by
Thomas Müller
Browse files
Merge pull request #13063 from AdamWill/assets-relocate
allow css/js asset directory to be relocated ('assetdirectory')
parents
2daf90da
bb79aac7
Changes
4
Hide whitespace changes
Inline
Side-by-side
config/config.sample.php
View file @
4628e98c
...
...
@@ -810,6 +810,16 @@ $CONFIG = array(
*/
'asset-pipeline.enabled'
=>
false
,
/**
* The parent of the directory where css and js assets will be stored if
* piplelining is enabled; this defaults to the ownCloud directory. The assets
* will be stored in a subdirectory of this directory named 'assets'. The
* server *must* be configured to serve that directory as $WEBROOT/assets.
* You will only likely need to change this if the main ownCloud directory
* is not writeable by the web server in your configuration.
*/
'assetdirectory'
=>
'/var/www/owncloud'
,
/**
* Where ``mount.json`` file should be stored, defaults to ``data/mount.json``
*/
...
...
lib/private/template.php
View file @
4628e98c
...
...
@@ -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'
,
...
...
lib/private/templatelayout.php
View file @
4628e98c
...
...
@@ -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
);
}
...
...
lib/repair/assetcache.php
View file @
4628e98c
...
...
@@ -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.'
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment