getting started with mulberry

48
A Mobile App Development Toolkit Rebecca Murphey & Dan Imal Boston Front End Developer Meetup January 2012 Tuesday, January 24, 12

Upload: rebecca-murphey

Post on 15-Jan-2015

1.642 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Getting Started with Mulberry

A Mobile App Development ToolkitRebecca Murphey & Dan Imal

Boston Front End Developer Meetup

January 2012

Tuesday, January 24, 12

Page 2: Getting Started with Mulberry

Rebecca MurpheyLead JavaScript Developer@rmurphey

Dan ImalSenior User Experience Developer@mrdanimal

Tuesday, January 24, 12

Page 3: Getting Started with Mulberry

Tuesday, January 24, 12

Page 4: Getting Started with Mulberry

linkage

mulberry.toura.com

bit.ly/toura-mulberry

bit.ly/toura-mulberry-demos

Tuesday, January 24, 12

Page 5: Getting Started with Mulberry

Tuesday, January 24, 12

Page 6: Getting Started with Mulberry

Tuesday, January 24, 12

Page 7: Getting Started with Mulberry

command line tools scaffold your app and generate skeleton "les for the pieces you’ll need

application code harness a powerful CSS and JavaScript framework to develop rich interfaces

app builder generates production-ready builds for Android, iOS (mobile web is on the way)

Tuesday, January 24, 12

Page 8: Getting Started with Mulberry

CallbackCordova

Tuesday, January 24, 12

Page 9: Getting Started with Mulberry

$ mulberry scaffold recipes

Tuesday, January 24, 12

Page 10: Getting Started with Mulberry

Tuesday, January 24, 12

Page 11: Getting Started with Mulberry

Tuesday, January 24, 12

Page 12: Getting Started with Mulberry

$ mulberry generate

Tuesday, January 24, 12

Page 13: Getting Started with Mulberry

dramatic pause.

Tuesday, January 24, 12

Page 14: Getting Started with Mulberry

Tuesday, January 24, 12

Page 15: Getting Started with Mulberry

create content with yaml, markdown & html

Tuesday, January 24, 12

Page 16: Getting Started with Mulberry

create functionality with javascript

Tuesday, January 24, 12

Page 17: Getting Started with Mulberry

create styles with css & sass

Tuesday, January 24, 12

Page 18: Getting Started with Mulberry

Tuesday, January 24, 12

Page 19: Getting Started with Mulberry

$ mulberry serve

Tuesday, January 24, 12

Page 20: Getting Started with Mulberry

ohai sane development tools.

Tuesday, January 24, 12

Page 21: Getting Started with Mulberry

$ mulberry test

Tuesday, January 24, 12

Page 22: Getting Started with Mulberry

Tuesday, January 24, 12

Page 23: Getting Started with Mulberry

Tuesday, January 24, 12

Page 24: Getting Started with Mulberry

$ mulberry deploy

Tuesday, January 24, 12

Page 25: Getting Started with Mulberry

it’s just javascript.

(ok, and some haml, yaml, & sass.)

Tuesday, January 24, 12

Page 26: Getting Started with Mulberry

todos: capabilities: - name: PageTodos screens: - name: index regions: - components: - custom.TodoForm - className: list scrollable: true components: - custom.TodoList - components: - custom.TodoTools

NB: You can define this with JavaScript, too, using toura.pageDef(‘todos’, { ... }).

Tuesday, January 24, 12

Page 27: Getting Started with Mulberry

mulberry.page('/todos', { name : 'Todos', pageDef : 'todos'}, true);

mulberry.page('/completed', { name : 'Completed', pageDef : 'completed'});

$YOURAPP/javascript/routes.js

#/todos #/completed

Tuesday, January 24, 12

Page 28: Getting Started with Mulberry

mulberry.component('TodoForm', { componentTemplate : dojo.cache('client.components', 'TodoForm/TodoForm.haml'),

init : function() { this.connect(this.domNode, 'submit', function(e) { e.preventDefault();

var description = dojo.trim(this.descriptionInput.value), item;

if (!description) { return; }

item = { description : description }; this.domNode.reset(); this.onAdd(item); }); },

onAdd : function(item) { }});

$YOURAPP/javascript/components/TodoForm.js

Tuesday, January 24, 12

Page 29: Getting Started with Mulberry

%form.component.todo-form %input{ placeholder : 'New todo', dojoAttachPoint : 'descriptionInput' } %button{ dojoAttachPoint : 'saveButton' } Add

$YOURAPP/javascript/components/TodoForm/TodoForm.haml

Tuesday, January 24, 12

Page 30: Getting Started with Mulberry

mulberry.store('todos', { model : 'Todo',

finish : function(id) { this.invoke(id, 'finish'); },

unfinish : function(id) { this.invoke(id, 'unfinish'); }});

$YOURAPP/javascript/stores/todos.js

Tuesday, January 24, 12

Page 31: Getting Started with Mulberry

mulberry.model('Todo', { complete : false,

finish : function() { this.set('complete', true); },

unfinish : function() { this.set('complete', false); }});

$YOURAPP/javascript/models/Todo.js

Tuesday, January 24, 12

Page 32: Getting Started with Mulberry

@touradev @rmurphey @mrdanimal

mulberry.toura.com

bit.ly/toura-mulberry

bit.ly/toura-mulberry-demos

Tuesday, January 24, 12

Page 33: Getting Started with Mulberry

Tuesday, January 24, 12

Page 34: Getting Started with Mulberry

routes manage high-level application state

components receive and render data, and react to user input

capabilities provide data to components, and broker communications between them

page de!nitions reusable groupings of components and capabilities

stores persist data on the device, make that data query-able, and return model instances

Tuesday, January 24, 12

Page 35: Getting Started with Mulberry

routes manage high-level application state

Tuesday, January 24, 12

Page 36: Getting Started with Mulberry

mulberry.page('/todos', { name : 'Todos', pageDef : 'todos'}, true);

mulberry.page('/completed', { name : 'Completed', pageDef : 'completed'});

$YOURAPP/javascript/routes.js

#/todos #/completed

Tuesday, January 24, 12

Page 37: Getting Started with Mulberry

stores persist data on the device, make that data query-able, and return model instances

Tuesday, January 24, 12

Page 38: Getting Started with Mulberry

mulberry.store('todos', { model : 'Todo',

finish : function(id) { this.invoke(id, 'finish'); },

unfinish : function(id) { this.invoke(id, 'unfinish'); }});

$YOURAPP/javascript/stores/todos.js

Tuesday, January 24, 12

Page 39: Getting Started with Mulberry

page de!nitions reusable groupings of components and capabilities

Tuesday, January 24, 12

Page 40: Getting Started with Mulberry

todos: capabilities: - name: PageTodos screens: - name: index regions: - components: - custom.TodoForm - className: list scrollable: true components: - custom.TodoList - components: - custom.TodoTools

NB: You can define this with JavaScript, too, using toura.pageDef(‘todos’, { ... }).

Tuesday, January 24, 12

Page 41: Getting Started with Mulberry

components receive and render data, and react to user input

Tuesday, January 24, 12

Page 42: Getting Started with Mulberry

mulberry.component('TodoForm', { componentTemplate : dojo.cache('client.components', 'TodoForm/TodoForm.haml'),

init : function() { this.connect(this.domNode, 'submit', function(e) { e.preventDefault();

var description = dojo.trim(this.descriptionInput.value), item;

if (!description) { return; }

item = { description : description }; this.domNode.reset(); this.onAdd(item); }); },

onAdd : function(item) { }});

$YOURAPP/javascript/components/TodoForm.js

Tuesday, January 24, 12

Page 43: Getting Started with Mulberry

%form.component.todo-form %input{ placeholder : 'New todo', dojoAttachPoint : 'descriptionInput' } %button{ dojoAttachPoint : 'saveButton' } Add

$YOURAPP/javascript/components/TodoForm/TodoForm.haml

Tuesday, January 24, 12

Page 44: Getting Started with Mulberry

mulberry.component('TodoForm', { componentTemplate : dojo.cache('client.components', 'TodoForm/TodoForm.haml'),

init : function() { this.connect(this.domNode, 'submit', function(e) { e.preventDefault();

var description = dojo.trim(this.descriptionInput.value), item;

if (!description) { return; }

item = { description : description }; this.domNode.reset(); this.onAdd(item); }); },

onAdd : function(item) { }});

$YOURAPP/javascript/components/TodoForm.js

Tuesday, January 24, 12

Page 45: Getting Started with Mulberry

capabilities provide data to components, and broker communications between them

Tuesday, January 24, 12

Page 46: Getting Started with Mulberry

todos: capabilities: - name: PageTodos screens: - name: index regions: - components: - custom.TodoForm - className: list scrollable: true components: - custom.TodoList - components: - custom.TodoTools

mulberry.capability('PageTodos', { requirements : { todoList : 'custom.TodoList', todoForm : 'custom.TodoForm', todoTools : 'custom.TodoTools' },

connects : [ [ 'todoForm', 'onAdd', '_add' ], [ 'todoList', 'onComplete', '_complete' ], [ 'todoList', 'onDelete', '_delete' ], [ 'todoTools', 'onCompleteAll', '_completeAll' ] ],

init : function() { this.todos = client.stores.todos; this._updateList(); },

_add : function(item) { this.todos.add(item); this._updateList(); },

_delete : function(id) { this.todos.remove(id); this._updateList(); },

_complete : function(id) { this.todos.finish(id); this._updateList(); },

_updateList : function() { var items = this.todos.query(function(item) { return !item.complete; });

this.todoList.set('todos', items); },

_completeAll : function() { this.todos.query(function(item) { return !item.complete; }).forEach(dojo.hitch(this, function(t) { t.finish(); this.todos.put(t); }));

this._updateList(); }});

Tuesday, January 24, 12

Page 47: Getting Started with Mulberry

todos: capabilities: - name: PageTodos screens: - name: index regions: - components: - custom.TodoForm - className: list scrollable: true components: - custom.TodoList - components: - custom.TodoTools

mulberry.capability('PageTodos', { requirements : { todoList : 'custom.TodoList', todoForm : 'custom.TodoForm', todoTools : 'custom.TodoTools' },

connects : [ [ 'todoForm', 'onAdd', '_add' ], [ 'todoList', 'onComplete', '_complete' ], [ 'todoList', 'onDelete', '_delete' ], [ 'todoTools', 'onCompleteAll', '_completeAll' ] ],

init : function() { this.todos = client.stores.todos; this._updateList(); },

_add : function(item) { this.todos.add(item); this._updateList(); },

_delete : function(id) { this.todos.remove(id); this._updateList(); },

_complete : function(id) { this.todos.finish(id); this._updateList(); },

_updateList : function() { var items = this.todos.query(function(item) { return !item.complete; });

this.todoList.set('todos', items); },

_completeAll : function() { this.todos.query(function(item) { return !item.complete; }).forEach(dojo.hitch(this, function(t) { t.finish(); this.todos.put(t); }));

this._updateList(); }});

Tuesday, January 24, 12

Page 48: Getting Started with Mulberry

todos: capabilities: - name: PageTodos screens: - name: index regions: - components: - custom.TodoForm - className: list scrollable: true components: - custom.TodoList - components: - custom.TodoTools

mulberry.capability('PageTodos', { requirements : { todoList : 'custom.TodoList', todoForm : 'custom.TodoForm', todoTools : 'custom.TodoTools' },

connects : [ [ 'todoForm', 'onAdd', '_add' ], [ 'todoList', 'onComplete', '_complete' ], [ 'todoList', 'onDelete', '_delete' ], [ 'todoTools', 'onCompleteAll', '_completeAll' ] ],

init : function() { this.todos = client.stores.todos; this._updateList(); },

_add : function(item) { this.todos.add(item); this._updateList(); },

_delete : function(id) { this.todos.remove(id); this._updateList(); },

_complete : function(id) { this.todos.finish(id); this._updateList(); },

_updateList : function() { var items = this.todos.query(function(item) { return !item.complete; });

this.todoList.set('todos', items); },

_completeAll : function() { this.todos.query(function(item) { return !item.complete; }).forEach(dojo.hitch(this, function(t) { t.finish(); this.todos.put(t); }));

this._updateList(); }});

Tuesday, January 24, 12