SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
3.7.2012 (                 : 20.3.2012)

A Backbone.js Tutorial for the
Impatient
     Part 1: How to Get Your Hands Dirt with
     Backbone.js in 5 Minutes




 B : Jaakko Salonen (@jsalonen)

 I     :M   C   A       &S       C         .S                   .

 P                  QuickSlides <https://github.com/airport h/QuickSlides>
Prerequisites
  R         :


  D    '                                      ,


 Node.js

  U                                               -


  G                 ://       .       /

 Git

  U                                                   .
  G                 ://   -       .       /

 D     ?N       '
Creating our project
  W      B
               ( '    )
  I


 C               :
 gtcoehts/gtu.o/baynbcbn-olrlt.i mpoet
  i ln tp:/ihbcmtrne/akoebiepaegt yrjc
 c mpoet
  d yrjc
 nd bidsre
  oe ul evr


  D     .i
         gt

  O           :8000

 IT'S ALIVE
Routers
     L '                             :

 I             R            apmdlseapej:
                            p/oue/ ml.s

     EapeRue =Bcbn.otretn(
     xml.otr   akoeRue.xed{
      rue:{
       ots
        ":"ne"
         " idx
       ,

      idx fnto( {
       ne: ucin)
       $'mi'.tl'h>el Wrd/1';
        (#an)hm(<1Hlo ol<h>)

     );


 H                          p/anj:
                            apmi.s

     iiilz:fnto( {
     ntaie ucin)
      ti.xmlRue =nwEapeRue(;
       hseapeotr  e xml.otr)
     ,



Building and validating
 B                          :
     nd bid
     oe ul


 I                 ,             tot ros.
                            Dn, ihu err.
                            oe

 S                              :
     nd bidsre
     oe ul evr


 C                     .R
           .
Views
 I                      DOM,     '
           .

 M        apmdlseapej (
          p/oue/ ml.s                 i d ):
                                       ne
     idx fnto( {
     ne: ucin)
      vridx=nwEapeVesIdx)
       a ne  e xml.iw.ne(;
      idxrne(;
       ne.edr)


     EapeVesIdx=Bcbn.iwetn(
     xml.iw.ne      akoeVe.xed{
      e:'mi'
       l #an,
      tmlt:"p/epae/ne.tl,
       epae aptmltsidxhm"
      rne:fnto( {
       edr ucin)
        vrve =ti;
         a iw   hs
        nmsaefthepaeti.epae fnto(ml {
         aepc.ecTmlt(hstmlt, ucintp)
          ve.linrTL=tp(nm:'ol')
           iwe.neHM   ml{ae wrd ;
         );

     );


 aptmltsid .tl
  p/epae/ne hm

     <1Hlo<=nm % fo aptmlt/ne.tl<h>
     h>el % ae > rm p/epaeidxhm!/1


 N                  (        '           )
Refactoring to Support Multiple
Pages (1/2)
 A    W
 apmdlseapej:
  p/oue/ ml.s

     EapeWbae=Bcbn.oe.xed{
     xml.epg    akoeMdletn(
      dfut:{
       eals
       tte 'nild,
        il: Utte'
       cnet 'ocnet
        otn: N otn'

     );


 A                :
     "pgi" "ne"
     :aed: idx


 A               id
                  ne   :

     idx fnto(aed {
     ne: ucinpgi)
      i(aed==udfnd {
       fpgi = neie)
       pgi =1
        aed  ;

      vridx=nwEapeVesIdx)
       a ne  e xml.iw.ne(;
      idxmdl=nwEapeWbae{i' pgi )
       ne.oe   e xml.epg('d: aed ;
      idxrne(;
       ne.edr)



 (        ...)
Refactoring to Support Multiple
Pages (2/2)
 P  W                  rne (
                       edr
 apmdlseapej)
  p/oue/ ml.s

 ve.linrTL=tp(iwmdltJO()
 iwe.neHM   mlve.oe.oSN);


 A            p/epae/ne hm:
             aptmltsid .tl

 <1HloPg #% i %!/1
 h>el ae <= d ><h>


 D   !T       URLS             :

     ://   :8000/
     ://   :8000/1
     ://   :8000/#99
Managing Models with a
Collection
 A                        (
 a p m d l s e a p e j ):
  p/oue/ ml.s

 EapeWbae =Bcbn.olcinetn(
 xml.epgs   akoeCleto.xed{
  mdl EapeWbae
   oe: xml.epg,
  /lcltrg:nwwno.tr(Wbae" / cmetfrnw
   /oaSoae e idwSoe"epgs) / omn o o
 );


 R       id
          ne   R        (   ):

 i(aed==udfnd {
 fpgi = neie)
  pgi =1
   aed  ;


 vrwbae =nwEapeWbae(;
 a epgs   e xml.epgs)
 /wbae.ec(;/ cmetfrnw
 /epgsfth) / omn o o
 vrti_ae=wbae.e(aed;
 a hspg    epgsgtpgi)

 i(ti_ae==udfnd){
 f hspg = neie
  ti_ae=nwEapeWbae{d pgi )
   hspg  e xml.epg(i: aed ;
  wbae.d(hspg)
   epgsadti_ae;
  /ti_aesv(;/ cmetfrnw
   /hspg.ae) / omn o o


 vridx=nwEapeVesIdx)
 a ne   e xml.iw.ne(;
 idxmdl=ti_ae
 ne.oe   hspg;
 idxrne(;
 ne.edr)


 T   (              )
Persisting Models with HTML5
localStorage
  G   bcbn.oaSoaej
      akoelcltrg.s
       . /  /B  .  S                     :
  S
  ast/slb/akoelcltrg.s
   sesj/isbcbn.oaSoaej

 A                  c n i . s(
                     ofgj             bcbn
                                       akoe
        ):
 "akoelcltrg" ".ast/slb/akoelcltrg"
 bcbn.oaSoae: ./sesj/isbcbn.oaSoae,

 ..
 .

 bcbn.oaSoae {
 akoelcltrg:
  dp:[uebcbn" "s!nesoe]
   es "s!akoe, ueudrcr",
  atc:"akoe
   tah Bcbn"
 ,


 apmdlseapej
  p/oue/ ml.s                        dfn (
                                      eie
    u e b c b n " ):
   "s!akoe,

 "s!akoelcltrg"
 uebcbn.oaSoae


 Uncomment lines from previous slide

 B                                           S
               .R    . .   F     :
 cnoedrlcltrg)
 osl.i(oaSoae;
Adding Flesh - Edit Content
 N             (      ),
        .

 aptmltsid .tl
  p/epae/ne hm

 <1cas"aette>% tte% (<=i %)/1
 h ls=pg-il"<= il > #% d ><h>
 <i cas"aecnet>
 dv ls=pg-otn"
  <i cas"dtrhde"
   dv ls=eio idn>
   <>txae rw=2"cl=8"<txae>/>
    p<etra os"5 os"0>/etra<p
   <>ipttp=sbi"vle"ae>/nu>/>
    p<nu ye"umt au=Sv"<ipt<p
  <dv
   /i>
  <i cas"edrd>% cnet%<dv
   dv ls=rnee"<= otn >/i>
 <dv
 /i>


 apmdlseapej
  p/oue/ ml.s
 EapeVesId :
   ml.i .ne

 eet:{
 vns
  "lc .aecnet.edrd:"dtotn"
   cik pg-otn rnee" eiCnet
 ,
 eiCnet fnto( {
 dtotn: ucin)
  vrcnet=ti.oe.e(cnet)
   a otn  hsmdlgt'otn';
  $'pg-otn .edrd)hd(;
   (.aecnet rnee'.ie)
  $'pg-otn .dtr)rmvCas'idn)
   (.aecnet eio'.eoels(hde';
  $'pg-otn .dtrtxae'.tlcnet;
   (.aecnet eio etra)hm(otn)
 ,
Adding Flesh - Save Edited
Content
 apmdlseapej
  p/oue/ ml.s

 eet:{
 vns
  ..
   .
  "lc .aecnet.dtripttp=sbi'" "aeotn"
   cik pg-otn eio nu[ye'umt]: svCnet
 ,
 ..
 .
 svCnet fnto( {
 aeotn: ucin)
  vrcnet=$'pg-otn .dtrtxae'.a(;
   a otn  (.aecnet eio etra)vl)
  ti.oe.e(cnet,cnet;
   hsmdlst'otn' otn)
  ti.oe.ae)
   hsmdlsv(;

  $'pg-otn .dtr)adls(hde';
   (.aecnet eio'.dCas'idn)
  $'pg-otn .dtrtxae'.tl')
   (.aecnet eio etra)hm(';
  $'pg-otn .edrd)rmvCas'idn)
   (.aecnet rnee'.eoels(hde';

  ti.edr)
   hsrne(;
E e Cand - Markdown
Renderer Hook-up (1/2)
 L '              .   ( J   S   M
       )

 G          (
 . / s t / s l b / h d n j ):
  .aesj/isso o .s
 hts/gtu.o/ihbgtu-lvrdmrdw/lbg-ae/cit/hw
 tp:/ihbcmgtu/ihbfaoe-akonbo/hpgssrpsso


 apcni.s
  p/ofgj

 sodw:".ast/slb/hwon,
 hwon ./sesj/issodw"

 ue {
 s:
  ..
   .
  sodw:{
   hwon
    atc:"hwon
     tah Sodw"
E e Cand - Markdown
Renderer Hook-up (2/2)
 apmdlseapej
  p/oue/ ml.s

 "s!akoe,
 uebcbn"
 "s!hwon
 uesodw"

 ..
 .

 fnto(aepc,Bcbn,Sodw){
 ucinnmsae akoe hwon


 N                :

 aptmltsid .tl
  p/epae/ne hm

 <i cas"edrd>
 dv ls=rnee"
  < vrcnetr=nwSodw.ovre(;%
   % a ovre  e hwoncnetr) >
  <=cnetrmkHm(otn)%
   % ovre.aetlcnet >
 <dv
 /i>
Building for production
 R             (                    ):
 nd bid
 oe ul


 C                         .F            ,   :
 nd bid-hl
 oe ul -ep


 B             :
 nd bidrlae
 oe ul ees


 R                              :
 nd bidsre:ees
 oe ul evrrlae


 YSlow gives us Grade A (overall performance score 94)
See ou in Part 2
 Thank ou!
 J      S
     U e i e (@j a    e )f   e i   (f   e
     ecei e da e !)

Más contenido relacionado

La actualidad más candente

谈A国古代!%,%o现代l实现
谈A国古代!%,%o现代l实现谈A国古代!%,%o现代l实现
谈A国古代!%,%o现代l实现
sugeladi
 
Oliver Pirate Project
Oliver Pirate ProjectOliver Pirate Project
Oliver Pirate Project
Joan Bennett
 

La actualidad más candente (20)

谈A国古代!%,%o现代l实现
谈A国古代!%,%o现代l实现谈A国古代!%,%o现代l实现
谈A国古代!%,%o现代l实现
 
JavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring RooJavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring Roo
 
One page app with AngularJS
One page app with AngularJSOne page app with AngularJS
One page app with AngularJS
 
Purpose
PurposePurpose
Purpose
 
2008 june 9
2008 june 92008 june 9
2008 june 9
 
WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめよう
 
Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)
 
Oliver Pirate Project
Oliver Pirate ProjectOliver Pirate Project
Oliver Pirate Project
 
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_ЯндексеТанки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
 
Ember background basics
Ember background basicsEmber background basics
Ember background basics
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
 
Create Custom Post Type Plugin
Create Custom Post Type PluginCreate Custom Post Type Plugin
Create Custom Post Type Plugin
 
Javascript Common Mistakes
Javascript Common MistakesJavascript Common Mistakes
Javascript Common Mistakes
 
Python パッケージ構成
Python パッケージ構成Python パッケージ構成
Python パッケージ構成
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6
 
Clojurescript up and running
Clojurescript up and runningClojurescript up and running
Clojurescript up and running
 
Shell and perl scripting classes in mumbai
Shell and perl scripting classes in mumbaiShell and perl scripting classes in mumbai
Shell and perl scripting classes in mumbai
 
Alu car
Alu carAlu car
Alu car
 
Javascript: The Important Bits
Javascript: The Important BitsJavascript: The Important Bits
Javascript: The Important Bits
 

Similar a A Backbone.js Tutorial for the Impatient - Part 1

Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Pat Cito
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
Tony Fabeen
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
Tony Fabeen
 

Similar a A Backbone.js Tutorial for the Impatient - Part 1 (20)

Angular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureAngular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental Feature
 
Starting out with Ember.js
Starting out with Ember.jsStarting out with Ember.js
Starting out with Ember.js
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at Google
 
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
 
Theme Development and Customization
Theme Development and CustomizationTheme Development and Customization
Theme Development and Customization
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Making the most of 2.2
Making the most of 2.2Making the most of 2.2
Making the most of 2.2
 
Noah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku SecretsNoah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku Secrets
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Tercera parte parte del Cuaderno de Ingles
Tercera parte parte del Cuaderno de InglesTercera parte parte del Cuaderno de Ingles
Tercera parte parte del Cuaderno de Ingles
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friend
 
Ff to-fp
Ff to-fpFf to-fp
Ff to-fp
 
Front End Dependency Management at CascadiaJS
Front End Dependency Management at CascadiaJSFront End Dependency Management at CascadiaJS
Front End Dependency Management at CascadiaJS
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutes
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

A Backbone.js Tutorial for the Impatient - Part 1

  • 1. 3.7.2012 ( : 20.3.2012) A Backbone.js Tutorial for the Impatient Part 1: How to Get Your Hands Dirt with Backbone.js in 5 Minutes B : Jaakko Salonen (@jsalonen) I :M C A &S C .S . P QuickSlides <https://github.com/airport h/QuickSlides>
  • 2. Prerequisites R : D ' , Node.js U - G :// . / Git U . G :// - . / D ?N '
  • 3. Creating our project W B ( ' ) I C : gtcoehts/gtu.o/baynbcbn-olrlt.i mpoet i ln tp:/ihbcmtrne/akoebiepaegt yrjc c mpoet d yrjc nd bidsre oe ul evr D .i gt O :8000 IT'S ALIVE
  • 4. Routers L ' : I R apmdlseapej: p/oue/ ml.s EapeRue =Bcbn.otretn( xml.otr akoeRue.xed{ rue:{ ots ":"ne" " idx , idx fnto( { ne: ucin) $'mi'.tl'h>el Wrd/1'; (#an)hm(<1Hlo ol<h>) ); H p/anj: apmi.s iiilz:fnto( { ntaie ucin) ti.xmlRue =nwEapeRue(; hseapeotr e xml.otr) , Building and validating B : nd bid oe ul I , tot ros. Dn, ihu err. oe S : nd bidsre oe ul evr C .R .
  • 5. Views I DOM, ' . M apmdlseapej ( p/oue/ ml.s i d ): ne idx fnto( { ne: ucin) vridx=nwEapeVesIdx) a ne e xml.iw.ne(; idxrne(; ne.edr) EapeVesIdx=Bcbn.iwetn( xml.iw.ne akoeVe.xed{ e:'mi' l #an, tmlt:"p/epae/ne.tl, epae aptmltsidxhm" rne:fnto( { edr ucin) vrve =ti; a iw hs nmsaefthepaeti.epae fnto(ml { aepc.ecTmlt(hstmlt, ucintp) ve.linrTL=tp(nm:'ol') iwe.neHM ml{ae wrd ; ); ); aptmltsid .tl p/epae/ne hm <1Hlo<=nm % fo aptmlt/ne.tl<h> h>el % ae > rm p/epaeidxhm!/1 N ( ' )
  • 6. Refactoring to Support Multiple Pages (1/2) A W apmdlseapej: p/oue/ ml.s EapeWbae=Bcbn.oe.xed{ xml.epg akoeMdletn( dfut:{ eals tte 'nild, il: Utte' cnet 'ocnet otn: N otn' ); A : "pgi" "ne" :aed: idx A id ne : idx fnto(aed { ne: ucinpgi) i(aed==udfnd { fpgi = neie) pgi =1 aed ; vridx=nwEapeVesIdx) a ne e xml.iw.ne(; idxmdl=nwEapeWbae{i' pgi ) ne.oe e xml.epg('d: aed ; idxrne(; ne.edr) ( ...)
  • 7. Refactoring to Support Multiple Pages (2/2) P W rne ( edr apmdlseapej) p/oue/ ml.s ve.linrTL=tp(iwmdltJO() iwe.neHM mlve.oe.oSN); A p/epae/ne hm: aptmltsid .tl <1HloPg #% i %!/1 h>el ae <= d ><h> D !T URLS : :// :8000/ :// :8000/1 :// :8000/#99
  • 8. Managing Models with a Collection A ( a p m d l s e a p e j ): p/oue/ ml.s EapeWbae =Bcbn.olcinetn( xml.epgs akoeCleto.xed{ mdl EapeWbae oe: xml.epg, /lcltrg:nwwno.tr(Wbae" / cmetfrnw /oaSoae e idwSoe"epgs) / omn o o ); R id ne R ( ): i(aed==udfnd { fpgi = neie) pgi =1 aed ; vrwbae =nwEapeWbae(; a epgs e xml.epgs) /wbae.ec(;/ cmetfrnw /epgsfth) / omn o o vrti_ae=wbae.e(aed; a hspg epgsgtpgi) i(ti_ae==udfnd){ f hspg = neie ti_ae=nwEapeWbae{d pgi ) hspg e xml.epg(i: aed ; wbae.d(hspg) epgsadti_ae; /ti_aesv(;/ cmetfrnw /hspg.ae) / omn o o vridx=nwEapeVesIdx) a ne e xml.iw.ne(; idxmdl=ti_ae ne.oe hspg; idxrne(; ne.edr) T ( )
  • 9. Persisting Models with HTML5 localStorage G bcbn.oaSoaej akoelcltrg.s . / /B . S : S ast/slb/akoelcltrg.s sesj/isbcbn.oaSoaej A c n i . s( ofgj bcbn akoe ): "akoelcltrg" ".ast/slb/akoelcltrg" bcbn.oaSoae: ./sesj/isbcbn.oaSoae, .. . bcbn.oaSoae { akoelcltrg: dp:[uebcbn" "s!nesoe] es "s!akoe, ueudrcr", atc:"akoe tah Bcbn" , apmdlseapej p/oue/ ml.s dfn ( eie u e b c b n " ): "s!akoe, "s!akoelcltrg" uebcbn.oaSoae Uncomment lines from previous slide B S .R . . F : cnoedrlcltrg) osl.i(oaSoae;
  • 10. Adding Flesh - Edit Content N ( ), . aptmltsid .tl p/epae/ne hm <1cas"aette>% tte% (<=i %)/1 h ls=pg-il"<= il > #% d ><h> <i cas"aecnet> dv ls=pg-otn" <i cas"dtrhde" dv ls=eio idn> <>txae rw=2"cl=8"<txae>/> p<etra os"5 os"0>/etra<p <>ipttp=sbi"vle"ae>/nu>/> p<nu ye"umt au=Sv"<ipt<p <dv /i> <i cas"edrd>% cnet%<dv dv ls=rnee"<= otn >/i> <dv /i> apmdlseapej p/oue/ ml.s EapeVesId : ml.i .ne eet:{ vns "lc .aecnet.edrd:"dtotn" cik pg-otn rnee" eiCnet , eiCnet fnto( { dtotn: ucin) vrcnet=ti.oe.e(cnet) a otn hsmdlgt'otn'; $'pg-otn .edrd)hd(; (.aecnet rnee'.ie) $'pg-otn .dtr)rmvCas'idn) (.aecnet eio'.eoels(hde'; $'pg-otn .dtrtxae'.tlcnet; (.aecnet eio etra)hm(otn) ,
  • 11. Adding Flesh - Save Edited Content apmdlseapej p/oue/ ml.s eet:{ vns .. . "lc .aecnet.dtripttp=sbi'" "aeotn" cik pg-otn eio nu[ye'umt]: svCnet , .. . svCnet fnto( { aeotn: ucin) vrcnet=$'pg-otn .dtrtxae'.a(; a otn (.aecnet eio etra)vl) ti.oe.e(cnet,cnet; hsmdlst'otn' otn) ti.oe.ae) hsmdlsv(; $'pg-otn .dtr)adls(hde'; (.aecnet eio'.dCas'idn) $'pg-otn .dtrtxae'.tl') (.aecnet eio etra)hm('; $'pg-otn .edrd)rmvCas'idn) (.aecnet rnee'.eoels(hde'; ti.edr) hsrne(;
  • 12. E e Cand - Markdown Renderer Hook-up (1/2) L ' . ( J S M ) G ( . / s t / s l b / h d n j ): .aesj/isso o .s hts/gtu.o/ihbgtu-lvrdmrdw/lbg-ae/cit/hw tp:/ihbcmgtu/ihbfaoe-akonbo/hpgssrpsso apcni.s p/ofgj sodw:".ast/slb/hwon, hwon ./sesj/issodw" ue { s: .. . sodw:{ hwon atc:"hwon tah Sodw"
  • 13. E e Cand - Markdown Renderer Hook-up (2/2) apmdlseapej p/oue/ ml.s "s!akoe, uebcbn" "s!hwon uesodw" .. . fnto(aepc,Bcbn,Sodw){ ucinnmsae akoe hwon N : aptmltsid .tl p/epae/ne hm <i cas"edrd> dv ls=rnee" < vrcnetr=nwSodw.ovre(;% % a ovre e hwoncnetr) > <=cnetrmkHm(otn)% % ovre.aetlcnet > <dv /i>
  • 14. Building for production R ( ): nd bid oe ul C .F , : nd bid-hl oe ul -ep B : nd bidrlae oe ul ees R : nd bidsre:ees oe ul evrrlae YSlow gives us Grade A (overall performance score 94)
  • 15. See ou in Part 2 Thank ou! J S U e i e (@j a e )f e i (f e ecei e da e !)