Skip to content
Browse files

updates for resource delivery

  • Loading branch information...
1 parent 20735c0 commit a2d90fea98a77885dfa84a32b5755fdfaa1fadac @khrome khrome committed Jan 26, 2013
Showing with 29 additions and 5 deletions.
  1. +2 −0 handler-css.js
  2. +20 −2 handler-less.js
  3. +2 −0 handler-scss.js
  4. +1 −1 package.json
  5. +4 −2 protolus-resource.js
View
2 handler-css.js
@@ -13,6 +13,8 @@ var CSSHandler = new Class({
return {
name : 'link',
attrs : {
+ rel:"stylesheet",
+ type:"text/css"
},
target : 'href'
};
View
22 handler-less.js
@@ -7,14 +7,32 @@ var LessHandler = new Class({
this.parent('less');
},
handle : function(options, callback){
- less.render(options.body, function (e, css) {
- callback(css);
+ var path = process.cwd()+options.location;
+ var parts = path.split('/');
+ parts.pop();
+ var dir = parts.join('/');
+ try{
+ var parser = new(less.Parser)({
+ paths: [dir], // Specify search paths for @import directives
+ filename: path // Specify a filename, for better error messages
});
+ parser.parse(options.body, function (e, tree) {
+ if(e) callback('/* ERROR : '+e+'*'+'/');
+ else{
+ var css = tree.toCSS({ compress: options.compact || false });
+ callback(css);
+ }
+ });
+ }catch(ex){
+ callback('/* ERROR : '+ex.message+'*'+'/');
+ }
},
tagProfile : function(){
return {
name : 'link',
attrs : {
+ rel:"stylesheet",
+ type:"text/css"
},
target : 'href'
};
View
2 handler-scss.js
@@ -17,6 +17,8 @@ var SCSSHandler = new Class({
return {
name : 'link',
attrs : {
+ rel:"stylesheet",
+ type:"text/css"
},
target : 'href'
};
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "protolus-resource",
"homepage": "https://github.com/Protolus/protolus-resource",
- "version": "0.0.5-alpha",
+ "version": "0.0.6-alpha",
"main": "protolus-resource.js",
"description": "a CommonJS based server-side resource delivery mechanism with client side shim",
"keywords": [
View
6 protolus-resource.js
@@ -390,17 +390,19 @@ Resource.handle = function(request, response, passthru){
array.forEachEmission(resourceList, function(resourceName, index, rtrn){
var resource = registry.require(resourceName);
resource.files(type, function(files, fileNames){
- array.forEach(files, function(file, index){
+ array.forEachEmission(files, function(file, index, back){
handler.handle({
body : file,
location : '/node_modules/'+resource.options.name+'/'+fileNames[index],
name : resource.options.name,
compact : options.compact
}, function(result){
results.push(result);
+ back();
});
+ }, function(){
+ rtrn();
});
- rtrn();
});
}, function(){
response.writeHead(200);

0 comments on commit a2d90fe

Please sign in to comment.
Something went wrong with that request. Please try again.