public
Description: Sammy is a tiny javascript framework built on top of jQuery, It's RESTful Evented Javascript.
Homepage: http://code.quirkey.com/sammy
Clone URL: git://github.com/quirkey/sammy.git
commit  d3c12af61c5b895d72ace6caa06022fce9016232
tree    4139f8dca1e4c013690b3805546978ba98e29d68
parent  369ec39faf58b121451df1c4be80c0fcbde670e7
sammy /
name age message
file .gitignore Thu Sep 03 20:51:56 -0700 2009 Changes to the way logging works Sammy.addLogg... [quirkey]
file .gitmodules Sat Sep 26 14:56:34 -0700 2009 Added self-referential site dir for a submodule... [quirkey]
file HISTORY Tue Sep 29 21:25:00 -0700 2009 Added HISTORY for 0.3.0 Reminified files [quirkey]
file LICENSE Mon May 11 07:56:20 -0700 2009 Added MIT License. Also first draft of README [quirkey]
file README.md Tue Oct 27 13:17:21 -0700 2009 Fix README to get rid of with() [quirkey]
file Rakefile Tue Sep 29 22:31:08 -0700 2009 Updated site and rakefile [quirkey]
directory examples/ Sat Sep 26 13:11:09 -0700 2009 Fixed params parsing for form submission. Firs... [Aaron Quint]
directory lib/ Thu Nov 12 13:45:23 -0800 2009 Dont require an app_function to be passed to th... [quirkey]
submodule site - 1bad440 Tue Oct 27 13:16:52 -0700 2009 Updated site [quirkey]
directory test/ Thu Nov 12 13:11:09 -0800 2009 Added the ability to configure the method and t... [quirkey]
directory vendor/ Wed Sep 30 07:52:31 -0700 2009 Updated docs for use(), tagging 0.3.0 [quirkey]
README.md

Sammy

http://code.quirkey.com/sammy

Description

Sammy is a tiny javascript framework built on top of jQuery inspired by Ruby's Sinatra.

Installation

Download sammy.js and install it in your public javascripts directory. Include it in your document AFTER jquery.

Usage

Like Sinatra, a Sammy application revolves around 'routes'. Routes in Sammy are a little different, though. Not only can you define 'get' and 'post' routes, but you can also bind routes to custom events triggered by your application.

You set up a Sammy Application by passing a Function to the $.sammy (which is a shortcut for the Sammy.Application constructor).

$.sammy(function() {

  this.get('#/', function() {
    $('#main').text('Welcome!');
  });

});

Inside the 'app' function() this is the Application. This is where you can configure the application and add routes.

Above, we defined a get() route. When the browser is pointed to #/ the function passed to that route will be run. Inside the route function, this is a Sammy.EventContext. EventContext has a bunch of special methods and properties including a params hash, the ability to redirect, render partials, and more.

Once you've defined an application the only thing left to do is run it. The best-practice behavior is to encapulate run() in a document.ready block:

var app = $.sammy(...)

$(function() {
  app.run();
});

This will guarantee that the DOM is loaded before we try to apply functionality to it.

Dependencies

Sammy requires jQuery >= 1.3.2 Get it from: http://jquery.com

More!

Learn!

Keep informed!

License

Sammy is covered by the MIT License. See LICENSE for more information.

Sammy includes code originally created by John Resig (Class implementation) and Greg Borenstien (srender).