A MVC framework for Titanium Developer.
The purpose of this framework is to organize your Titanium Developer projects in a Model-View-Controller (MVC) pattern.
Current Version: 0.3.1
Fixed issue with model generator and the name attribute
API is locked
From this point on we will not be changing the API to move to stability. There were some changes between 0.2 and 0.3. From this point on there will not be any more api changes, so if your app works with 0.3 it should work with all later versions.
- Multiple App Support
Extended the Chester namespace from Base, this will enable the developer to add multiple applications to the Chester namespace and run routes between the apps.
Created an alias of '_' underscore for find, which will make the lines more readable. ex:
Created a names array on the base class to make it easier to find children objects
Updated generators with new changes
- Finish Generator Test Coverage
- Add testing library. Suggestions?
gem install chester
Add to any Titanium Developer Project
Just run chester install, and it will create the chester.coffee file in your Resources folder.
cd ./Resources chester install
cd ./Resources chester brew
Easy to generate models | views | controllers
cd ./Resources chester generate model person chester generate controller people chester generate view people index chester generate helper people
These generators will make the following objects:
class Person # Insert your code here Chester._('app').Models.add(new Person('Person'))
Just a quick run down on what is going on here: in order for chester to know your model, you MUST have an attribute called name. This attribute (name) will register the model to the application object. Chester will then be able to find your model whenever you request it.
class PeopleController extends Chester.Controller # Register Controller to application Chester._('app').add(new PeopleController('PeopleController'))
Just like with the model, the controller needs to have an attribute called name. That is the actual name used for Chester to recognize the controller.
class PeopleIndex extends Chester.View render: (params) -> # TODO: add your presentation code here. # Register view to Patients Controller Chester._('app')._("PeopleController").add(new PeopleIndex("index"))
Include the framework | models | views | controllers in app.js
// Include MVC Framework Ti.include('chester.js'); // Register Controllers Ti.include('controllers/people_controller.js'); // Register Models Ti.include('models/person.js'); // Register Views Ti.include('views/peoples/index.js');
- Simple Example and locked API
- Full Test Suite
- Complete Web Site Documentation
- Complete working JQuery Example
- Complete working Titanium Example
- Add a plugin module
The object hierarchy is very straight forward. Chester has a base object which has an add method and a find method.
- has a collection called children
- add : adds an object to the children array
- find : locates and returns the object based on the name attribute
This is the core class definition that all other classes inherit.
This objects children are controllers. With the add method you can add new controllers to this object. With the find method you can locate the controller by the name of the controller.
Add and Find Example:
- Chester.Application.find("PeopleController").add(new PeopleIndex())
There is another array of objects attached to this class called models. These are basic classes that can added to the Models array.
This will be the most confusing class because the UI objects in Titanium are user views. The Chester views are more like code containers that help isolate your user interface code from your business logic and domain logic.
- Controller: string,
- Action: string,
- Params: object
This method simply finds the controller and executes the action method on the controller, passing the params object as the parameter.
- Submit a pull request!
- Report an issue on twitter.com/jackhq using #Ti.chester