SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Destaque

Окна.Работа с окнами. Панель инструментов
Окна.Работа с окнами. Панель инструментовОкна.Работа с окнами. Панель инструментов
Окна.Работа с окнами. Панель инструментов
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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

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

Notas do Editor

  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