5 Backbone.js ➔ Lightweight JavaScript library ~ 6.3kb ➔ Brings structure to your application ➔ Brings MVC on client side – model, view, collections, router ➔ One hard dependency underscore.js ➔ For RESTful persistence and DOM manipulation , include json2.js, and either jQuery ( >= 1.7.0) or Zepto. ➔ Used by LinkedIn, Foursquare, WunderKit, Groupon,etc. More at http://backbonejs.org/#examples
6 Why backbone.js? ➔ Lightweight library not a framework, and does not have any opinions. ➔ Provides helpful methods to manipulate and query your data. ➔ Backbone does not force you to use a single template engine. ➔ Scales well eg. disqus widget and usatoday.com ➔ Works well with other libraries Get more information at http://backbonejs.org/#FAQ-why-backbone
7 Backbone.js Architecture Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
10 Collection ✔ A list of models ✔ Add, push, pop etc. ✔ Built on underscore.js Look at collection.html Books = Backbone.Collection.extend({ localStorage : new Store('books-collection'), model : Book }) var books = new Books(); books.push(new Book());
11 Views ✔ Views displays model ✔ Views are not HTML ✔ HTML comes from templates. ✔ Works with any template library ✔ Manipulates a DOM ✔ Has a Model / Collection look at view.html BooksView = Backbone.View.extend({ el : $('#main'), initialize : function(){ this.books = new Books(); this.books.on('all',this.render,this); this.books.fetch(); }, render : function(){ this.$el.html(this.template(this)); return this; } });
12 Router ✔ Maps URLs to functions ✔ Enable history and bookmarking ✔ Starting point of application Router = Backbone.Router.extend( routes : { "" : "index", }, index : function(){ console.log('in index()....'); var booksView = new BooksView(); this.el.empty(); this.el.append(booksView.render().el); }}); var router = new Router({el : $($('#main'))}); Backbone.history.start();
14 Cloud Service Models STORAGE (RHS) HARDWARE (x86, Power, S/390) VIRTUALIZATION (RHEV) OPERATING SYSTEM (RHEL) APPLICATION PLATFORM (JBOSS, PHP, RUBY, ETC) APPLICATION Automated and Managed by the Public or Private Cloud Offering Managed and Controlled by Customer (IT, Dev, or User) IaaS PaaS SaaS Increased Control Increased Automation
16 PaaS = Platform as a Service A Cloud Application Platform Code Deploy Enjoy Save Time and Money Code your app Push-button Deploy, and your App is running in the Cloud!
18 Why PaaS? Lets developer focus on his job i.e. to write code. You develop “Cloud Aware” applications from the beginning. Improves developer productivity. Reduces cost and time to market. Brings agility to product development. Gives developers the power to prototype their ideas rapidly.
21 What else do I get and what is the catch? OpenShift is free-as-in-beer & free-as-in-freedom You get three free gears, each with 512MB memory and 1GB of disk space. Need more resources, just ask! The catch is we are in developer preview right now
23 Some terminology for today 1. Application – your web code and any data store. Has to be on 1 or more gears 2. Gear – is like a server. It can have only 1 language for the web programming. 3. Cartridge – it adds a language, a data store, or other functionality 4. Git – used for version control and managing code between server and your development machine 5. Ssh – command line tool to connect to your gear
31 Play with MongoDB running in the Cloud ssh into instance Type mongo on the shell Create a sample db Insert some documents in the collection Run some queries
35 1. OpenShift makes life great for you 2. The tools are easy to use 3. You should be ready to write services 4. Almost anything you need on a server 5. Did I mention – Free 6. Source code https://github.com/shekhargulati/bookshop-bootcamp- rest-quickstart Conclusion