Add sinatra server

Use bundler (Gemfiles).
Use rakefile (config.ru) which define sinatra configuration.
Serve a rest API for media.
Will use this as the new server, so we're transitioning.
First haml view

Layout of the media part of the page.
Display media

Collection, model and view for the list of media.
Handle pushState on the server side.
Application skeleton.
Implement creation and edition behavior for media

Replace the selection view by a commum edit view.
Do everything through events using the Backbone object as event aggregator.
Medium deletion behavior

Display a confirmation view instead of the selection view.
Prevent edition and deletion of the "Choose One" element.
Use a promise as a NullObject/Option for getting the selected element.
It fails if the "Choose One" element is selected.
Undefined the selected element in the router if "Choose One" is selected.
Not sure if its useful, but better safe.
Move media related code from router to Library

Router should only know how to rehydrate app state from url.
Library is a bit bloated, maybe a Region object would make it better.
Extract view switching behavior in Region object

Just remove the previous view if exists and replace the content of the el by the new view.
Borrow on Marionnette concept.
Use Backbone style class definition.
Use Backbone object definition style on Library
More explicit workflow with promises

Views which result is binary (worked or didn't) can return a promise that will be forwarded by the region.
So the calling code can react on the result of the view.
Implemented it for edition and deletion.
Added validation with Backbone.Validation as a trial run.
If we cancel an edition, the model is still updated, so need to fix that.
Bootstrap media data

Application template populate bootstrap data from the db, which avoid 1 unecessary round trip to the server after init.
Stop listening to all media collection events in the media view, otherwise the view is re rendered too often and the medium selection doesn't work.
Stop using Backbone.Validation as it is too complex for current need and not so easy to use.
Validate by hand and show a star with a warning class when title is empty.
Edition cancellation bugs fixed

Was using this instead of self to get the previously selected medium.
Use a clone of the selected medium to not modify it if invalid validation followed by cancel.
Merge the resulting clone in the collection afterwards, otherwise will discard the changes.
Handle medium selection by URL

Route to handle medium/:id.
Update all links and preprend root (/) so that pointed resources are not requested on the URL (host/medium/main.css for instance).
Change URL on medium selection.
Fix routing and selection bug

Test to differentiate between Medium and id parameters to showMediaView was wrong.
Medium where passed as id.
When route to medium doesn't exists, reload the root route.
Show and handle medium/new route

Split creating and editing events in the view so router can listen to both.
Change url on edit and delete action
Handle edit and delete URLs on medium

Had to change which medium to show on cancel.
Library handles both medium and medium id on delete and edit methods.
Start theater and add media content chooser

Create the controllers in the app and pass them to the router.
This allows to access the controllers and their objects from the console.
And it make more sense. The router should have to know how to wire an app.
Start to play with bootstrap

Add bootstrap.
Remodel medium edition view to be bootstrap like.
Media views bootstrap style
Use icons for buttons