SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
"Modern" Javascript-ing
        Plone
... how to drink less while doing
       Javascript in Plone.
            Rok Garbas / @garbas
Products.ResourcesRegistry
        orders resources,
           minimizes,
          groups them.
Nothing wrong with it,
        right?
              Hard to debug
     Hard to keep resources up to date.
 Nothing / Nada / Niente of our JS is tested.
        Tricky for addons to plugin.
Seriously...

We need to get out shit
      together!
PLOG pledge
                On my honor, I will try,
To serve Plone community and worship **all** Javascript
                         Gods,
 To write Modular, Tested, Documented Javascript code
           And to live by the Girl Scout Law.
Modular
Javascript
AMD vs CommonJS
        Scope
     Remote/Local
      Asynchrony
AMD
// define wrapper
define(
    // dependencies are specified in advance.
    ['modA', 'modB'],
    // the module is declared within a definition function.
    // dependencies are mapped into function parameters.
    function (modA, modB) {
        // inside here is the module's code.
        // the module is exported to the outside world via the
        // the definition function's returned value.
        var modC = modA + modB;
        return modC;
    }
);

                            CommonJS
// dependencies specified as needed
var modC = require('modC');

// the module is exported by decorating the `exports` free variable.
exports.foo = require('modA') + require('modB');
ResuireJS
 Paths for network/CDN resources.
         Minimize resources.
Optimizing into one lite JavaScript file.
Keeping
resources up to
     date
Jam
                      Manage dependencies
                        "npm" for browser
              Really nice integration with RequireJS
$   jam   install backbone
$   jam   upgrade
$   jam   compile compiled.min.js
$   jam   compile --almond compiled-standalone.min.js
Testing
Javascript
Test Frameworks
      QUnit
     Jasmine
      Buster
      Mocha
Test Assertions
expect.js - Minimalistic BDD-style assertions for Node.JS
            and the class="fragment"browser.
       should.js - BDD style assertions for node.js
 better-assert - c-style assert() for nodejs, reporting the
          expression string as the error message
                     Buster, Jasmine -
My assertion library choice
Chai is a BDD / TDD assertion library for node and the
                     browser.
 chai.should();
 foo.should.be.a('string');
 foo.should.equal('bar');
 foo.should.have.length(3);
 tea.should.have.property('flavors').with.length(3);

 var expect = chai.expect;
 expect(foo).to.be.a('string');
 expect(foo).to.equal('bar');
 expect(foo).to.have.length(3);
 expect(tea).to.have.property('flavors').with.length(3);

 var assert = chai.assert;
 assert.typeOf(foo, 'string');
 assert.equal(foo, 'bar');
 assert.lengthOf(foo, 3)
 assert.property(tea, 'favors');
 assert.lengthOf(tea.flavors, 3);
Test runners
QUnit, Jasmine, Buster, Mocha
          TEST'EM
Mockup
project

Mais conteúdo relacionado

Mais procurados

LCA 2012: High Availability Sprint
LCA 2012: High Availability SprintLCA 2012: High Availability Sprint
LCA 2012: High Availability Sprint
hastexo
 
Testing nodejs apps
Testing nodejs appsTesting nodejs apps
Testing nodejs apps
felipefsilva
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
Jan Sifra
 

Mais procurados (20)

Browserify
BrowserifyBrowserify
Browserify
 
JavaScript Basics with baby steps
JavaScript Basics with baby stepsJavaScript Basics with baby steps
JavaScript Basics with baby steps
 
Lightning Talk: Making JS better with Browserify
Lightning Talk: Making JS better with BrowserifyLightning Talk: Making JS better with Browserify
Lightning Talk: Making JS better with Browserify
 
LCA 2012: High Availability Sprint
LCA 2012: High Availability SprintLCA 2012: High Availability Sprint
LCA 2012: High Availability Sprint
 
JUDCon 2010 Boston : TorqueBox
JUDCon 2010 Boston : TorqueBoxJUDCon 2010 Boston : TorqueBox
JUDCon 2010 Boston : TorqueBox
 
Node workShop Basic
Node workShop BasicNode workShop Basic
Node workShop Basic
 
Testing nodejs apps
Testing nodejs appsTesting nodejs apps
Testing nodejs apps
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB Shell
 
NodeJS
NodeJSNodeJS
NodeJS
 
Javascript Bundling and modularization
Javascript Bundling and modularizationJavascript Bundling and modularization
Javascript Bundling and modularization
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날
 
Overview: How to Measure your WebApp
Overview: How to Measure your WebAppOverview: How to Measure your WebApp
Overview: How to Measure your WebApp
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
MongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームMongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲーム
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 
On Demand Javascript - Scalecamp 2009
On Demand Javascript - Scalecamp 2009On Demand Javascript - Scalecamp 2009
On Demand Javascript - Scalecamp 2009
 
Coffeescript intro
Coffeescript   introCoffeescript   intro
Coffeescript intro
 
JUDCon 2010 Boston : BoxGrinder
JUDCon 2010 Boston : BoxGrinderJUDCon 2010 Boston : BoxGrinder
JUDCon 2010 Boston : BoxGrinder
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torquebox
 
Ultra fast web development with sinatra
Ultra fast web development with sinatraUltra fast web development with sinatra
Ultra fast web development with sinatra
 

Destaque

Theming Plone with Deliverance
Theming Plone with DeliveranceTheming Plone with Deliverance
Theming Plone with Deliverance
Rok Garbas
 
Migrations With Transmogrifier
Migrations With TransmogrifierMigrations With Transmogrifier
Migrations With Transmogrifier
Rok Garbas
 

Destaque (9)

Guillaume St Etienne : Services et Contrats Agiles
Guillaume St Etienne : Services et Contrats AgilesGuillaume St Etienne : Services et Contrats Agiles
Guillaume St Etienne : Services et Contrats Agiles
 
Theming Plone with Deliverance
Theming Plone with DeliveranceTheming Plone with Deliverance
Theming Plone with Deliverance
 
Migrations With Transmogrifier
Migrations With TransmogrifierMigrations With Transmogrifier
Migrations With Transmogrifier
 
Transmogrifier: content migration and time traveling
Transmogrifier: content migration and time travelingTransmogrifier: content migration and time traveling
Transmogrifier: content migration and time traveling
 
Ubuntuday 2014
Ubuntuday 2014Ubuntuday 2014
Ubuntuday 2014
 
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
 
Aspek hukum dalam ekonomi 'monopoli dan persaingan usaha tidak sehat'
Aspek hukum dalam ekonomi 'monopoli dan persaingan usaha tidak sehat'Aspek hukum dalam ekonomi 'monopoli dan persaingan usaha tidak sehat'
Aspek hukum dalam ekonomi 'monopoli dan persaingan usaha tidak sehat'
 
The Near Future of CSS
The Near Future of CSSThe Near Future of CSS
The Near Future of CSS
 
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
 

Semelhante a PLOG - Modern Javascripting with Plone

Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
Eric Bottard
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
Jesse Vincent
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
MongoDB
 
Артем Маркушев - JavaScript
Артем Маркушев - JavaScriptАртем Маркушев - JavaScript
Артем Маркушев - JavaScript
DataArt
 
Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10
Sean Hull
 
PHP Development With MongoDB
PHP Development With MongoDBPHP Development With MongoDB
PHP Development With MongoDB
Fitz Agard
 
PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)
MongoSF
 

Semelhante a PLOG - Modern Javascripting with Plone (20)

Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript Conference
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous Task
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Артем Маркушев - JavaScript
Артем Маркушев - JavaScriptАртем Маркушев - JavaScript
Артем Маркушев - JavaScript
 
Mlocjs buzdin
Mlocjs buzdinMlocjs buzdin
Mlocjs buzdin
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Rails with mongodb
Rails with mongodbRails with mongodb
Rails with mongodb
 
Python + GDB = Javaデバッガ
Python + GDB = JavaデバッガPython + GDB = Javaデバッガ
Python + GDB = Javaデバッガ
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundler
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
 
Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10
 
PHP Development With MongoDB
PHP Development With MongoDBPHP Development With MongoDB
PHP Development With MongoDB
 
PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)
 

Último

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Último (20)

ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 

PLOG - Modern Javascripting with Plone

  • 1. "Modern" Javascript-ing Plone ... how to drink less while doing Javascript in Plone. Rok Garbas / @garbas
  • 2. Products.ResourcesRegistry orders resources, minimizes, groups them.
  • 3. Nothing wrong with it, right? Hard to debug Hard to keep resources up to date. Nothing / Nada / Niente of our JS is tested. Tricky for addons to plugin.
  • 4. Seriously... We need to get out shit together!
  • 5. PLOG pledge On my honor, I will try, To serve Plone community and worship **all** Javascript Gods, To write Modular, Tested, Documented Javascript code And to live by the Girl Scout Law.
  • 7. AMD vs CommonJS Scope Remote/Local Asynchrony
  • 8. AMD // define wrapper define( // dependencies are specified in advance. ['modA', 'modB'], // the module is declared within a definition function. // dependencies are mapped into function parameters. function (modA, modB) { // inside here is the module's code. // the module is exported to the outside world via the // the definition function's returned value. var modC = modA + modB; return modC; } ); CommonJS // dependencies specified as needed var modC = require('modC'); // the module is exported by decorating the `exports` free variable. exports.foo = require('modA') + require('modB');
  • 9. ResuireJS Paths for network/CDN resources. Minimize resources. Optimizing into one lite JavaScript file.
  • 11. Jam Manage dependencies "npm" for browser Really nice integration with RequireJS $ jam install backbone $ jam upgrade $ jam compile compiled.min.js $ jam compile --almond compiled-standalone.min.js
  • 13. Test Frameworks QUnit Jasmine Buster Mocha
  • 14. Test Assertions expect.js - Minimalistic BDD-style assertions for Node.JS and the class="fragment"browser. should.js - BDD style assertions for node.js better-assert - c-style assert() for nodejs, reporting the expression string as the error message Buster, Jasmine -
  • 15. My assertion library choice Chai is a BDD / TDD assertion library for node and the browser. chai.should(); foo.should.be.a('string'); foo.should.equal('bar'); foo.should.have.length(3); tea.should.have.property('flavors').with.length(3); var expect = chai.expect; expect(foo).to.be.a('string'); expect(foo).to.equal('bar'); expect(foo).to.have.length(3); expect(tea).to.have.property('flavors').with.length(3); var assert = chai.assert; assert.typeOf(foo, 'string'); assert.equal(foo, 'bar'); assert.lengthOf(foo, 3) assert.property(tea, 'favors'); assert.lengthOf(tea.flavors, 3);
  • 16. Test runners QUnit, Jasmine, Buster, Mocha TEST'EM