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
// The following attempts to extend arrays *kind* of work with ES5 | |
// except you get Objects masquerading as Arrays. Seems like an | |
// oversight in ES5 Object.create() (15.2.3.5) to me. | |
// simple approach where you don't need a constructor: | |
arr1 = Object.create(Array.prototype, {x: {value: 1}}); | |
// use a proper constructor | |
function SubArray() {} | |
SubArray.prototype = new Array(); |
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
// load modules passed in first argument, call function argument when loaded. | |
// note that modules are loaded and defined, but not yet executed (the module function is not called) | |
load(["single", "multi", "package"], function(require) { | |
// modules listed above are available via synchronous require() here. | |
// note that any of the modules may itself invoke load(), causing invocation of | |
// this function to be further delayed if the modules haven't been loaded yet | |
load("baz", function(require) { |
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
// if running in a CommonJS environment use exports object, | |
// otherwise set up as hiccup.html() | |
if (typeof exports === "undefined" || !exports) { | |
var hiccup = {}; | |
} | |
(function(exports) { | |
var html = exports.html = function() { | |
var buffer = []; |
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
// this is just a JSGI application like it used to be | |
var app = exports.app = new Application(); | |
// delegate requests to other apps/modules exporting their own JSGI app | |
app.route({vhost: ["foo.com", "*.foo.com"]}, "foo/config"); | |
app.route("/admin/", "admin"); | |
app.route("/", "actions"); | |
// method-specific mapping of requests to controller/action functions | |
app.get("/", function() {}); |
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
// First argument (or array element for nested arrays) is tag name. | |
// Second can optionally be an object, in which case it is used to | |
// supply attributes. All others are added to the tag's body. | |
html("p", {"class": "foo"}, "hello world", "!") | |
'<p class="foo">hello world!</p>' | |
// Shortcuts for denoting id and class attributes | |
html("p#foo.bar.baz", "hello world!") | |
'<p id="foo" class="bar baz">hello world!</p>' |
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
var httpclient = require("ringo/httpclient"); | |
var {Headers} = require("ringo/webapp/util"); | |
var {startsWith} = require("ringo/utils/strings"); | |
var base = "http://localhost:8080"; | |
var sites = { | |
"frau.helma.at": "/frauhelma", | |
"pool.helma.at": "/pool", | |
"henso.com": "/henso", |
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
diff --git a/lib/ringo/storage/sql/mapping.js b/lib/ringo/storage/sql/mapping.js | |
index 21399db..3a3bccb 100644 | |
--- a/lib/ringo/storage/sql/mapping.js | |
+++ b/lib/ringo/storage/sql/mapping.js | |
@@ -73,6 +73,9 @@ var Mapping = function(type, definition) { | |
for (var propName in definition.properties) { | |
var propDefinition = definition.properties[propName]; | |
var propMapping = null; | |
+ if (typeof propDefinition === "string") { | |
+ propDefinition = {"type": propDefinition}; |
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
var http = require('http'); | |
var Buffer = require('buffer').Buffer; | |
http.createServer(function (req, res) { | |
var n = 1024, b; | |
for (var i = 1; i <= 30; i++) | |
b = new Buffer(n); | |
res.writeHead(200, {"Content-Type": "text/plain"}); | |
res.end(b); | |
}).listen(8000); |
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
var {AsyncResponse} = require("ringo/webapp/response"); | |
var {setTimeout} = require("ringo/scheduler"); | |
exports.app = function(req) { | |
var res = AsyncResponse(req, 30000, true); | |
setTimeout(function() { | |
res.start(200, {"Content-Type": "text/html; charset=utf-8"}); | |
res.write("Hallo Welt"); | |
}, 1000); | |
setTimeout(function() { |
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
/* | |
* A simple ringo websocket extension. Add the following code to your webapp's | |
* config.js file to enable it: | |
* | |
* exports.extensions = ["websocket-extension"]; | |
*/ | |
var websocket = require("ringo/webapp/websocket"); | |
exports.serverStarted = function(server) { |