Merge branch 'MDL-40478-m' of git://github.com/andrewnicols/moodle

This commit is contained in:
Marina Glancy 2013-07-17 11:09:08 +10:00
commit 576151c987
2 changed files with 26 additions and 16 deletions

View File

@ -14,24 +14,29 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// A module name should be composed of:
// moodle-<component>-<module>[-skin]
var path = me.path,
parts = me.name.replace(/^moodle-/,'').split('-', 3),
modulename = parts.pop();
// moodle-<component>-<module>[-<submodule>][-skin]
var parts = me.name.replace(/^moodle-/,'').split('-'),
component = parts.shift(),
module = parts[0],
min = '-min';
if (/(skin|core)/.test(modulename)) {
if (/-(skin|core)$/.test(me.name)) {
// For these types, we need to remove the final word and set the type.
modulename = parts.pop();
parts.pop();
me.type = 'css';
// CSS is not minified - clear the min option.
min = '';
}
// Build the first part of the filename.
me.path = parts.join('-') + '/' + modulename + '/' + modulename;
if (module) {
// Determine the filename based on the remaining parts.
var filename = parts.join('-');
// CSS is not minified, but all other types are.
if (me.type !== 'css') {
me.path = me.path + '-min';
// Build the first part of the filename.
me.path = component + '/' + module + '/' + filename + min + '.' + me.type;
} else {
// This is a hangup from the old ways of writing Modules.
// We will start to warn about this once we have removed all core components of this form.
me.path = component + '/' + component + '.' + me.type;
}
// Add the file extension.
me.path = me.path + '.' + me.type;

View File

@ -101,17 +101,22 @@ foreach ($parts as $part) {
$frankenstylemodulename = join('-', array($version, $frankenstyle, $modulename));
$frankenstylefilename = preg_replace('/' . $modulename . '/', $frankenstylemodulename, $filename);
// Submodules are stored in a directory with the full submodule name.
// We need to remove the -debug.js, -min.js, and .js from the file name to calculate that directory name.
$frankenstyledirectoryname = str_replace(array('-min.js', '-debug.js', '.js'), '', $frankenstylefilename);
// By default, try and use the /yui/build directory.
$contentfile = $dir . '/yui/build/' . $frankenstyledirectoryname;
if ($mimetype == 'text/css') {
// CSS assets are in a slightly different place to the JS.
$contentfile = $dir . '/yui/build/' . $frankenstylemodulename . '/assets/skins/sam/' . $frankenstylefilename;
$contentfile = $contentfile . '/assets/skins/sam/' . $frankenstylefilename;
// Add the path to the bits to handle fallback for non-shifted assets.
$bits[] = 'assets';
$bits[] = 'skins';
$bits[] = 'sam';
} else {
$contentfile = $dir . '/yui/build/' . $frankenstylemodulename . '/' . $frankenstylefilename;
$contentfile = $contentfile . '/' . $frankenstylefilename;
}
// If the shifted versions don't exist, fall back to the non-shifted file.