mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-44357 theme: Allow core to compile LESS in PHP
This commit is contained in:
parent
9b8555fbea
commit
d433cf37cd
68 changed files with 10947 additions and 47 deletions
|
@ -39,6 +39,8 @@ $THEME->name = 'clean';
|
|||
$THEME->doctype = 'html5';
|
||||
$THEME->parents = array('bootstrapbase');
|
||||
$THEME->sheets = array('custom');
|
||||
$THEME->lessfile = 'moodle';
|
||||
$THEME->parents_exclude_sheets_when_lessfile = array('bootstrapbase' => array('moodle'));
|
||||
$THEME->supportscssoptimisation = false;
|
||||
$THEME->yuicssmodules = array();
|
||||
$THEME->enable_dock = true;
|
||||
|
|
4
theme/clean/less/moodle.less
Normal file
4
theme/clean/less/moodle.less
Normal file
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* Import all the rules from the parent.
|
||||
*/
|
||||
@import "../../bootstrapbase/less/moodle.less";
|
|
@ -148,6 +148,25 @@ if ($type === 'editor') {
|
|||
css_store_css($theme, "$candidatedir/editor.css", $csscontent, false);
|
||||
|
||||
} else {
|
||||
|
||||
$lock = null;
|
||||
|
||||
// Lock system to prevent concurrent requests to compile LESS, which is really slow and CPU intensive.
|
||||
// Each client should wait for one to finish the compilation before starting a new compiling process.
|
||||
// We only do this when the file will be cached...
|
||||
if ($type === 'less' && $cache) {
|
||||
$lockfactory = \core\lock\lock_config::get_lock_factory('core_theme_get_css_content');
|
||||
// We wait for the lock to be acquired, the timeout does not need to be strict here.
|
||||
$lock = $lockfactory->get_lock($themename, rand(15, 30));
|
||||
if (file_exists($candidatesheet)) {
|
||||
// The file was built while we waited for the lock, we release the lock and serve the file.
|
||||
if ($lock) {
|
||||
$lock->release();
|
||||
}
|
||||
css_send_cached_css($candidatesheet, $etag);
|
||||
}
|
||||
}
|
||||
|
||||
// Older IEs require smaller chunks.
|
||||
$csscontent = $theme->get_css_content();
|
||||
|
||||
|
@ -165,7 +184,13 @@ if ($type === 'editor') {
|
|||
$chunkurl = "{$relroot}/theme/styles.php?theme={$themename}&rev={$rev}&type=all&svg=0";
|
||||
}
|
||||
}
|
||||
|
||||
css_store_css($theme, "$candidatedir/all.css", $csscontent, true, $chunkurl);
|
||||
|
||||
// Release the lock.
|
||||
if ($lock) {
|
||||
$lock->release();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$cache) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue