MOJITO
Sriram Iyer
Yahoo! Developer Network
WHAT IS MOJITO?

MVC based framework for building rich web applications
Built on Javascript
Open Source




                                                         3
WE ALREADY HAVE A LOT OF MVC




                               4
THINK ABOUT THESE CASES




                          5
I WANT TO MAKE A WEB APPLICATION




                                   6
CLIENT CAN HAVE CAPABLE BROWSER




                                  7
CLIENT MIGHT BE FEATURE PHONE




                                8
RUN YOUR CODE ON SERVER SIDE
EASY TO TRANSFER FEATURE FROM
       ONE SIDE TO ANOTHER

Ajax fallback
Security risk
Performance
Latency




                                 10
BACKEND AND FRONTEND DEVS CAN
      HELP EACH OTHER

              What is he
               talking
               about?!!
                           Frontend

                 Mi…
                Mmm…




    Backend
TRADITIONAL WAY
ONE LANGUAGE
Mojito is written entirely in JavaScript.
TWO RUNTIMES
Your application code can be configured to run on the
server or be deployed to the client.
Similar user experience on different devices
Similar user experience on different devices
Similar user experience on different devices
Similar user experience on different devices
BACKEND JAVASCRIPT
http://nodejs.org/




                     17
FRONTEND JAVASCRIPT
http://yuilibrary.com




                        18
MOJITS
The basic unit of composition and reuse in a Mojito
application is a mojit. Visually, you can think of a mojit as
the rectangular area of a page that was constructed by a
Mojito application.
WHAT A MOJIT LOOKS LIKE
MODEL
Models are intended to closely represent business logic
entities and contain code that accesses and persists data.
CONTROLLER
Controllers are the command centers for mojits. They can
either do all of the work or delegate the work to models and/
or views.
VIEW
View files are called view templates in Mojito. View
templates can contain both HTML and templating tags/
expressions, such as Mustache or Handlebars, and are
rendered into markup that is outputted to the client.
WAIT! WHAT ABOUT DOM
BINDER
Allows event handlers to be attached to the mojit
DOM node communicate with other mojits on the page and
executes actions on the mojit that the binder is attached to
A REAL TUTORIAL
INSTALL
Pre-request
   Node.js
   npm
npm install mojito -g
CREATE A MOJITO APPLICATION
CREATE A MOJIT
DATA IN MODEL
CONTROLLER
VIEW
CONFIGURATION
 application.json




 routes.json
LET’S START IT!
RESULT
ARCHITECTURE
ARCHITECTURE
WHAT WE MISSED TODAY
•   Framework Mojits
•   Client side running context
•   Using Multiple Mojits
•   Detailed configuration
•   Extending Mojito
MORE ABOUT MOJITO
• http://developer.yahoo.com/cocktails/mojito/
• https://github.com/yahoo/mojito/
• http://developer.yahoo.com/forum/Yahoo-Mojito/
QUESTIONS?
PUTTING IT ALL TOGETHER
Previous talks
   YQL
   YUI
   Mojito

You can use all the above Yahoo! technologies to build a full
fledged web application.




                                                                41
YQL - GATHER DATA




                    42
YUI - PRESENT DATA




                     43
MOJITO - BUILD AN APP
     Mojito is based on YUI & NodeJS
     YUI has native YQL support




   Query data using YQL
   Add this to the model within your Mojit
  •Display the data using the Mojit view

http://developer.yahoo.com/cocktails/mojito/docs/code_exs/calling_yql.html




                                                                        44

Open Hack Taiwan 2012 - Mojito intro

Editor's Notes

  • #2 \n
  • #3 \n
  • #4 \n
  • #5 \n
  • #6 \n
  • #7 \n
  • #8 \n
  • #9 \n
  • #10 \n----- Meeting Notes (10/10/12 18:28) -----\ntable sorting\n----- Meeting Notes (10/11/12 18:06) -----\nmove client to this ppt\n
  • #11 \n
  • #12 \n
  • #13 \n
  • #14 \n
  • #15 \n
  • #16 \n
  • #17 Mojito can identify the calling device by examining the HTTP header User-Agent. You create custom views for different devices, and Mojito will render and serve the correct device-specific views.\n
  • #18 Mojito can identify the calling device by examining the HTTP header User-Agent. You create custom views for different devices, and Mojito will render and serve the correct device-specific views.\n
  • #19 Mojito can identify the calling device by examining the HTTP header User-Agent. You create custom views for different devices, and Mojito will render and serve the correct device-specific views.\n
  • #20 \n----- Meeting Notes (10/12/12 17:23) -----\nuse nodejs as web server\n
  • #21 \n
  • #22 \n
  • #23 Client requests for data are sent to the controller, which in turn fetches data from the model, renders views and passes the data to the client\n
  • #24 \n
  • #25 \n
  • #26 \n----- Meeting Notes (10/10/12 18:28) -----\nask if they know what is an template engine\n
  • #27 \n----- Meeting Notes (10/12/12 17:23) -----\nintroduce dom , different from view\n
  • #28 \n----- Meeting Notes (10/11/12 18:06) -----\nadd a dot before each item\n
  • #29 \n
  • #30 mojito is a module of nodejs\n----- Meeting Notes (10/12/12 17:23) -----\ncommand different from pre-request\n
  • #31 \n----- Meeting Notes (10/11/12 18:06) -----\nchange make to create\n
  • #32 \n----- Meeting Notes (10/10/12 18:28) -----\nhow to config to client and server run time\n
  • #33 \n
  • #34 \n
  • #35 \n
  • #36 In spec you can put the mojit name which you want to use inside.\n
  • #37 \n
  • #38 \n----- Meeting Notes (10/12/12 17:23) -----\nhello mojito\n
  • #39 \n----- Meeting Notes (10/12/12 17:37) -----\nput it early\n
  • #40 Add a real case run js in both side, Add which production is using mojito\n
  • #41 Mojito comes with the built-in utility mojits that make developing applications easier.\n
  • #42 \n
  • #43 \n----- Meeting Notes (10/10/12 18:28) -----\nintroduce if client side support js, we can run in client side ,if client side not support js, we will run the code in server\n
  • #44 \n
  • #45 \n
  • #46 \n
  • #47 \n