forked from weepy/kaffeine
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
160 changed files
with
22,139 additions
and
1,533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,7 @@ | ||
#!/usr/bin/env node | ||
var fs = require("fs") | ||
var path = "./lib/plugins" | ||
var files = fs.readdirSync(path) | ||
|
||
var filez = [] | ||
|
||
for(var i in files) { | ||
if(files[i].match(/\.js$/)) | ||
filez.push(files[i].replace(/\.js$/, "")) | ||
} | ||
|
||
var text = "Plugins = " + JSON.stringify(filez) | ||
|
||
fs.writeFile("./browser/plugins.js", text) | ||
|
||
|
||
// concat all files for client side: | ||
|
||
var js = "// Kaffeine for the browser. Include this file _after_ all your external Kaffeine scripts.\n// Internal Kaffeine scripts will be loaded on document load" | ||
|
||
js += fs.readFileSync("./browser/brequire.js") + "\n" | ||
js += fs.readFileSync("./browser/lib/token.js") + "\n" | ||
js += fs.readFileSync("./browser/lib/kaffeine.js") + "\n" | ||
|
||
|
||
for(var i in files) | ||
js += fs.readFileSync("./browser/lib/plugins/" + files[i]) + "\n" | ||
|
||
js += fs.readFileSync("./lib/browser.js") | ||
|
||
fs.writeFile("./browser/kaffeine-browser.js", js) | ||
require("brequire")("./lib") | ||
.module_base("kaffeine") | ||
.include_lib() | ||
// .inspect() | ||
.write("./browser/kaffeine-browser.js") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
var Kaffeine = require("./kaffeine"), | ||
fs = require('fs'), | ||
path = require('path'), | ||
optparse = require('optparse'), | ||
util = require("util"), | ||
sources = [], | ||
options = {}, | ||
oparser | ||
|
||
|
||
function loadPlugins(source) { | ||
fs.readdir(source, function(err, files) { | ||
for(var i =0; i< files.length;i++) { | ||
var file = files[i] | ||
if(!file.match(/\.js$/)) continue | ||
file = file.replace(/\.js$/, "") | ||
|
||
var path = "./plugins/" + file | ||
Kaffeine.plugins[file] = require(path) | ||
} | ||
}) | ||
} | ||
|
||
|
||
var SWITCHES = [ | ||
['-c', '--compile FILES', 'list of kaffeine files or folders to compile (comma seperated)'], | ||
['-o', '--output DIR', 'set the directory for compiled JavaScript'], | ||
['-w', '--watch', 'watch scripts for changes, and recompile'], | ||
['-v', '--version', 'display Kaffeine version'], | ||
['-h', '--help', 'display this help message'], | ||
['-g', '--growl', 'growl about error\'s in compilation. requires growl notify'], | ||
['-j', '--javascript-clientside', 'output clientside javascript version'] | ||
] | ||
|
||
function parseOptions() { | ||
oparser = new optparse.OptionParser(SWITCHES, "kaffeine compiles .k files to Kaffeine. run 'kaffeine help' for more info") | ||
//var o = options = | ||
|
||
// options.run = false // !(o.compile || o.print || o.lint) | ||
// options.print = false // !!(o.print || (o.eval || o.stdio && o.compile)) | ||
//console.log(process.argv) | ||
//sources = options.slice(2, options.length) | ||
|
||
oparser.on('compile', function(o, s) { | ||
sources = s.split(",") | ||
options.compile = true | ||
}); | ||
|
||
oparser.on('help', function(sources) { | ||
options.help = true | ||
}); | ||
|
||
oparser.on('watch', function(sources) { | ||
options.watch = true | ||
}); | ||
|
||
oparser.on('output', function(o, dir) { | ||
options.output = dir | ||
}) | ||
oparser.parse(process.argv) | ||
} | ||
|
||
exports.run = function() { | ||
parseOptions() | ||
loadPlugins(__dirname + "/plugins") | ||
|
||
if(options.help) return usage() | ||
if(options.version) return version() | ||
/*var separator = sources.indexOf('--') | ||
var flags = [] | ||
if(separator >= 0) { | ||
flags = sources.slice((separator + 1), sources.length) | ||
sources = sources.slice(0, separator-1) | ||
} | ||
process.ARGV = process.argv = flags*/ | ||
compileScripts() | ||
} | ||
|
||
function usage() { | ||
console.log(oparser.toString()) | ||
process.exit(0) | ||
} | ||
|
||
function version() { | ||
console.log("Kaffeine version " + Kaffeine.VERSION) | ||
process.exit(0) | ||
} | ||
|
||
|
||
function compileScripts() { | ||
|
||
for(var i =0; i < sources.length; i++) { | ||
var source = sources[i] | ||
var base = source | ||
var compile = function(source, topLevel) { | ||
|
||
path.exists(source, function (exists) { | ||
if(!exists) throw(new Error("File not found = " + source)) | ||
fs.stat( source, function(err, stats) { | ||
if(stats.isDirectory()) { | ||
fs.readdir(source, function(err, files) { | ||
for(var j=0; j<files.length;j++) { | ||
var file = files[j] | ||
compile(path.join(source, file)) | ||
} | ||
}) | ||
} | ||
else if(topLevel || path.extname(source) == '.k') { | ||
fs.readFile(source, function(err, code) { compileScript(source, code.toString(), base) }) | ||
if(options.watch) watch(source, base) | ||
} | ||
}) | ||
}) | ||
} | ||
compile(source, true) | ||
} | ||
} | ||
|
||
// Compile a single source script, containing the given code, according to the | ||
// requested options. If evaluating the script directly sets `__filename`, | ||
// `__dirname` and `module.filename` to be correct relative to the script's path. | ||
function compileScript(source, code, base) { | ||
var o = options | ||
try { | ||
var js = new Kaffeine().compile(code) | ||
if(o.print) print(js) | ||
else if(o.compile) writeJs(source, js, base) | ||
} | ||
catch(err) { | ||
if(!o.watch) { | ||
console.log(err.stack) | ||
process.exit(1) | ||
} | ||
console.log(err.message) | ||
} | ||
} | ||
|
||
// Write out a JavaScript source file with the compiled code. By default, files | ||
// are written out in `cwd` as `.js` files with the same name, but the output | ||
// directory can be customized with `--output`. | ||
function writeJs(source, js, base) { | ||
var filename = path.basename(source, path.extname(source)) + '.js' | ||
var srcDir = path.dirname(source) | ||
var baseDir = srcDir.substring(base.length) | ||
var dir = options.output ? path.join(options.output, baseDir) : srcDir | ||
var jsPath = path.join(dir, filename) | ||
var compile = function() { | ||
fs.writeFile(jsPath, js, function(err) { | ||
if(options.compile && options.watch) console.log("Compiled " + source) | ||
}) | ||
} | ||
path.exists(dir, function(exists) { | ||
exists ? compile() : exec("mkdir -p " + dir, compile) | ||
}) | ||
} | ||
|
||
function watch(source, base) { | ||
fs.watchFile(source, {persistent: true, interval: 500}, function(curr, prev) { | ||
if(curr.mtime.getTime() === prev.mtime.getTime()) return | ||
fs.readFile(source, function(err, code) { compileScript(source, code.toString(), base)}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* ClearSS | ||
* | ||
* Use this as a starter CSS file. It will save time and headaches if you provide sensible defaults for your styles. | ||
* | ||
* Author: Andrei Eftimie | ||
* Contact: andrei@eftimie.com | ||
* | ||
* Creative Commons License http://creativecommons.org/licenses/by/3.0/ | ||
* | ||
*/ | ||
|
||
/* | ||
* Reset | ||
* Loosely based on Eric Meyer's CSS Reset http://meyerweb.com/eric/tools/css/reset/ | ||
*/ | ||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin: 0; padding: 0; } | ||
fieldset, img { border: none; vertical-align: middle; } | ||
|
||
/* | ||
* Margins | ||
*/ | ||
p, ul, ol, dl, table, address, pre, fieldset { margin: 0 0 1.25em 0; } | ||
hr { margin: 1.25em 0 2.375em 0; height: .125em; } | ||
|
||
/* | ||
* Hyperlinks | ||
*/ | ||
a { text-decoration: underline; overflow: hidden; } | ||
a:hover, a:focus { text-decoration: none; } | ||
|
||
/* | ||
* General Document Settings | ||
*/ | ||
body { margin: 2.5em; font: 1em/1.25em sans-serif; } | ||
|
||
/* | ||
* Headings | ||
*/ | ||
h1, h2, h3, h4, h5, h6 { font-size: 1em; line-height: 1em; margin: 1em 0; } | ||
h1 { font-size: 2em; line-height: 1.25em; margin: 0 0 .625em 0; } | ||
h2 { font-size: 1.75em; line-height: 1.4285em; margin: .7142em 0; } | ||
h3 { font-size: 1.5em; margin: .833em 0; line-height: .833em; } | ||
h4 { font-size: 1.25em; } | ||
h5 { font-size: 1.125em; margin: 1.1111em 0; line-height: 1.1111em; } | ||
|
||
/* | ||
* Lists | ||
*/ | ||
ul { margin-left: 2.2em; } | ||
li ul, li ol { margin-top: 0; margin-bottom: 0; } | ||
ol { margin-left: 2.2em; } | ||
ol ul li { list-style: disc !important; } | ||
ol li { list-style-type: decimal; } | ||
ol li ol li { list-style-type: lower-alpha; } | ||
ol li ol li ol li { list-style-type: upper-roman; } | ||
|
||
/* | ||
* Definition List | ||
*/ | ||
dt { font-weight: bold; } | ||
dd { margin-bottom: 1.25em; } | ||
|
||
/* | ||
* Table | ||
*/ | ||
table { border-collapse: collapse; border: 1px solid #999; width: 100%; margin-bottom: 1.2em; } | ||
th, td { text-align: left; padding: 10px 8px 9px 8px; } | ||
th, td { border: 1px solid #999; } | ||
caption, th { font-weight: bold; } | ||
|
||
/* | ||
* Quotes | ||
*/ | ||
blockquote:before, blockquote:after, q:before, q:after { content: ""; } | ||
blockquote, q { quotes: "" ""; } | ||
|
||
/* | ||
* Code | ||
*/ | ||
pre { outline: 1px solid #999; font-size: 1em; margin-bottom: 20px; } | ||
code { font-size: 1em; line-height: 1.25em; } | ||
|
||
/* | ||
* Forms | ||
*/ | ||
input, select, textarea, button { font-size: 1em; font-family: inherit; padding: .3em; } | ||
textarea { padding: .425em .3em; } | ||
[type=submit] { padding: 0; margin: .55em 0; } | ||
fieldset { border: 1px solid #999; padding: 1.20em 2.5em; } | ||
|
||
form ol { margin: 0; } | ||
form li { list-style: none; margin-bottom: 1.25em; } | ||
form li label { display: block; } | ||
form li input { margin: .225em 0; } | ||
form .inline label { display: inline; } | ||
form .inline input { margin-right: 1em; } |
Oops, something went wrong.