Mediator based client-side MVC framework heavily inspired by Addy Osmani's talks on Aura.
Halo was conceived while Aura was still in private development, causing some concepts to be shared and others to be significantly different.
In your web page:
Each script is namespaced within require.js to its own filename (except for require.js).
|require.js||N/A||AMD loader which exposes
||One does not simply describe jQuery.|
||Cross-browser WebSocket implementation.|
||Mediator which provides a channel system for talking between models and controllers.|
||Build chain for client-side MVC views. You will
||require.js plugin which loads text files. This is a dependency for our mvc routing library.|
mvc is a require.js plugin which allows for easy routing to your models, views, and controllers. For example,
; // is equivalent to require(['models/user.js']);; // is equivalent to require(['text!views/main.html']);; // is equivalent to require(['controllers/home.js']);// Coming soon!; // is equivalent to...// require(['controllers/main.js', 'controllers/home.js', 'models/user']);
mvc is configured via require.js' configuration.
URLs are constructed via
directory + '/' + module + extension.
PrimalClay adds a set of functions to controller and model templates.
Currently, there is only
addMixin which handles the common mixin logic across models and controllers.
PrimalClay takes one parameter which is the constructor function to wrap.
MyControlleraddMixin; // undefinedvar $MyController = ;// Add a new mixin (myMixin) for MyController which processes params through myMixinFn$MyController;
Halo comes with two model templates for usage:
CrudModel provides the
memory mixin and Sauron hooks for
SocketModel extends on top
CrudModel by adding a socket.io to all methods,
as well as Sauron hooks for
deleteEvent which are intended to handle server push events.
More information on
SocketModel, and their mixins/methods can be found in docs/models.md.
There are two controller templates available:
BaseController does not provide any mixins by default and binds
stop to Sauron listeners.
BaseController and proxies
stop to append and remove generated content respectively.
Detailed explanations of
HtmlController, and their behaviors can be found in docs/controllers.md.
We have tried to stay as true to the thought
A view is markup and interactive logic
as much as possible.
Further documentation can be can be found in docs/views.md
// index.html<script>// Configure everything and kick-off the index controller</script>// config.js// Load in Builder, jade, and all jQuery plugins;// views/index.jadecontainerif errp An error occurred =elseh1 User inforowspan6 Name: #usernamespan6 Email: #useremail// controllers/index.js
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Also, please don't edit files in the "dist" or "stage" subdirectories as they are generated via grunt. You'll find source code in the "src" subdirectory!
If you plan to use the
src directory, you will need to adjust your require.js config accordingly.
We use multiple directories to separate the purpose of files. However, upon compilation, we flatten it to a single directory which allows for
require(['HtmlController']) without any additional routing.
You have a couple of options for the
src directory routing
mvcplugin which knows the paths to your
SocketModelto their new locations.
While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the
test/*.html unit test file(s) in actual browsers.
See the Why does grunt complain that PhantomJS isn't installed? guide in the Grunt FAQ for help with installing or troubleshooting PhantomJS.
Copyright (c) 2013 Ensighten Licensed under the MIT license.