mirror of
https://github.com/less/less.js.git
synced 2026-02-08 14:05:24 -05:00
started data-uri implementation, added basic console formatting support
This commit is contained in:
@@ -447,15 +447,15 @@ tree.functions = {
|
||||
|
||||
"data-uri": function(mimetypeNode, filePathNode) {
|
||||
|
||||
if (typeof window !== 'undefined' || less.mode == 'rhino') { // TODO rhino implementation
|
||||
if (typeof window !== 'undefined') {
|
||||
return new tree.URL(filePathNode || mimetypeNode, this.currentFileInfo).eval(this.env);
|
||||
}
|
||||
|
||||
var mimetype = mimetypeNode.value;
|
||||
var filePath = (filePathNode && filePathNode.value);
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
var fs = require('fs') || less._fs,
|
||||
path = require('path') || less._path,
|
||||
useBase64 = false;
|
||||
|
||||
if (arguments.length < 2) {
|
||||
@@ -478,6 +478,9 @@ tree.functions = {
|
||||
} catch (ex) {
|
||||
mime = tree._mime;
|
||||
}
|
||||
if (typeof mime === 'undefined') {
|
||||
mime = tree._mime;
|
||||
}
|
||||
|
||||
mimetype = mime.lookup(filePath);
|
||||
|
||||
@@ -605,7 +608,8 @@ tree._mime = {
|
||||
'.png' : 'image/png'
|
||||
},
|
||||
lookup: function (filepath) {
|
||||
var ext = require('path').extname(filepath),
|
||||
var path = require('path') || less._path;
|
||||
var ext = path.extname(filepath),
|
||||
type = tree._mime._types[ext];
|
||||
if (type === undefined) {
|
||||
throw new Error('Optional dependency "mime" is required for ' + ext);
|
||||
|
||||
@@ -86,14 +86,13 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
});
|
||||
}
|
||||
|
||||
less.Parser.fileLoader = function (originalHref, currentFileInfo, callback, env, newVars) {
|
||||
less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
|
||||
|
||||
if (currentFileInfo && currentFileInfo.currentDirectory && !/^\//.test(originalHref)) {
|
||||
originalHref = less._path.join(currentFileInfo.currentDirectory, originalHref);
|
||||
var href = file;
|
||||
if (currentFileInfo && currentFileInfo.currentDirectory && !/^\//.test(file)) {
|
||||
href = less._path.join(currentFileInfo.currentDirectory, file);
|
||||
}
|
||||
|
||||
var href = originalHref;
|
||||
|
||||
var path = less._path.dirname(href);
|
||||
|
||||
var newFileInfo = {
|
||||
@@ -113,6 +112,14 @@ less.Parser.fileLoader = function (originalHref, currentFileInfo, callback, env,
|
||||
newFileInfo.relativeUrls = env.relativeUrls;
|
||||
}
|
||||
|
||||
var j = file.lastIndexOf('/');
|
||||
if(newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
|
||||
var relativeSubDirectory = file.slice(0, j+1);
|
||||
newFileInfo.rootpath = newFileInfo.rootpath + relativeSubDirectory; // append (sub|sup) directory path of imported file
|
||||
}
|
||||
newFileInfo.currentDirectory = path;
|
||||
newFileInfo.filename = href;
|
||||
|
||||
try {
|
||||
var data = readFile(href);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user