Skip to content

Commit

Permalink
Integrated Hem codebase properly. Started working on defining and imp…
Browse files Browse the repository at this point in the history
…lementing Weber config.
  • Loading branch information
hiddentao committed Mar 2, 2012
1 parent 39b22c5 commit b721e72
Show file tree
Hide file tree
Showing 24 changed files with 1,495 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cakefile
Expand Up @@ -11,4 +11,4 @@ build = (callback) ->
callback?() if code is 0

task 'build', 'Build lib/ from src/', ->
build()
build()
24 changes: 24 additions & 0 deletions LICENSE
Expand Up @@ -11,6 +11,30 @@ the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Based on software by Alex Maccaw:

Copyright (c) 2011 Alex MacCaw (info@eribium.org)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down
51 changes: 51 additions & 0 deletions assets/stitch.eco
@@ -0,0 +1,51 @@
<% @identifier or= 'require' %>
(function(/*! Stitch !*/) {
if (!this.<%= @identifier %>) {
var modules = {}, cache = {}, require = function(name, root) {
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
module = cache[path] || cache[indexPath]
if (module) {
return module;
} else if (fn = modules[path] || modules[path = indexPath]) {
module = {id: path, exports: {}};
cache[path] = module.exports;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return cache[path] = module.exports;
} else {
throw 'module ' + name + ' not found';
}
}, expand = function(root, name) {
var results = [], parts, part;
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
}, dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.<%= @identifier %> = function(name) {
return require(name, '');
}
this.<%= @identifier %>.define = function(bundle) {
for (var key in bundle)
modules[key] = bundle[key];
};
this.<%= @identifier %>.modules = modules;
this.<%= @identifier %>.cache = cache;
}
return this.<%= @identifier %>.define;
}).call(this)({
<%- (JSON.stringify(module.id) + ": function(exports, require, module) {#{module.compile()}}" for module in @modules).join(', ') %>
});
80 changes: 80 additions & 0 deletions lib/compilers.js
@@ -0,0 +1,80 @@
(function() {
var compilers, cs, dirname, eco, fs, stylus;

fs = require('fs');

dirname = require('path').dirname;

compilers = {};

compilers.js = compilers.css = function(path) {
return fs.readFileSync(path, 'utf8');
};

require.extensions['.css'] = function(module, filename) {
var source;
source = JSON.stringify(compilers.css(filename));
return module._compile("module.exports = " + source, filename);
};

try {
cs = require('coffee-script');
compilers.coffee = function(path) {
return cs.compile(fs.readFileSync(path, 'utf8'), {
filename: path
});
};
} catch (err) {

}

eco = require('eco');

compilers.eco = function(path) {
var content;
content = eco.precompile(fs.readFileSync(path, 'utf8'));
return "module.exports = " + content;
};

compilers.jeco = function(path) {
var content;
content = eco.precompile(fs.readFileSync(path, 'utf8'));
return "module.exports = function(values){ \n var $ = jQuery, result = $();\n values = $.makeArray(values);\n \n for(var i=0; i < values.length; i++) {\n var value = values[i];\n var elem = $((" + content + ")(value));\n elem.data('item', value);\n $.merge(result, elem);\n }\n return result;\n};";
};

require.extensions['.jeco'] = require.extensions['.eco'];

compilers.tmpl = function(path) {
var content;
content = fs.readFileSync(path, 'utf8');
return ("var template = jQuery.template(" + (JSON.stringify(content)) + ");\n") + "module.exports = (function(data){ return jQuery.tmpl(template, data); });\n";
};

require.extensions['.tmpl'] = function(module, filename) {
return module._compile(compilers.tmpl(filename));
};

try {
stylus = require('stylus');
compilers.styl = function(path) {
var content, result;
content = fs.readFileSync(path, 'utf8');
result = '';
stylus(content).include(dirname(path)).render(function(err, css) {
if (err) throw err;
return result = css;
});
return result;
};
require.extensions['.styl'] = function(module, filename) {
var source;
source = JSON.stringify(compilers.styl(filename));
return module._compile("module.exports = " + source, filename);
};
} catch (err) {

}

module.exports = compilers;

}).call(this);
44 changes: 44 additions & 0 deletions lib/css.js
@@ -0,0 +1,44 @@
(function() {
var CSS, compilers, resolve;

resolve = require('path').resolve;

compilers = require('./compilers');

CSS = (function() {

function CSS(path) {
try {
this.path = require.resolve(resolve(path));
} catch (e) {

}
}

CSS.prototype.compile = function() {
if (!this.path) return;
delete require.cache[this.path];
return require(this.path);
};

CSS.prototype.createServer = function() {
var _this = this;
return function(env, callback) {
return callback(200, {
'Content-Type': 'text/css'
}, _this.compile());
};
};

return CSS;

})();

module.exports = {
CSS: CSS,
createPackage: function(path) {
return new CSS(path);
}
};

}).call(this);
117 changes: 117 additions & 0 deletions lib/dependency.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b721e72

Please sign in to comment.