0.0.4-6-g621932e • Published 12 years ago

alpha_simprini v0.0.4-6-g621932e

Weekly downloads
6
License
-
Repository
github
Last release
12 years ago
Alpha Simprini incorporates Pathology and Taxi.

Alpha Simprini

PUBLIC DOMAIN LICENSE ( IT'S IN THE PUBLIC DOMAIN )

From Lower Earth Orbit, it's Alpha Simprini

Alpha Simprini is a browser application framework. It is a terrible awful mish-mash of ideas from Backbone and SproutCore/Ember.js

Modular (or something)

Alpha Simprini uses Pathology and Taxi to power the underlying Object model and event/databinding systems.

Also present are jwerty, jQuery, underscore, ShareJS, rangy and fleck

Tests are written in nodeunit.

Views

No Templating Language

Alpha Simprini doesn't use a templating language. Your DOM is generated by code. The opinion behind this is that a templating language (even so-called 'logicless' templates) really want to be Classes with methods deep within their hearts. Except they don't end up doing a very good job of approximating the experience.

( You could certainly build a templating language on top of the Alpha Simprini dom generation and data-binding api. But why? )

Declarative Data Binding

Declare your data as it will live in the DOM. Ordered list? Selection models? Relationships? Simple fields?

MyApp.ThingyView = AS.View.extend
  content: ->
    @h1 "This is the thingy view!"
    @p "This thing is ", @thingy.description, "."
    @ul ->
      @bind @thingy.children, (child) ->
        @li -> @bind(child.name).attr

When the data changes, the DOM will be updated to reflect those changes automatically. All event handlers are cleaned up as objects are removed too.

Models

Domain Modeling

Model your domain with fields, and relationships: hasMany, hasOne, belongsTo.

CookBook.Recipe = AS.Model.extend()
CookBook.Recipe.field "minutesToPrepare", type: Number
CookBook.Recipe.field "veggeratian", type: Boolean
CookBook.Recipe.field "title"

CookBook.Ingredient = AS.Model.extend()
CookBook.Ingredient.field "name"
CookBook.Ingredient.field "quantity", type: Number
CookBook.Ingredient.belongsTo "recipe"

CookBook.Recipe.hasMany "ingredients", 
  model: -> MyApp.Ingredient
  inverse: "recipe"

Real Time Collaboration

Alpha Simprini ships with support for real-time collaboration with ShareJS

1) Configure the connection between Alpha Simprini and ShareJS

# The default ShareJsURL looks like this:
AS.ShareJsURL = "http://#{window?.location.host or 'localhost'}/sjs"
# Set it as neccessary for your server configuration.

2) Mixin ShareJS support

Editor.Document = AS.Model.extend()
AS.Model.Share.extend(Editor.Document)

3) Load your document by ID

document = Editor.Document.open("documentid")

At this point you can use the model as usual. You don't have to wait for the object to properly connect to the ShareJS server. Any chanegs you make to the object will be properly applied when the connection is made.

Application

In your application initialize function construct your models and views.

Todo = AS.Namespace.new("Todo")
Todo.Application = AS.Application.extend
  initialize: ->
    @list = Todo.Models.List.open(@params.list_id)
    @list_view = @view Todo.Views.List, list: @list
    @append @list_view

dependencies

You can get a package of dependencies with html_package .

curl http://spader.herokuapp.com/minispade.js > vendor/minispade.js
gem install html_package
hip install \
    --file="http://cloud.github.com/downloads/collin/alpha_simprini/alpha_simprini-0.5.0.html" \ 
    --out="vendor/alpha_simprini"

minispade

The best supported use of Alpha Simprini is through minispade. The javascript files downloaded by hip install are pre-wrapped in minispade

A copy of minispade can be downloaded here, or from Github.

curl http://spader.herokuapp.com/minispade.js > vendor/minispade.js

Get all those files into your application, for example, with the Rails asset pipeline:

#= require 'vendor/minispade'
#= require_dir 'vendor/alpha_simprini'

minispade.require 'alpha_simprini'

Now you're off to the races.