SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Mojito training
Keshavaprasad B S
● What is Mojito?
● Mojito Architecture
● Installation & Setup
● Create a simple weather app
○ Understand application components
○ Deep dive into few of them
● Create a composite mojit
● Lazy Mojit
Agenda
● Mojito is a node module and hence benefits from the speed and
scalability on Node.js. It uses express package of Node.js.
● MVC framework built on YUI3
● Mojito offers:
○ Library for internationalization & localization
○ Device specific presentation
○ Ability to run the same code on either client or the server
○ Integrated unit testing
What is Mojito?
● Designed with the goal of running
in multiple runtime environments
and supporting online and offline
experiences.
○ Mobile browser: supports
HTML-based online
experience; may also support
an HTML5-based offline
experience
○ Desktop browser: assumed to
be always connected; supports
HTML-based online
experience
○ Native client: deployed as
packaged applications,
wrapping native chrome
around an HTML5-based
experience
Mojito architecture
1. Download node from http://nodejs.org.
2. Do npm install mojito
3. alias mojito=~/node_modules/mojito/bin/mojito
4. mojito version
Installation and setup
● Basic unit of composition and reuse in a Mojito application
● Why Mojit? : Module + Widget = Mojit
● Path: <app_name>/mojits/<mojit_name>
● Mojit components:
○ Models
○ Controller
○ Binders
○ View files
● Example: https://github.com/kbsbng/mojito-
examples/tree/master/HelloWorld/mojits/helloWorld
Application components: mojit
● Represent business logic entities and contain code that accesses
and persists data
● Can be shared across mojits
● Path: <app_name>/mojits/<mojit_name>/models.
● Naming convention:
○ For file name: {model_name}.{affinity}.js, where affinity is
server, client or common. For example, flickr.server.js
○ For the YUI module name: {mojit_name}Model
{Model_name}. For example, in photos/models/flickr.
server.js, use the YUI module name photosModelFlickr.
○ For the default model.server.js, use the YUI module name
{mojit_name}Model.
● Example: https://github.com/kbsbng/mojito-
examples/blob/master/HelloWorld/mojits/helloWorld/models/foo.
server.js
Application components: model
● Path: <app_name>/mojits/<mojit_name>/controller.
server.js.
● Naming convention:
○ For the file name: controller.{affinity}.js, where
affinity is common, server, or client.
○ For the YUI module name: use the mojit name.
● Example: https://github.com/kbsbng/mojito-
examples/blob/master/HelloWorld/mojits/helloWorld/controller.
server.js
● Controller <=> Model communication:
○ through ActionContext: ac.models.get
('{model_name}').{model_function}
● Passing data to the view.
○ through ActionContext: ac.done(data).
Application components: controller
● Path:
<app_name>/mojits/<mojit_name>/views/<view_file>
● Naming convention: {controller_function}.[{selector}].
{rendering_engine}.html.
Sample names: index.hb.html, photos.iphone.jade.html,
landing.android.ejs.html.
● Currently supporting templating engines:
○ Mustache
○ Handlebars (default).
● You can fairly easily add support to other templating engines like
jade and ejs.
● Example: https://github.com/kbsbng/mojito-
examples/blob/master/HelloWorld/mojits/helloWorld/binders/index.js
Application components: View
● Runs only on the client side
● Binders can
○ Attach event handlers to the mojit's DOM node
○ Communicate with other mojits on the page
○ Execute actions on the mojit that the binder is attached to
○ Refresh the mojit
● Example: https://github.com/kbsbng/mojito-
examples/blob/master/SimpleWeatherApp/mojits/Weather/binders/i
ndex.js
Application components: binder
Check the code at https://github.com/kbsbng/mojito-
examples/tree/master/SimpleWeatherApp. It:
● Creates a simple weather app to display temperature of Bangalore
by doing YQL query: "select * from weather.forecast where
woeid=2295420"
● Then, see how to add a forecast action to this module to show the
forecast.
Create a simple weather app
● https://github.com/kbsbng/mojito-
examples/blob/master/SimpleWeatherApp/routes.json
Deep dive: routing
● Helpers:
○ For mojit instance, use ac.helpers.set in controller. Examples:
■ https://github.com/kbsbng/mojito-
examples/blob/master/DemoHandlebarHelpers/mojits/Dem
o/controller.server.js
■ https://github.com/kbsbng/mojito-
examples/blob/master/DemoHandlebarHelpers/mojits/Dem
o/views/index.hb.html
○ For global use, use ac.helpers.expose in controller.
● Mojito supplied data:
○ {{mojit_view_id}}
○ {{mojit_assets}} - assets dir of the mojit
Deep dive: template and View Engine
● Example: https://github.com/kbsbng/mojito-
examples/tree/master/SimpleWeatherApp/mojits/Weather
Deep dive: Controller actions, action <=>
view mapping
● Using mojitProxy.invoke:
○ https://github.com/kbsbng/mojito-
examples/blob/master/SimpleWeatherApp/mojits/Weather/binders/index.js
Deep dive: Binder tunneling
● mojito-params-addon: http://developer.yahoo.
com/cocktails/mojito/api/classes/Params.common.html
● mojito-cookies-addon: http://developer.yahoo.
com/cocktails/mojito/api/classes/Cookie.server.html
● mojito-url-addon: http://developer.yahoo.
com/cocktails/mojito/api/classes/Url.common.html
● mojito-assets-addon: http://developer.yahoo.
com/cocktails/mojito/api/classes/Assets.common.html
● mojito-composite-addon: http://developer.yahoo.
com/cocktails/mojito/api/classes/Composite.common.html
● mojito-config-addon: http://developer.yahoo.
com/cocktails/mojito/api/classes/Config.common.html
Built-in components: Addons
● Composite mojits
○ https://github.com/kbsbng/mojito-
examples/blob/master/DemoCompositeMojitApp/application.
json
Built-in components: Mojits:
HTMLFrameMojit
● To use lazy mojit, app should:
○ create a top-level mojit instance of type HTMLFrameMojit
○ deploy the mojit instance of type HTMLFrameMojit to the client
("deploy": true)
○ create a container mojit that has children mojit instances
("children": { ... })
○ defer the dispatch of the mojit instance that will be lazily loaded
("defer": true)
Built-in components: Mojits: LazyMojit
● Defaults.json:
○ defaults for each mojit.
○ Can be overridden by parent mojit
○ Configurable based on context
● Definition.json:
○ metadata for a mojit
○ Configurable based on context
Configuration: application.json, defaults.
json, definition.json
● Launch an app using a context using --context "environment:
<context_name>"
Configuration: launch an app using a
context
● yui.config.debug (default: true)
● yui.config.logLevel (default: debug)
● yui.config.logLevelOrder: (default: ['debug', 'mojito', 'info', 'warn',
'error', 'none'] )
Configuration: logging
● Path:
○ App level: {application_name}/assets
○ Mojit level: {application_name}/mojits/{mojit_name}/assets
● Accessing assets:
○ /static/{application_name}/assets/{asset_file}
○ /static/{mojit_name}/assets/{asset_file}
● Using assets addon
Assets
● http://developer.yahoo.com/cocktails/mojito/docs/
Useful links
Thanks!

Weitere ähnliche Inhalte

Ähnlich wie Mojito

GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers WorkshopJody Garnett
 
Using PHP with IBM Bluemix
Using PHP with IBM BluemixUsing PHP with IBM Bluemix
Using PHP with IBM Bluemixvvaswani
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptHoracio Gonzalez
 
Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Anuchit Chalothorn
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptHoracio Gonzalez
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
[JogjaJS] Single Page Application nganggo Angular.js
[JogjaJS] Single Page Application nganggo Angular.js [JogjaJS] Single Page Application nganggo Angular.js
[JogjaJS] Single Page Application nganggo Angular.js Yanuar W
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoAhmed Salama
 
Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)
Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)
Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)Igalia
 
Ahmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDAhmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDShekh Muenuddeen
 
Integrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperationsIntegrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperationsLuca Mazzaferro
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for EveryoneGLC Networks
 
CI CD Daridabad MuleSoft meetup
CI CD Daridabad MuleSoft meetupCI CD Daridabad MuleSoft meetup
CI CD Daridabad MuleSoft meetupAmit Singh
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoKnoldus Inc.
 
GT-Mconf - Transfer of Technology Course
GT-Mconf - Transfer of Technology CourseGT-Mconf - Transfer of Technology Course
GT-Mconf - Transfer of Technology Coursemconf
 
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Ido Green
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...David Amend
 

Ähnlich wie Mojito (20)

GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers Workshop
 
Using PHP with IBM Bluemix
Using PHP with IBM BluemixUsing PHP with IBM Bluemix
Using PHP with IBM Bluemix
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
 
Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020Flutter workshop @ bang saen 2020
Flutter workshop @ bang saen 2020
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Code-Hub
Code-HubCode-Hub
Code-Hub
 
[JogjaJS] Single Page Application nganggo Angular.js
[JogjaJS] Single Page Application nganggo Angular.js [JogjaJS] Single Page Application nganggo Angular.js
[JogjaJS] Single Page Application nganggo Angular.js
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)
Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)
Improving Chromium's code health: Onion Soup and beyond (BlinkOn 11)
 
CI/CD with Bitbucket pipelines
CI/CD with Bitbucket pipelinesCI/CD with Bitbucket pipelines
CI/CD with Bitbucket pipelines
 
Ahmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDAhmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICD
 
Integrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperationsIntegrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperations
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for Everyone
 
CI CD Daridabad MuleSoft meetup
CI CD Daridabad MuleSoft meetupCI CD Daridabad MuleSoft meetup
CI CD Daridabad MuleSoft meetup
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
GT-Mconf - Transfer of Technology Course
GT-Mconf - Transfer of Technology CourseGT-Mconf - Transfer of Technology Course
GT-Mconf - Transfer of Technology Course
 
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
 

Kürzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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 TerraformAndrey Devyatkin
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
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...DianaGray10
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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?Igalia
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Mojito

  • 2. ● What is Mojito? ● Mojito Architecture ● Installation & Setup ● Create a simple weather app ○ Understand application components ○ Deep dive into few of them ● Create a composite mojit ● Lazy Mojit Agenda
  • 3. ● Mojito is a node module and hence benefits from the speed and scalability on Node.js. It uses express package of Node.js. ● MVC framework built on YUI3 ● Mojito offers: ○ Library for internationalization & localization ○ Device specific presentation ○ Ability to run the same code on either client or the server ○ Integrated unit testing What is Mojito?
  • 4. ● Designed with the goal of running in multiple runtime environments and supporting online and offline experiences. ○ Mobile browser: supports HTML-based online experience; may also support an HTML5-based offline experience ○ Desktop browser: assumed to be always connected; supports HTML-based online experience ○ Native client: deployed as packaged applications, wrapping native chrome around an HTML5-based experience Mojito architecture
  • 5. 1. Download node from http://nodejs.org. 2. Do npm install mojito 3. alias mojito=~/node_modules/mojito/bin/mojito 4. mojito version Installation and setup
  • 6. ● Basic unit of composition and reuse in a Mojito application ● Why Mojit? : Module + Widget = Mojit ● Path: <app_name>/mojits/<mojit_name> ● Mojit components: ○ Models ○ Controller ○ Binders ○ View files ● Example: https://github.com/kbsbng/mojito- examples/tree/master/HelloWorld/mojits/helloWorld Application components: mojit
  • 7. ● Represent business logic entities and contain code that accesses and persists data ● Can be shared across mojits ● Path: <app_name>/mojits/<mojit_name>/models. ● Naming convention: ○ For file name: {model_name}.{affinity}.js, where affinity is server, client or common. For example, flickr.server.js ○ For the YUI module name: {mojit_name}Model {Model_name}. For example, in photos/models/flickr. server.js, use the YUI module name photosModelFlickr. ○ For the default model.server.js, use the YUI module name {mojit_name}Model. ● Example: https://github.com/kbsbng/mojito- examples/blob/master/HelloWorld/mojits/helloWorld/models/foo. server.js Application components: model
  • 8. ● Path: <app_name>/mojits/<mojit_name>/controller. server.js. ● Naming convention: ○ For the file name: controller.{affinity}.js, where affinity is common, server, or client. ○ For the YUI module name: use the mojit name. ● Example: https://github.com/kbsbng/mojito- examples/blob/master/HelloWorld/mojits/helloWorld/controller. server.js ● Controller <=> Model communication: ○ through ActionContext: ac.models.get ('{model_name}').{model_function} ● Passing data to the view. ○ through ActionContext: ac.done(data). Application components: controller
  • 9. ● Path: <app_name>/mojits/<mojit_name>/views/<view_file> ● Naming convention: {controller_function}.[{selector}]. {rendering_engine}.html. Sample names: index.hb.html, photos.iphone.jade.html, landing.android.ejs.html. ● Currently supporting templating engines: ○ Mustache ○ Handlebars (default). ● You can fairly easily add support to other templating engines like jade and ejs. ● Example: https://github.com/kbsbng/mojito- examples/blob/master/HelloWorld/mojits/helloWorld/binders/index.js Application components: View
  • 10. ● Runs only on the client side ● Binders can ○ Attach event handlers to the mojit's DOM node ○ Communicate with other mojits on the page ○ Execute actions on the mojit that the binder is attached to ○ Refresh the mojit ● Example: https://github.com/kbsbng/mojito- examples/blob/master/SimpleWeatherApp/mojits/Weather/binders/i ndex.js Application components: binder
  • 11. Check the code at https://github.com/kbsbng/mojito- examples/tree/master/SimpleWeatherApp. It: ● Creates a simple weather app to display temperature of Bangalore by doing YQL query: "select * from weather.forecast where woeid=2295420" ● Then, see how to add a forecast action to this module to show the forecast. Create a simple weather app
  • 13. ● Helpers: ○ For mojit instance, use ac.helpers.set in controller. Examples: ■ https://github.com/kbsbng/mojito- examples/blob/master/DemoHandlebarHelpers/mojits/Dem o/controller.server.js ■ https://github.com/kbsbng/mojito- examples/blob/master/DemoHandlebarHelpers/mojits/Dem o/views/index.hb.html ○ For global use, use ac.helpers.expose in controller. ● Mojito supplied data: ○ {{mojit_view_id}} ○ {{mojit_assets}} - assets dir of the mojit Deep dive: template and View Engine
  • 15. ● Using mojitProxy.invoke: ○ https://github.com/kbsbng/mojito- examples/blob/master/SimpleWeatherApp/mojits/Weather/binders/index.js Deep dive: Binder tunneling
  • 16. ● mojito-params-addon: http://developer.yahoo. com/cocktails/mojito/api/classes/Params.common.html ● mojito-cookies-addon: http://developer.yahoo. com/cocktails/mojito/api/classes/Cookie.server.html ● mojito-url-addon: http://developer.yahoo. com/cocktails/mojito/api/classes/Url.common.html ● mojito-assets-addon: http://developer.yahoo. com/cocktails/mojito/api/classes/Assets.common.html ● mojito-composite-addon: http://developer.yahoo. com/cocktails/mojito/api/classes/Composite.common.html ● mojito-config-addon: http://developer.yahoo. com/cocktails/mojito/api/classes/Config.common.html Built-in components: Addons
  • 17. ● Composite mojits ○ https://github.com/kbsbng/mojito- examples/blob/master/DemoCompositeMojitApp/application. json Built-in components: Mojits: HTMLFrameMojit
  • 18. ● To use lazy mojit, app should: ○ create a top-level mojit instance of type HTMLFrameMojit ○ deploy the mojit instance of type HTMLFrameMojit to the client ("deploy": true) ○ create a container mojit that has children mojit instances ("children": { ... }) ○ defer the dispatch of the mojit instance that will be lazily loaded ("defer": true) Built-in components: Mojits: LazyMojit
  • 19. ● Defaults.json: ○ defaults for each mojit. ○ Can be overridden by parent mojit ○ Configurable based on context ● Definition.json: ○ metadata for a mojit ○ Configurable based on context Configuration: application.json, defaults. json, definition.json
  • 20. ● Launch an app using a context using --context "environment: <context_name>" Configuration: launch an app using a context
  • 21. ● yui.config.debug (default: true) ● yui.config.logLevel (default: debug) ● yui.config.logLevelOrder: (default: ['debug', 'mojito', 'info', 'warn', 'error', 'none'] ) Configuration: logging
  • 22. ● Path: ○ App level: {application_name}/assets ○ Mojit level: {application_name}/mojits/{mojit_name}/assets ● Accessing assets: ○ /static/{application_name}/assets/{asset_file} ○ /static/{mojit_name}/assets/{asset_file} ● Using assets addon Assets