Skip to content

Instantly share code, notes, and snippets.

View imalberto's full-sized avatar

alberto chan imalberto

  • Yahoo!
  • San Francisco
View GitHub Profile
@imalberto
imalberto / test.md
Last active December 18, 2015 10:18
test.md
Left align Right align Center align
This This This
column column column
will will will
be be be
left right center
aligned aligned aligned
@imalberto
imalberto / test.md
Created June 18, 2013 16:49
testing markdown

This is a [test][].

@imalberto
imalberto / app.js
Last active December 18, 2015 15:59
lib/router.js
var express = require('express'),
mojito = require('mojito'),
app;
app = express();
app.use(mojito.middleware());
app.use(app.router);
@imalberto
imalberto / appjs-route-usecases.md
Last active December 19, 2015 13:40
Use cases for app.js router/dispatcher

supported use cases

====

// use case 1
path: '/admin',
call: 'admin.help'
ac.url.make('admin.help') => /admin
ac.url.find('/admin')
@imalberto
imalberto / routes2.md
Created July 10, 2013 18:21
specific use case for routing
app.get('/admin', mojito.dispatch('admin.help'));

app.get('/:id/help', mojito.dispatch('admin.help'));

ac.url.make('admin.help', {}); => /admin

ac.url.make('admin.help', { id: 'foo' }); => /foo/help
@imalberto
imalberto / server-router.md
Last active December 19, 2015 16:49
ac.url* summary to get feedback

objective

========

Mojito is currently rewriting how routes are configured. Routes data is currently shared between server and client runtime.

Mojito will provide a BC layer, if required, in order to minimise inadverse effects on applications.

some background

========

@imalberto
imalberto / mojito-router-annotated.md
Last active December 19, 2015 19:18
mojito-router-annotated

the why

====

Y.mojito.RouteMaker responsibilities are the following:

  • (1) normalize the internal representation of routes.json
  • (2) given a "path", look up the matching path
  • (3) given a "query", construct a URI

(2) and (3) will take into parametrized values into consideration.

@imalberto
imalberto / util.js
Last active December 19, 2015 21:58
util.common.js#copy
copy: function(oldObj) {
var newObj,
key,
len,
type,
copy = Y.mojito.util.copy;
if (!oldObj) {
return oldObj;
}
@imalberto
imalberto / config.js
Last active December 21, 2015 13:38
route config format
"routes": {
"homepage": {
"path": "/",
"method": "get",
"keys": [],
"regexp": {},
"annotations": {
"name": "homepage",
"dispatch": {
"call": "home.index",
@imalberto
imalberto / routes.json
Last active December 21, 2015 14:49
routes.json
{
foo: {
call: "foo.index",
path: "/foo",
verbs: [ "get" ]
},
bar: {
call: "foo.index",
path: "/bar",
verbs: [ "post" ]