0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

Merge pull request #13047 from twbs/fix-customizer

Fix customizer (see #13043)
This commit is contained in:
Chris Rebert 2014-03-28 11:42:04 -07:00
commit d178a9581b
6 changed files with 34 additions and 16 deletions

View File

@ -158,7 +158,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
complete(content)
}
function generateCustomCSS(vars) {
function generateCustomLess(vars) {
var result = ''
for (var key in vars) {
@ -181,10 +181,20 @@ window.onload = function () { // wait for load in a dumb way because B-0
var IMPORT_REGEX = /^@import \"(.*?)\";$/
var lessLines = __less[lessFilename].split('\n')
for (var i = 0, imports = []; i < lessLines.length; i++) {
var match = IMPORT_REGEX.exec(lessLines[i])
if (match) imports.push(match[1])
}
var imports = []
$.each(lessLines, function (index, lessLine) {
var match = IMPORT_REGEX.exec(lessLine)
if (match) {
var importee = match[1]
var transitiveImports = includedLessFilenames(importee)
$.each(transitiveImports, function (index, transitiveImportee) {
if ($.inArray(transitiveImportee, imports) === -1) {
imports.push(transitiveImportee)
}
})
imports.push(importee)
}
})
return imports
}
@ -192,7 +202,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
function generateLESS(lessFilename, lessFileIncludes, vars) {
var lessSource = __less[lessFilename]
$.each(includedLessFilenames(lessFilename), function(index, filename) {
var lessFilenames = includedLessFilenames(lessFilename)
$.each(lessFilenames, function(index, filename) {
var fileInclude = lessFileIncludes[filename]
// Files not explicitly unchecked are compiled into the final stylesheet.
@ -203,7 +214,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
// Custom variables are added after Bootstrap variables so the custom
// ones take precedence.
if (('variables.less' === filename) && vars) lessSource += generateCustomCSS(vars)
if (('variables.less' === filename) && vars) lessSource += generateCustomLess(vars)
})
lessSource = lessSource.replace(/@import[^\n]*/gi, '') //strip any imports

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,16 +10,19 @@
'use strict';
var fs = require('fs');
var btoa = require('btoa');
var glob = require('glob');
function getFiles(type) {
var files = {};
fs.readdirSync(type)
var recursive = (type === 'less');
var globExpr = (recursive ? '/**/*' : '/*');
glob.sync(type + globExpr)
.filter(function (path) {
return type === 'fonts' ? true : new RegExp('\\.' + type + '$').test(path);
})
.forEach(function (path) {
var fullPath = type + '/' + path;
files[path] = (type === 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'));
.forEach(function (fullPath) {
var relativePath = fullPath.replace(/^[^/]+\//, '');
files[relativePath] = (type === 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'));
});
return 'var __' + type + ' = ' + JSON.stringify(files) + '\n';
}
@ -28,7 +31,10 @@ module.exports = function generateRawFilesJs(grunt, banner) {
if (!banner) {
banner = '';
}
var files = banner + getFiles('js') + getFiles('less') + getFiles('fonts');
var dirs = ['js', 'less', 'fonts'];
var files = banner + dirs.map(getFiles).reduce(function (combined, file) {
return combined + file;
}, '');
var rawFilesJs = 'docs/assets/js/raw-files.min.js';
try {
fs.writeFileSync(rawFilesJs, files);

View File

@ -32,6 +32,7 @@
"devDependencies": {
"btoa": "~1.1.1",
"canonical-json": "~0.0.4",
"glob": "^3.2.9",
"grunt": "~0.4.4",
"grunt-autoprefixer": "~0.7.2",
"grunt-banner": "~0.2.2",

File diff suppressed because one or more lines are too long