Skip to content

Instantly share code, notes, and snippets.

View robi42's full-sized avatar

Robert Thurnher robi42

View GitHub Profile
var http = require('ringo/httpclient');
var {AsyncResponse} = require('ringo/webapp/async');
var app = exports.app = require('stick').Application()
.configure('error', 'notfound', 'route', 'params');
app.get('/proxy/*', function (req, path) {
var response = new AsyncResponse(req);
// Fetch MP3 from AWS S3.
var {html5} = require('hiccup/page'),
{Application} = require('stick'),
{Response} = require('stick/helpers');
var text = 'Hello World!',
markup = html5(['head', ['title', text]], ['body', ['h1', text]]),
app = exports.app = Application('error', 'notfound', 'route')
.get('/', function (req) Response.html(markup));
if (require.main === module) {
@robi42
robi42 / app.js
Created December 11, 2010 12:17
Run with, e.g.: `$ ringo -i app.js`
var {html5} = require('hiccup/page');
var {htmlResponse} = require('stick/helpers');
var text = 'Hello World!';
var markup = html5(['head', ['title', text]], ['body', ['h1', text]]);
var app = exports.app = require('stick').Application()
.configure('error', 'notfound', 'route')
.get('/', function (req) htmlResponse(markup));
diff --git a/actions.js b/actions.js
index cccc9f0..a87d4bb 100644
--- a/actions.js
+++ b/actions.js
@@ -28,7 +28,7 @@ exports.edit = function(req, name) {
exports.list = function(req) {
return Response.skin(module.resolve('./skins/list.html'), {
- pages: Page.all().sort(strings.Sorter('name'))});
+ pages: Page.query().orderBy('name').select()});
diff --git a/modules/ringo/webapp/websocket.js b/modules/ringo/webapp/websocket.js
index 17ecc55..c3105cd 100644
--- a/modules/ringo/webapp/websocket.js
+++ b/modules/ringo/webapp/websocket.js
@@ -59,6 +59,14 @@ exports.addWebSocket = function(context, path, onconnect) {
return outbound.isOpen();
},
/**
+ * Get the outbound WebSocket connection.
+ * @name WebSocket.instance.getOutbound
// an-app/config.js
// [...]
exports.urls = ["./actions"]; // Simply an array of module names now.
// an-app/actions.js
// [...]
diff --git a/modules/core/array.js b/modules/core/array.js
index 138131b..e35a1cd 100644
--- a/modules/core/array.js
+++ b/modules/core/array.js
@@ -135,7 +135,7 @@ Object.defineProperty(Array.prototype, "partition", {
falses.push(this[i]);
}
}
- return [trues, falses]
+ return [trues, falses];
#!/usr/bin/env ringo
// Lives in: `ringowiki/db/`
var fs = require('fs');
var path = fs.path('Page');
fs.list(path).forEach(function (file) {
var filePath = fs.join(path, file);
var Person = require('ringo/storage/hibernate').defineClass('Person', {
table: 'persons', cacheable: false, props: {
firstName: {type: 'string', nullable: false},
lastName: {type: 'string', nullable: false},
birthDate: {type: 'timestamp', nullable: false},
birthYear: {type: 'integer'},
vitae: {column: 'resume', type: 'text', unique: true}
}});
Index: src/org/ringojs/wrappers/Storable.java
===================================================================
--- src/org/ringojs/wrappers/Storable.java (revision 8afdca5b125784a121643a029b843cec33577e64)
+++ src/org/ringojs/wrappers/Storable.java Sun Apr 11 19:10:01 CEST 2010
@@ -85,7 +85,7 @@
}
@JSStaticFunction
- public static Scriptable defineClass(Scriptable store, String type, Object mapping)
+ public static Scriptable defineClass(Scriptable store, String type, Object mapping, Object settings)