SlideShare a Scribd company logo
1 of 102
Download to read offline
Caridy Patino
Bartender at Yahoo! Mojito Team
Principal Engineer at Yahoo! Search

caridy@yahoo-inc.com
@caridy
for YUI developer
Agenda:

- YUI Apps overview
- Mojito for YUI Apps
- Mojito components
- Mojito Mojits
- Execution context & configurations
- DEMO
- Extending Mojito
There are three things we do when creating
             YUI applications:
The Seed file(s)
Example of a composite seed from search.yahoo.com:

http://a.l.yimg.com/pv/lib/s9/srp-core-js-1_201106101018.js
http://a.l.yimg.com/pv/lib/s9/srp-core-js-2_201210020629.js
The YUI().use() statement
The YUI config
YUI_config = {filter: “debug”};
YUI.GlobalConfig = {filter: “debug”};
YUI.applyConfig({filter: “debug”});
Y.applyConfig({filter: “debug”});
YUI({filter: “debug”});
... and there is a four thing we also do:
The YUI.add() magic to create new building blocks
          or to bundle business logic
... and here is where things get messy
How to organize our files?
How to configure our app to use our files?
How to build those files for production?
       How to optimize them?
       How to push to CDN?
... and this list goes on and on!
We are on our own on this!
YUI Runtimes
There are four different kind of applications
        that we can build with YUI
Traditional Web Pages
HTML5 Web App (a la YAF)
Offline HTML5 Hybrid App (a la phonegap)
NodeJS App to serve traffic
Nowadays, when we build a product, we usually
  need to build more that one type of app
We can group the runtimes by
     Server and Client
YUI 4x4

         Seeds   YUI use   YUI config   YUI add

 Web      x         x         x          x

 YAF      x         x         x          x

Hybrid    x         x         x          x

NodeJS              x         x          x
Mojito for YUI Developer




$ npm install mojito -g
YUI vs Mojito
YUI and Mojito
YUI is a library of building blocks
to create javascript applications!
Mojito is a boilerplate framework for
       javascript applications!
Mojito is a boilerplate framework for
     javascript YUI applications...
... and YUI modules are the building blocks
              for those apps
Mojito does NOT provide any building block,
      it provides archetypes and utilities
Mojito Architecture Components
Mojito Components

          mojito-cli


                  mojito-store


mojito-server

                  mojito-core



        mojito-client
Command line interface
$ mojito <something>
            mojito-cli


                    mojito-store


  mojito-server

                    mojito-core



          mojito-client
The Store is an abstraction layer for a
    mojito application filesystem

                 mojito-cli


                         mojito-store


       mojito-server

                         mojito-core



               mojito-client
Mojito core is the dispatch engine
and a runtime abstraction for logical pieces

                    mojito-cli


                            mojito-store


          mojito-server

                            mojito-core



                  mojito-client
Mojito server for NodeJS
      (a la express)

           mojito-cli


                   mojito-store


 mojito-server

                   mojito-core



         mojito-client
Mojito client
       (a la YAF)

          mojito-cli


                  mojito-store


mojito-server

                  mojito-core



        mojito-client
mojito-cli



 The capabilities of                     mojito-store

each component can
be augmented easily    mojito-server

                                         mojito-core



                               mojito-client
mojito-cli


                                          mojito-store
Each component can
 be used in isolation   mojito-server

                                          mojito-core



                                mojito-client
Server runtime workflow

 analyze req       route      flush static or error
(middleware)       exists?


                             dispatch

                  dispatch
                                            deploy    no   flush content
                                            client?


                                                yes
                                        generate seed
                                                            flush html
                                          and Y.use
Client runtime workflow

                  route
                            navigate
analyze url       exists?


                       dispatch

                                         valid
                                                  yes
                 dispatch              runtime?           execute

                                            no

                                    delegate to
                                                        flush content
                                  remote runtime
Growing your software with Mojito
Applications will tent to grow organically
by adding complexity and new logical pieces
Some of these logical pieces can be reuse
across different form factors and devices
In Mojito, a logical piece is called a Mojit
and Applications are just composition of Mojits
In Mojito, the simplest app
    contains one Mojit




$   mojito create app demo
$   cd ./demo
$   mojito create mojit foo
$   mojito start
Mojits in Mojito
A Mojit should be:

- sharable
- configurable
- customizable
- nest-able
- mutable
Mojit structure
A Mojit is a composition of entities in a
form of JS, CSS, templates, configurations,
             and other assets
$ mojito create mojit foo
Entity Registration in Mojito
In Mojito, there are three different
      registration processes
By YUI.add(), which is applicable for
 yui modules and it is used by YUI
By affinity, which is applicable for
javascript files, and it is used by mojito-store
The affinity could be:
server, client or common
The affinity registration solves two use cases:


   Bar
            requires
 (server)
                          Foo
                       (common)
   Baz
 (client)   requires
                                               Bar
                                             (server)

                          Foo
                                  requires
                       (common)
                                               Bar
                                             (client)
By selector, which is applicable for js, css and templates,
     and it is used by mojito-store during run time
The selector could be <anything> in a form of a string
The selector registration solves one use case:


                                             pick “bar.iphone”      Bar
                                                                 (iphone)


 Foo
       require “bar”                                                Bar
                              mojito-store
                                                                  (ipad)
                              selector
                       iphone,mobile,*

                                                                   Bar
                                  context                        (mobile)
render(data, {
    view: {
        name: “bar”
    }
});
YUI 4x4

         Seeds   YUI use   YUI config   YUI add

 Web                x                    x

 YAF                x                    x

Hybrid              x                    x

NodeJS              x                    x
Mojito execution context and configurations
Mojito uses the Yahoo! Configuration Bundle
                 (aka YCB)




       http://github.com/yahoo/ycb
Mojito Server and Client abstractions will
take care of resolving execution context
    and configurations when needed
path/to/demo/application.json
path/to/mojits/foo/definition.json
Accessing configuration from Mojit’s controller
Mojito does heavy use of configurations
        in a form of JSON files
Customizing Seed files
Customizing Seed files
YUI 4x4

         Seeds   YUI use   YUI config   YUI add

 Web      x                   x

 YAF      x                   x

Hybrid    x                   x

NodeJS                        x
DEMO
Extending Mojito
Mojito embraces NPM to enable
     software composition
package.json
$ cd path/to/app/
$ npm install mojit-trending-now
... and from the application point of view
there is not distinction because the mojito-store
              will flatten the structure
Mojito embraces NPM to support
boilerplate extensions and addons
$ cd path/to/app/
$ npm install mojito-sass
$ npm install mojito-shaker
Mojito extensions can be:

- mojito cli commands
- store addons
- mojits, archetypes & renderers
- middleware
- action-context addons
... and we need your help to build those
              extensions!
Mojito Today
// Mojito 101

$   npm install mojito@0.5.0pr4 -g
$   mojito version
$   mojito create app demo
$   cd ./demo
$   mojito create mojit foo
$   mojito jslint app . -p
$   mojito test app . --coverage
$   mojito start --context ”environment:dev”
$   curl http://localhost:8666/@foo/index
// Mojito 101 (second part)

$   mojito   build html5app ./
$   mojito   gv client
$   mojito   jslint app ./
$   mojito   docs app ./
$   mojito   info ./
$   mojito   help
Current versions:
- mojito@0.5.0pr4
- yui@3.7.3
Mojito Tomorrow
- YAF integration is coming
- Performance is paramount
- Mojito extensions:
  (debugger, profiler, less, sass,
   coffeescript, typescript, etc)
One last thing...
http://github.com/yahoo/mojito
All the code from the presentation
             is available here:


http://gist.github.com/4070536
Thank you!
   @caridy

More Related Content

Similar to YUI Apps Overview with Mojito

Yahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency HackdayYahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency HackdayGaurav Vaish
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoCaridy Patino
 
Mojito: Building for multiple devices using a single language and framework
Mojito: Building for multiple devices using a single language and frameworkMojito: Building for multiple devices using a single language and framework
Mojito: Building for multiple devices using a single language and frameworkDiego Ferreiro Val
 
Building for multiple devices using a single language and framework
Building for multiple devices using a single language and frameworkBuilding for multiple devices using a single language and framework
Building for multiple devices using a single language and frameworkFabian Frank
 
Open Hack Taiwan 2012 - Mojito intro
Open Hack Taiwan 2012 - Mojito introOpen Hack Taiwan 2012 - Mojito intro
Open Hack Taiwan 2012 - Mojito introsriramiyer2007
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Heiko Behrens
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsSpike Brehm
 
iEnterprise - Mit HTML5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML5 zum Unternehmens-Dashboard für TabletsiEnterprise - Mit HTML5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML5 zum Unternehmens-Dashboard für TabletsStefan Kolb
 
iEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für TabletsiEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für TabletsIndiginox
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 uploadDebnath Sinha
 
Cocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.twCocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.twYu-Wei Chuang
 
Inside Mobile Widgets Publish
Inside Mobile Widgets PublishInside Mobile Widgets Publish
Inside Mobile Widgets Publish360|Conferences
 
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...itsatony
 
Introduction to the Yahoo! Mojito Node.js MVC
Introduction to the Yahoo! Mojito Node.js MVCIntroduction to the Yahoo! Mojito Node.js MVC
Introduction to the Yahoo! Mojito Node.js MVCAvinash Chukka
 

Similar to YUI Apps Overview with Mojito (20)

Yahoo! Mojito
Yahoo! MojitoYahoo! Mojito
Yahoo! Mojito
 
淺談 NodeJS 與框架
淺談 NodeJS 與框架淺談 NodeJS 與框架
淺談 NodeJS 與框架
 
Yahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency HackdayYahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency Hackday
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing Mojito
 
Mojito: Building for multiple devices using a single language and framework
Mojito: Building for multiple devices using a single language and frameworkMojito: Building for multiple devices using a single language and framework
Mojito: Building for multiple devices using a single language and framework
 
Building for multiple devices using a single language and framework
Building for multiple devices using a single language and frameworkBuilding for multiple devices using a single language and framework
Building for multiple devices using a single language and framework
 
Open Hack Taiwan 2012 - Mojito intro
Open Hack Taiwan 2012 - Mojito introOpen Hack Taiwan 2012 - Mojito intro
Open Hack Taiwan 2012 - Mojito intro
 
Mojito@nodejstw
Mojito@nodejstwMojito@nodejstw
Mojito@nodejstw
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
 
iEnterprise - Mit HTML5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML5 zum Unternehmens-Dashboard für TabletsiEnterprise - Mit HTML5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML5 zum Unternehmens-Dashboard für Tablets
 
iEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für TabletsiEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für Tablets
iEnterprise - Mit HTML-5 zum Unternehmens-Dashboard für Tablets
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 upload
 
Cocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.twCocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.tw
 
Mobile Widgets Development
Mobile Widgets DevelopmentMobile Widgets Development
Mobile Widgets Development
 
Inside Mobile Widgets Publish
Inside Mobile Widgets PublishInside Mobile Widgets Publish
Inside Mobile Widgets Publish
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
 
blue via
blue via blue via
blue via
 
Introduction to the Yahoo! Mojito Node.js MVC
Introduction to the Yahoo! Mojito Node.js MVCIntroduction to the Yahoo! Mojito Node.js MVC
Introduction to the Yahoo! Mojito Node.js MVC
 

More from Caridy Patino

MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptCaridy Patino
 
CSP Level 2: Defensa en profundidad para aplicaciones Web
CSP Level 2: Defensa en profundidad para aplicaciones WebCSP Level 2: Defensa en profundidad para aplicaciones Web
CSP Level 2: Defensa en profundidad para aplicaciones WebCaridy Patino
 
The rise of single-page applications
The rise of single-page applicationsThe rise of single-page applications
The rise of single-page applicationsCaridy Patino
 
YUIConf2013: Introducing The "Modown" Project
YUIConf2013: Introducing The "Modown" ProjectYUIConf2013: Introducing The "Modown" Project
YUIConf2013: Introducing The "Modown" ProjectCaridy Patino
 
FOWA2013: The rise of single page applications
FOWA2013: The rise of single page applicationsFOWA2013: The rise of single page applications
FOWA2013: The rise of single page applicationsCaridy Patino
 
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeThe challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeCaridy Patino
 
HTML5 summit - DevCon5 - Miami - Feb 2, 2012
HTML5 summit - DevCon5 - Miami - Feb 2, 2012HTML5 summit - DevCon5 - Miami - Feb 2, 2012
HTML5 summit - DevCon5 - Miami - Feb 2, 2012Caridy Patino
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
JS Loading strategies
JS Loading strategiesJS Loading strategies
JS Loading strategiesCaridy Patino
 
YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010Caridy Patino
 

More from Caridy Patino (10)

MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
CSP Level 2: Defensa en profundidad para aplicaciones Web
CSP Level 2: Defensa en profundidad para aplicaciones WebCSP Level 2: Defensa en profundidad para aplicaciones Web
CSP Level 2: Defensa en profundidad para aplicaciones Web
 
The rise of single-page applications
The rise of single-page applicationsThe rise of single-page applications
The rise of single-page applications
 
YUIConf2013: Introducing The "Modown" Project
YUIConf2013: Introducing The "Modown" ProjectYUIConf2013: Introducing The "Modown" Project
YUIConf2013: Introducing The "Modown" Project
 
FOWA2013: The rise of single page applications
FOWA2013: The rise of single page applicationsFOWA2013: The rise of single page applications
FOWA2013: The rise of single page applications
 
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeThe challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
 
HTML5 summit - DevCon5 - Miami - Feb 2, 2012
HTML5 summit - DevCon5 - Miami - Feb 2, 2012HTML5 summit - DevCon5 - Miami - Feb 2, 2012
HTML5 summit - DevCon5 - Miami - Feb 2, 2012
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
JS Loading strategies
JS Loading strategiesJS Loading strategies
JS Loading strategies
 
YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010YUI 3 Loading Strategies - YUIConf2010
YUI 3 Loading Strategies - YUIConf2010
 

YUI Apps Overview with Mojito