diff --git a/lib/mess/parser.js b/lib/mess/parser.js index 27ce2ba..bba9444 100644 --- a/lib/mess/parser.js +++ b/lib/mess/parser.js @@ -293,8 +293,9 @@ mess.Parser = function Parser(env) { } try { + env.compress = env.compress || false var css = evaluate.call(this, { frames: frames }) - .toCSS([], { compress: options.compress || false }); + .toCSS([], env); } catch (e) { lines = input.split('\n'); line = getLine(e.index); diff --git a/lib/mess/renderer.js b/lib/mess/renderer.js index 478f319..ca77e5a 100644 --- a/lib/mess/renderer.js +++ b/lib/mess/renderer.js @@ -26,7 +26,9 @@ var to = function(list) { mess.Renderer = function Renderer(env) { var env = { - data_dir: env.data_dir || '/tmp/' + data_dir: env.data_dir || '/tmp/', + local_data_dir: env.local_data_dir || '', + validation_data: env.validation_data || false }; return { env: env, @@ -63,7 +65,6 @@ mess.Renderer = function Renderer(env) { }, function(err, results) { var result_map = to(results); - console.log(result_map); m.Layer = _.map(_.filter(m.Layer, function(l) { return l.Datasource.file && @@ -120,6 +121,7 @@ mess.Renderer = function Renderer(env) { * @param {Function} callback */ style: function(m, callback) { + var that = this; Step( function() { var group = this.group(); @@ -137,9 +139,9 @@ mess.Renderer = function Renderer(env) { var options = {}, group = this.group(); for (var i = 0, l = results.length; i < l; i++) { - new(mess.Parser)({ + new(mess.Parser)(_.extend(_.extend({ filename: s - }).parse(results[i][1], function(err, tree) { + }, that.env), this.env)).parse(results[i][1], function(err, tree) { if (err) { mess.writeError(err, options); throw err; @@ -278,15 +280,19 @@ mess.Renderer = function Renderer(env) { }), layer_id = 'id-' + layer.id; layer.styles = []; - if (_.include(hash, layer_id)) { - layer.styles.push(layer_id); - } - - _.each(classes, function(klass) { - if (_.include(hash, klass)) { - layer.styles.push(klass); + _.each(hash, function(h) { + if (h && (h.search(layer_id) != -1)) { + layer.styles.push(h); } }); + + _.each(hash, function(h) { + _.each(classes, function(c) { + if (h && (h.search(c) != -1)) { + layer.styles.push(c); + } + }); + }); return layer; }; diff --git a/lib/mess/tree/reference.js b/lib/mess/tree/reference.js index beda088..c58ed50 100644 --- a/lib/mess/tree/reference.js +++ b/lib/mess/tree/reference.js @@ -198,6 +198,7 @@ tree.Reference = { "face_name": { "css": "shield-face-name", "type": "string", + "validate": "font", "required": true }, "size": { @@ -395,6 +396,7 @@ tree.Reference = { }, "face_name": { "css": "text-face-name", + "validate": "font", "type": "string", "required": true }, @@ -688,7 +690,18 @@ tree.Reference.requiredProperties = function(symbolizer_name, properties) { } }; -tree.Reference.validValue = function(selector, value) { +tree.Reference._validateValue = { + 'font': function(env, value) { + if (env.validation_data && env.validation_data.fonts) { + return env.validation_data.fonts.indexOf(value) != -1; + } else { + return true; + } + } +}; + + +tree.Reference.validValue = function(env, selector, value) { if (value[0]) { return tree.Reference.selector(selector).type == value[0].is; } else { @@ -703,8 +716,15 @@ tree.Reference.validValue = function(selector, value) { } return true; } else { - return tree.Reference.selector(selector).type == value.value[0].is; + if (tree.Reference.selector(selector).validate) { + return tree.Reference.selector(selector).type == value.value[0].is && + tree.Reference._validateValue[tree.Reference.selector(selector).validate] + (env, value.value[0].value); + } else { + return tree.Reference.selector(selector).type == value.value[0].is; + } } } } + })(require('mess/tree'));