SlideShare une entreprise Scribd logo
1  sur  32
UiT widgets
DUG - CultuurNet Vlaanderen pt 2: 3 cases over het verspreiden
                van centrale data via Drupal

                    Leuven, 2012-10-11



Kristof Coomans (Statik) - kristof@statik.be - @KristofCoomans
About me
‣ 8 years PHP, majority OO
‣ 3 years Drupal
‣ Technical Lead at Statik


‣ Who are you?
UiT widgets

‣ What?
‣ Components
‣ How to code a new widget type
‣ Example: Twitter widget type
What?
What?

‣ extensible framework to add additional
  elements on any HTML-based website,
  independent of the underlying platform
‣ think: adds, Twitter widgets, Facebook
  social plugins
‣ embeddable chunks of JavaScript code
Components
Components
‣ core
 ‣ framework-independent OO PHP
   library: Cultuurnet_Widgets
 ‣ a lightweight JavaScript module
   building upon jQuery (in code
   snippets represented as ‘cn’)
‣ Drupal module implementing the
  framework-agnostic pieces:
  cul_widgets_server
Components
‣ Varnish caching reverse proxy
How to code a new
  widget type
Anatomy
‣ layout types containing layout
  areas
‣ widget types containing controls
‣ each of these components have
  their own PHP interface, we’ll
  focus today on:

  Cultuurnet_Widgets_Widget
Initial setup
‣ add a PHP class MyWidget which
  extends Cultuurnet_Widgets_Widget_
  AbstractWidget in mywidget.inc inside
  your own Drupal module
‣ instruct Drupal to register any PHP
  classes in mywidget.inc in its autoload
  registry, in mymodule.info:

  files[] = mywidget.inc
Initial setup
‣ let the widgets server know about your
  own widget type by implementing
  hook_cul_widget_types() in
  mymodule.module:
Available properties
‣ $this->id: unique numeric ID
‣ $this->config
  ‣ instance of
    Cultuurnet_Widgets_Config
  ‣ container of configuration values
  ‣ getConfigValue(), setConfigValue()
‣ ...
Configuration forms
‣ optionsCategories(): define # forms
  which will appear as tabs
‣ options(): FAPI-like callback
‣ optionsValidate(): FAPI-like validate
  callback
‣ optionsSubmit(): FAPI-like submit
  callback, this is the place to store
  configuration in $this->config
Lifecycle: phase 1
‣ initial JavaScript includes everything to
  load the necessary JavaScript
  dependencies, CSS, and content that
  doesn’t change over time


‣ render() method of your
  implementation of
  Cultuurnet_Widgets_Widget
Lifecycle: phase 1
‣ return an instance of
  Cultuurnet_Widgets_Result_Javascript
  Result
‣ add HTML/CSS: addHtml(), addCss()
‣ all CSS selectors will be adapted to
  target only elements inside your
  widget
‣ add additional JavaScript to start
  phase 2 of the lifecycle: addJs()
Lifecycle: phase 2
‣ load all dynamic content that
  changes over time, with JSONP
Lifecycle: phase 2
‣ JSONP as a cross-domain
  alternative to XMLHTTPRequest
Lifecycle: phase 2
‣ JSONP is handled by the JS module
‣ cn.callWidget() allows to call
  certain (we call them ‘exposed’)
  PHP methods on an instance of
  your Cultuurnet_Widgets_Widget
  implementation
‣ JavaScript properties are mapped
  to arguments of the PHP method
  (Reflection API)
Lifecycle: phase 2
‣ JavaScript:




‣ PHP:

  function like($eventId) { ... };
Lifecycle: phase 2
‣ which methods can be called this
  way?
‣ defined by implementation of
  isExposedMethod($name)
‣ return value of each method:

  an instance of
  Cultuurnet_Widgets_Result_JsonResult
Lifecycle: phase 2
‣ basic usage: just a container for any
  kind of variable we want to pass back
  to the client-side: setValue($value)
‣ available in data.value in the succes
  callback function
Lifecycle: phase 2
‣ what about loading private /
  sensitive data?
‣ think: UiTid
‣ widgets server does a HTTP
  refer(r)er check against a list of
  allowed domains
JS modules
‣ AMD
‣ mechanism to define modules
  such that the module and its
  dependencies can be
  asynchronously loaded
‣ different loader implementations
  available, we use RequireJS
JS modules
‣ basic module definition in bv.
  mymodule.js:




‣ to use the module:
JS modules
‣ to register JS modules with the
  widgets server in Drupal,
  implement
  hook_widgets_amd_modules():
Example: Twitter
  widget type
Questions?
Resources
‣ AMD: https://github.com/amdjs/
  amdjs-api/wiki/AMD
‣ source code (coming soon): https://
  github.com/statikbe
‣ slides: http://www.slideshare.net/
  KristofC

Contenu connexe

En vedette

Окна.Работа с окнами. Панель инструментов
Окна.Работа с окнами. Панель инструментовОкна.Работа с окнами. Панель инструментов
Окна.Работа с окнами. Панель инструментов
Lubov
 
Wedding Power Point
Wedding Power PointWedding Power Point
Wedding Power Point
guest47392f
 
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
ifPeople
 

En vedette (20)

Окна.Работа с окнами. Панель инструментов
Окна.Работа с окнами. Панель инструментовОкна.Работа с окнами. Панель инструментов
Окна.Работа с окнами. Панель инструментов
 
Cámara comienza a vender ya!
Cámara   comienza a vender ya!Cámara   comienza a vender ya!
Cámara comienza a vender ya!
 
Variables Everywhere
Variables EverywhereVariables Everywhere
Variables Everywhere
 
Wedding Power Point
Wedding Power PointWedding Power Point
Wedding Power Point
 
100928 town square presentation
100928 town square presentation100928 town square presentation
100928 town square presentation
 
Кульова блискавка
Кульова блискавкаКульова блискавка
Кульова блискавка
 
Hoja de chequeo según Algoritmo de Google 2016
Hoja de chequeo según Algoritmo de Google 2016Hoja de chequeo según Algoritmo de Google 2016
Hoja de chequeo según Algoritmo de Google 2016
 
Cuadernillo curso seo Prodetur Aznalcázar
Cuadernillo curso seo Prodetur AznalcázarCuadernillo curso seo Prodetur Aznalcázar
Cuadernillo curso seo Prodetur Aznalcázar
 
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
Open Source CMS + Salesforce Integration Showdown: Plone vs Drupal vs Joomla!
 
Tantas cousas que dicirte
Tantas cousas que dicirteTantas cousas que dicirte
Tantas cousas que dicirte
 
Os dez mandamentos verdes
Os dez mandamentos verdesOs dez mandamentos verdes
Os dez mandamentos verdes
 
Que hermosa te deu Dios, terra querida
Que hermosa te deu Dios, terra queridaQue hermosa te deu Dios, terra querida
Que hermosa te deu Dios, terra querida
 
Carta do xefe indio Seattle
Carta do xefe indio SeattleCarta do xefe indio Seattle
Carta do xefe indio Seattle
 
Ósos de muller
Ósos de mullerÓsos de muller
Ósos de muller
 
Leveraging the Web for More Effective Engagement: Alliance for Nonprofit Mana...
Leveraging the Web for More Effective Engagement: Alliance for Nonprofit Mana...Leveraging the Web for More Effective Engagement: Alliance for Nonprofit Mana...
Leveraging the Web for More Effective Engagement: Alliance for Nonprofit Mana...
 
More Than Just a Meeting Place: Leveraging online tools for action
More Than Just a Meeting Place: Leveraging online tools for actionMore Than Just a Meeting Place: Leveraging online tools for action
More Than Just a Meeting Place: Leveraging online tools for action
 
Writing for the Web
Writing for the WebWriting for the Web
Writing for the Web
 
Lúa
LúaLúa
Lúa
 
Social Media 101: Online Communication as Stakeholder Engagement
Social Media 101: Online Communication as Stakeholder EngagementSocial Media 101: Online Communication as Stakeholder Engagement
Social Media 101: Online Communication as Stakeholder Engagement
 
Introduction to Scrum
Introduction to ScrumIntroduction to Scrum
Introduction to Scrum
 

Similaire à UiT widgets

Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
Oro Inc.
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
Mahmoud Hamed Mahmoud
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
Fermin Galan
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
mwillmer
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
Bo-Yi Wu
 
Using advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint developmentUsing advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint development
sadomovalex
 

Similaire à UiT widgets (20)

MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Panmind at Ruby Social Club Milano
Panmind at Ruby Social Club MilanoPanmind at Ruby Social Club Milano
Panmind at Ruby Social Club Milano
 
YaJUG: What's new in GWT2
YaJUG: What's new in GWT2YaJUG: What's new in GWT2
YaJUG: What's new in GWT2
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Flex Daily Solutions @ FITC 2008
Flex Daily Solutions @ FITC 2008Flex Daily Solutions @ FITC 2008
Flex Daily Solutions @ FITC 2008
 
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalDependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functional
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84
 
ASP.NET Internals
ASP.NET InternalsASP.NET Internals
ASP.NET Internals
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
vite-en.pdf
vite-en.pdfvite-en.pdf
vite-en.pdf
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
 
Using advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint developmentUsing advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint development
 
From framework coupled code to #microservices through #DDD /by @codelytv
From framework coupled code to #microservices through #DDD /by @codelytvFrom framework coupled code to #microservices through #DDD /by @codelytv
From framework coupled code to #microservices through #DDD /by @codelytv
 
Visual C++ project model
Visual C++ project modelVisual C++ project model
Visual C++ project model
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
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
 

Dernier (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 

UiT widgets

  • 1. UiT widgets DUG - CultuurNet Vlaanderen pt 2: 3 cases over het verspreiden van centrale data via Drupal Leuven, 2012-10-11 Kristof Coomans (Statik) - kristof@statik.be - @KristofCoomans
  • 2. About me ‣ 8 years PHP, majority OO ‣ 3 years Drupal ‣ Technical Lead at Statik ‣ Who are you?
  • 3. UiT widgets ‣ What? ‣ Components ‣ How to code a new widget type ‣ Example: Twitter widget type
  • 5. What? ‣ extensible framework to add additional elements on any HTML-based website, independent of the underlying platform ‣ think: adds, Twitter widgets, Facebook social plugins ‣ embeddable chunks of JavaScript code
  • 7. Components ‣ core ‣ framework-independent OO PHP library: Cultuurnet_Widgets ‣ a lightweight JavaScript module building upon jQuery (in code snippets represented as ‘cn’) ‣ Drupal module implementing the framework-agnostic pieces: cul_widgets_server
  • 9. How to code a new widget type
  • 10. Anatomy ‣ layout types containing layout areas ‣ widget types containing controls ‣ each of these components have their own PHP interface, we’ll focus today on: Cultuurnet_Widgets_Widget
  • 11.
  • 12. Initial setup ‣ add a PHP class MyWidget which extends Cultuurnet_Widgets_Widget_ AbstractWidget in mywidget.inc inside your own Drupal module ‣ instruct Drupal to register any PHP classes in mywidget.inc in its autoload registry, in mymodule.info: files[] = mywidget.inc
  • 13. Initial setup ‣ let the widgets server know about your own widget type by implementing hook_cul_widget_types() in mymodule.module:
  • 14. Available properties ‣ $this->id: unique numeric ID ‣ $this->config ‣ instance of Cultuurnet_Widgets_Config ‣ container of configuration values ‣ getConfigValue(), setConfigValue() ‣ ...
  • 15. Configuration forms ‣ optionsCategories(): define # forms which will appear as tabs ‣ options(): FAPI-like callback ‣ optionsValidate(): FAPI-like validate callback ‣ optionsSubmit(): FAPI-like submit callback, this is the place to store configuration in $this->config
  • 16. Lifecycle: phase 1 ‣ initial JavaScript includes everything to load the necessary JavaScript dependencies, CSS, and content that doesn’t change over time ‣ render() method of your implementation of Cultuurnet_Widgets_Widget
  • 17. Lifecycle: phase 1 ‣ return an instance of Cultuurnet_Widgets_Result_Javascript Result ‣ add HTML/CSS: addHtml(), addCss() ‣ all CSS selectors will be adapted to target only elements inside your widget ‣ add additional JavaScript to start phase 2 of the lifecycle: addJs()
  • 18. Lifecycle: phase 2 ‣ load all dynamic content that changes over time, with JSONP
  • 19.
  • 20.
  • 21. Lifecycle: phase 2 ‣ JSONP as a cross-domain alternative to XMLHTTPRequest
  • 22. Lifecycle: phase 2 ‣ JSONP is handled by the JS module ‣ cn.callWidget() allows to call certain (we call them ‘exposed’) PHP methods on an instance of your Cultuurnet_Widgets_Widget implementation ‣ JavaScript properties are mapped to arguments of the PHP method (Reflection API)
  • 23. Lifecycle: phase 2 ‣ JavaScript: ‣ PHP: function like($eventId) { ... };
  • 24. Lifecycle: phase 2 ‣ which methods can be called this way? ‣ defined by implementation of isExposedMethod($name) ‣ return value of each method: an instance of Cultuurnet_Widgets_Result_JsonResult
  • 25. Lifecycle: phase 2 ‣ basic usage: just a container for any kind of variable we want to pass back to the client-side: setValue($value) ‣ available in data.value in the succes callback function
  • 26. Lifecycle: phase 2 ‣ what about loading private / sensitive data? ‣ think: UiTid ‣ widgets server does a HTTP refer(r)er check against a list of allowed domains
  • 27. JS modules ‣ AMD ‣ mechanism to define modules such that the module and its dependencies can be asynchronously loaded ‣ different loader implementations available, we use RequireJS
  • 28. JS modules ‣ basic module definition in bv. mymodule.js: ‣ to use the module:
  • 29. JS modules ‣ to register JS modules with the widgets server in Drupal, implement hook_widgets_amd_modules():
  • 30. Example: Twitter widget type
  • 32. Resources ‣ AMD: https://github.com/amdjs/ amdjs-api/wiki/AMD ‣ source code (coming soon): https:// github.com/statikbe ‣ slides: http://www.slideshare.net/ KristofC

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n