This file contains hidden or 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
exports.form: (uri, formdef, success) -> | |
form: forms.create formdef | |
handler: (request, nextApp) -> | |
#h.dir 'REQ:', request | |
if request.method is 'GET' | |
x: h.when nextApp(request), (y) -> | |
h.dir 'REQ:', y.body | |
form.bind y.body | |
response: h.defer() | |
respond: (body) -> |
This file contains hidden or 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
MoreRestrictive: (model, methods) -> | |
Facet.Restrictive model, h.apply methods, { | |
query: (q, options) -> | |
#if typeof q is 'string' | |
# # handle $-parameters | |
# # TODO: consider security issues | |
# if options?.parameters | |
# q: q.replace /\$[1-9]/g, (param) -> | |
# options.parameters[param.substring(1) - 1] | |
q: RQ.parseQuery q |
This file contains hidden or 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
CALL: (uri, method, params, headers) -> | |
headers: or {} | |
promise: defer() | |
promise.addErrback (error) -> failure error | |
$.ajax { | |
url: uri | |
contentType: 'application/json' | |
beforeSend: (xhr) -> | |
xhr.setRequestHeader 'client-id', 'dummy' | |
for k, v of headers |
This file contains hidden or 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
/*! | |
* Connect - Mongo | |
* Copyright(c) 2010 Vladimir Dronnikov <[email protected]> | |
* MIT Licensed | |
*/ | |
/** | |
* Module dependencies. | |
*/ |
This file contains hidden or 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
app.coffee | |
----- | |
exports.getDataModel: (request) -> | |
# admins or when security is bypassed | |
if settings.security.bypass or settings.security.admins?[request?.remoteUser] | |
request.user: { | |
id: 'root' | |
acl: () -> adminModel | |
} | |
return adminModel |
This file contains hidden or 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
function form2obj(){ | |
var r = {}; | |
// for all enabled? inputs | |
$(':input[name]', $(this)).each(function(i, field){ | |
// get the field | |
var $field = $(field); | |
// sanitize field value | |
var value = $field.val(); | |
// we don't store empty values | |
if (!value) return; |
This file contains hidden or 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
// support dotted fields | |
// N.B. ?select(name.en) returns {name: {en: 'Russia'}} while should {en: 'Russia'} | |
// TODO: optimize! | |
// first assign deeper properties | |
for (var j = 0; j < fields.length; ++j) { | |
if (fields[j].indexOf('.') < 0) continue; | |
var r = results[i]; | |
var parts = fields[j].split('.'); | |
for (var k = 0; k < parts.length; ++k) { | |
r = r[parts[k]]; |
This file contains hidden or 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
/* | |
http://develobert.blogspot.com/2007/11/automated-lorem-ipsum-generator.html | |
*/ | |
LoremIpsum = { | |
fullstop: '.', /* Character(s) to add to the end of sentences */ | |
min_wps: 10, /* Minimum words per sentence */ | |
max_wps: 25, /* Maximum words per sentence */ | |
min_spp: 2, /* Minimum sentences per paragraph */ | |
max_spp: 8, /* Maximum sentences per paragraph */ |
This file contains hidden or 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
w = (func, cb, args) -> | |
errHandler = (err) -> | |
dir 'ERR', err | |
try | |
promise.when func.apply(this, args), cb, errHandler | |
catch err | |
errHandler err | |
w1 = (func, cb, args) -> | |
errHandler = (err) -> |
This file contains hidden or 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
#!/usr/bin/env node | |
require.paths.unshift(__dirname + '/lib/node', __dirname); | |
var sys = require('sys'); | |
var oldconsolelog = console.log; | |
console.log = function(){ | |
Array.prototype.forEach.call(arguments, function(arg){ | |
if (arg instanceof Object) |