== Welcome to Spider
Spider is a Model-View-Controller application framework, mainly intended for Web applications.
Its main features are:
* A model layer that is easy to use, yet flexible enough to adapt to legacy schemas.
Models are defined in Ruby: schemas are autogenerated, but can be specified manually when needed.
Deep loading and deep querying are supported, through a simple pure-Ruby query language:
planets = Planet.find{ |planet| planet.stars.diameter <= 1500000 }
p planets[0].atmosphere.type
No N+1 queries are performed: deep data is loaded in batches, using windows if needed.
A Unit of Work is available for complex saves. An Identity Mapper mantains
the integrity of an object's tree; but it isn't forced globally, so data replication and
translation is still possible.
* A view layer based on HTML, with reusable widgets that are easy to extend in both their controller and their view.
Templates are mostly valid HTML, but implement variable substitution, widget instantiation, conditional and iteration logic.
Hello, { @my_name }
A view can be extended by another one like
, and welcome to the show.
Or, a widget can be customized directly when instantiated:
Views are compiled, so they are fast; so are the _overrides_, which always work on the source template.
No code blocks are available in the views. This forces clear separation of the logic from the presentation and allows
the programmatic manipulation of the templates.
Still, full Ruby is available on the "scene" variables, so formatting logic can be applied inline.
* A light controller with flexible redirection, before and after stacks, and an annotation system to expose methods
with different content types.
class MyController < Spider::PageController
route 'admin', MyAdminController
route /books/(.+)/, :book
__.html
def book(id)
@scene.book = Book.new(id)
render 'book'
end
end
Widgets are controllers, too, so they get the same funtionality; still, it's the main controller that manages them,
and can easily customize the widgets' behaviour.
* A JavaScript library (jQuery based) that interacts with the backend.
Controllers have their corresponding Javascript objects that allow actions on the server; so do widgets
instances, which have a direct line with the same instance on the server.
$W('my_gallery').reload({place: 'Barcelona'});
Widgets instances can be rendered individually, allowing a zero-work ajax which can be refined later while
still preserving the non-javascript functionality.
Javascript and CSS dependencies are managed by requiring them in controller and widget templates; they are
automatically resolved and compressed when running in production mode.
In addition, Spider provides:
* Thread safety (if you play it safe, of course): Spider runs equally well in a single process mode as in a multiple
process mode. A threaded single process can be faster and less resource intensive; multiple threaded or single-threaded
processes can be pooled.
Thread safety has been a requirement since the beginning of the project.
* CRUD administration but no scaffolding: administration is composed with widgets that can be extended and customized,
ensuring that common functionality can be globally modified when needed.
* Multiple app support: apps are packages which can be distributed and activated as needed.
* A (writable) YAML-based configuration system with smart defaults and includable sets.
* No pollution: monkey-patching is kept to the minimum. ActiveSupport is definitely not needed,
but is grudgingly accepted if it is loaded.
* Full internazionalization using gettext and CLDR, even for Javascript files.
You can dive in by running
$ spider create home test
$ cd test
$ spider create app my_app
Add 'my_app' to the apps in config/config.yml, run
$ spider webserver start
and point your browser to http://localhost:8080/my_app/
Have fun!