SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Lets Build Some Widgets!
Anatomy of a Widget
•   Config.xml <- W3C Widgets P&C Spec
•   icon.png
•   index.html <- HTML start file
•   JavaScript code, CSS

• Zip it up, change ext to .wgt, and you’re
  done
Widget metadata
•   Id
•   Height, Width
•   Name
•   Description
•   Version
•   Features
•   Author info
•   License
A Silly Example: config.xml
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
   id="http://www.getwookie.org/widgets/tea"
   version="1.0” height="150” width="125">
  <name>Tea</name>
  <description>A silly Tea widget</description>
   <author>Scott Wilson</author>
</widget>
A Silly Example: index.html
<html>
  <body>
     <img src="tea.jpg" />
     <p>Time for a break, mate</p>
  </body>
</html>
Make your own basic widget
1.   Make an index.html file
2.   Make a config.xml file
3.   Zip them up, and change suffix to “.wgt”
4.   Upload to a wookie server
Uploading
•   Go to http://192.168.2.161/wookie
•   Click “admin”
•   Login with java/java
•   Click “add new widget”
•   Find your .wgt file
•   OK!
Previewing a widget
•   Go to 192.168.2.161:8080/wookie
•   Click “View Widget Gallery”
•   Click the “demo” link under your widget
•   Your widget will show
Preferences
• You can store preferences for an instance of
  a widget using:

widget.preferences.setItem(“key”, “value”)
widget.preferences.getItem(“key”)
Collaborative Widgets
• State and Participants

• State is shared across widgets with the same
  IRI in the same shared context.
• State is propagated to related widgets using
  an event callback
• State is set by submitting deltas
State example
wave.setStateCallback(stateUpdated);

stateUpdated = function(){
 var keys = wave.getState().getKeys();
 for (var i = 0; i < keys.length; i++) {
   alert(wave.getState().get(keys[i]));
 }
};

wave.getState().submitValue(“key”, “value”);
Participants
• Register callbacks with:
  wave.setParticipantCallback(myfunction);

• Methods:
   – getViewer() - get the current user
   – getParticipants() - get map of all participants

• Model:
   – getId(), getDisplayName(), getThumbnailUrl()
Making a collaborative app
•   This requires some more planning

1. Draw up a design
2. Create a working test page
3. Implement models, action handlers and
   event handlers
4. Create the config.xml, icon.png, zip it up
   and run it
Design
• Start with the view - what the widget looks
  like
• Create the model - what are the objects in
  the state model?
• Add the actions - how you interact with it
• Wire it all up…
Prototyping
• Make a regular html page to test out your
  view. Populate it with fake model, and don’t
  wire up the actions yet
• You can reuse this for the real widget - just
  take out your fake state info sections
Implementing
• Create a “Model” object for your state
  model
• Create a “Controller” object, and a method
  in it for each action
• Register the participant and state event
  handlers with an “update view” method that
  populates the view when running
Models
•       Models can be implemented in typical “bean” fashion
•       Save/Find methods need to access wave state
•       Can use JSON (e.g. with json.js) or just plain strings for storage

    function Task(id,name,status,assigned){
      this.task_id = id;
      this.name = name;
      this.status = status;
      this.assigned_to = assigned;
    }
    Task.prototype.save = function(){
    wave.getState().submitValue(this.task_id, JSON.stringify(this));
    }
Static model methods
Task.create = function(json){
      var obj = JSON.parse(json);
     var task = new Task(obj.task_id,
      obj.name,obj.status,obj.assigned_to);
    return task;
                                                                   • Typically need
}
                                                                     methods to turn state
Task.find = function(task_id){
    var keys = wave.getState().getKeys();
    for (var i = 0; i < keys.length; i++) {
                                                                     strings back into
       var key = keys[i];
       if (key == task_id){
                                                                     model instances
          return Task.create(task_id, wave.getState().get(key));

    }
       }                                                           • Also finder methods to
}
    return null;
                                                                     get a particular model
Task.findAll = function(){                                           object
  var tasks = {};
     var keys = wave.getState().getKeys();
     for (var i = 0; i < keys.length; i++) {                       • This isn’t the only way
     var key = keys[i];
     var task = Task.create(key, wave.getState().get(key));
     tasks[key] = task;
                                                                     to do this, but is an
  }
  return tasks;
                                                                     OK pattern
}
Controllers
/**
 * The Controller object
 * This is used to wire up the view and model with actions
                                                             • Methods for each
 */
var Controller = {
                                                               action, making
    // Action handlers                                         changes to the model
    // Toggle task state between completed and to-do
    toggleTask: function(task_id){
                                                             • You usually don’t
    },
                                                               need to do any code
    // Create a new task
    newTask: function(){
    },
                                                               that interacts with
    // Abandon task for someone else to do
                                                               HTML, as the event
    abandonTask: function(task_id){
    },                                                         handlers should do
    // Claim a task (assign to self)
    claimTask: function(task_id){
                                                               that
    }
}
Event Handlers
// Update the view when state has been updated               These fire whenever the state or participants
   stateUpdated: function(){                                    are updated (e.g. by another instance).
      var tasks = Task.findAll();
      if (tasks && tasks != null){
         var tasklist = "";                                  Event handlers need to be registered like so:
         for (key in tasks) {
            var task = tasks[key];                           wave.setStateCallback(Controller.stateUpdated);
                                                             wave.setParticipantCallback(Controller.participantsUpdated);
            tasklist += // the task stuff to show
         dwr.util.setValue("tasklist", tasklist, {
       escapeHtml:false });                                  Also useful to have these methods called
         var objDiv = document.getElementById("tasklist");       from onLoad() in an init() function to
         objDiv.scrollTop = objDiv.scrollHeight;                 create initial view
      }
   },
   participantsUpdated: function(){                          You can import JQuery if you like for
      Controller.updateUser();                                  setting the view content, or do it using
   }                                                            DOM
Packaging
You need to add this to your config.xml to tell
 Wookie to include the Wave Gadget API
 methods:



<feature
 name="http://wave.google.com"
 required="true"/>
Uploading, debugging and testing
• You need a             • I’ve set up a Moodle
  collaborative            instance at:
  environment to test
  your widget properly   192.168.2.XXX

                         Login as ws1,ws2,ws3,
                           or ws4
Other stuff…
• AJAX                         • Camera access
If you want to call            If you want to access the
   external sites from            user’s camera from a
   within the widget, call        widget, there is an
   myurl =
                                  example of how to do
   widget.proxify(url)
   first to call it via proxy.    this in the moodle
   Also need to add the           course (topic 3)
   site to the server
   whitelist.

Mais conteúdo relacionado

Mais procurados

Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2DreamLab
 
"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar SimovićJS Belgrade
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projectsIgnacio Martín
 
Aggregation and Awareness or How to Reduce the Amount of your FrontEnd Code ...
Aggregation and Awareness or How to Reduce the Amount of  your FrontEnd Code ...Aggregation and Awareness or How to Reduce the Amount of  your FrontEnd Code ...
Aggregation and Awareness or How to Reduce the Amount of your FrontEnd Code ...ISS Art, LLC
 
13 advanced-swing
13 advanced-swing13 advanced-swing
13 advanced-swingNataraj Dg
 
The state of hooking into Drupal - DrupalCon Dublin
The state of hooking into Drupal - DrupalCon DublinThe state of hooking into Drupal - DrupalCon Dublin
The state of hooking into Drupal - DrupalCon DublinNida Ismail Shah
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose worldFabio Collini
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOSMake School
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7Dongho Cho
 
Basic Tutorial of React for Programmers
Basic Tutorial of React for ProgrammersBasic Tutorial of React for Programmers
Basic Tutorial of React for ProgrammersDavid Rodenas
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVICS
 
Hooks and Events in Drupal 8
Hooks and Events in Drupal 8Hooks and Events in Drupal 8
Hooks and Events in Drupal 8Nida Ismail Shah
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxVisual Engineering
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5Martin Kleppe
 

Mais procurados (20)

Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović"Angular.js Concepts in Depth" by Aleksandar Simović
"Angular.js Concepts in Depth" by Aleksandar Simović
 
Angular In Depth
Angular In DepthAngular In Depth
Angular In Depth
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Aggregation and Awareness or How to Reduce the Amount of your FrontEnd Code ...
Aggregation and Awareness or How to Reduce the Amount of  your FrontEnd Code ...Aggregation and Awareness or How to Reduce the Amount of  your FrontEnd Code ...
Aggregation and Awareness or How to Reduce the Amount of your FrontEnd Code ...
 
13 advanced-swing
13 advanced-swing13 advanced-swing
13 advanced-swing
 
The state of hooking into Drupal - DrupalCon Dublin
The state of hooking into Drupal - DrupalCon DublinThe state of hooking into Drupal - DrupalCon Dublin
The state of hooking into Drupal - DrupalCon Dublin
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOS
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
 
Basic Tutorial of React for Programmers
Basic Tutorial of React for ProgrammersBasic Tutorial of React for Programmers
Basic Tutorial of React for Programmers
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IV
 
Hooks and Events in Drupal 8
Hooks and Events in Drupal 8Hooks and Events in Drupal 8
Hooks and Events in Drupal 8
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 

Destaque

Hayley Designers
Hayley DesignersHayley Designers
Hayley DesignersOllie Bray
 
Blogs For Moms
Blogs For MomsBlogs For Moms
Blogs For Momsrddietrich
 
Usevertising, czyli reklama spotyka Design Thinking i co z tego wynika.
Usevertising, czyli reklama spotyka Design Thinking  i co z tego wynika.Usevertising, czyli reklama spotyka Design Thinking  i co z tego wynika.
Usevertising, czyli reklama spotyka Design Thinking i co z tego wynika.Michal Owczarek
 
Building Windmills 2009: Personal Learning Networks
Building Windmills 2009: Personal Learning NetworksBuilding Windmills 2009: Personal Learning Networks
Building Windmills 2009: Personal Learning NetworksOllie Bray
 
Computer Games Based Learning in Schools: BETT 2010
Computer Games Based Learning in Schools: BETT 2010Computer Games Based Learning in Schools: BETT 2010
Computer Games Based Learning in Schools: BETT 2010Ollie Bray
 
Integratsioon mat. ja loodusained
Integratsioon mat. ja loodusainedIntegratsioon mat. ja loodusained
Integratsioon mat. ja loodusainedaluojalaine
 
$15 per Month Answering Service
$15 per Month Answering Service$15 per Month Answering Service
$15 per Month Answering Servicekerrykelcom
 
Consultation on Zero Waste Regulations
Consultation on Zero Waste RegulationsConsultation on Zero Waste Regulations
Consultation on Zero Waste RegulationsChristian Storstein
 
The Awaited Savior
The Awaited SaviorThe Awaited Savior
The Awaited Saviorzain
 
Cit 2008 Kindle I Phone Sdk
Cit 2008 Kindle I Phone SdkCit 2008 Kindle I Phone Sdk
Cit 2008 Kindle I Phone SdkMike Qaissaunee
 
AOC Personalisation
AOC PersonalisationAOC Personalisation
AOC Personalisationscottw
 
Jaka wartosc ma tresc blogow?
Jaka wartosc ma tresc blogow?Jaka wartosc ma tresc blogow?
Jaka wartosc ma tresc blogow?Sebastian Luczak
 
The Roles Of Scientists
The Roles Of ScientistsThe Roles Of Scientists
The Roles Of Scientistsgriggans
 
恐龍愛玩耍 戴浩政
恐龍愛玩耍  戴浩政恐龍愛玩耍  戴浩政
恐龍愛玩耍 戴浩政MJ7062
 
LACA Foundation in El Salvador
LACA Foundation in El SalvadorLACA Foundation in El Salvador
LACA Foundation in El Salvadorstuboo
 
Fours And Fives
Fours And FivesFours And Fives
Fours And Fivesrwstip
 

Destaque (20)

Hayley Designers
Hayley DesignersHayley Designers
Hayley Designers
 
Wdie 8 Sem2
Wdie 8 Sem2Wdie 8 Sem2
Wdie 8 Sem2
 
Blogs For Moms
Blogs For MomsBlogs For Moms
Blogs For Moms
 
Usevertising, czyli reklama spotyka Design Thinking i co z tego wynika.
Usevertising, czyli reklama spotyka Design Thinking  i co z tego wynika.Usevertising, czyli reklama spotyka Design Thinking  i co z tego wynika.
Usevertising, czyli reklama spotyka Design Thinking i co z tego wynika.
 
Building Windmills 2009: Personal Learning Networks
Building Windmills 2009: Personal Learning NetworksBuilding Windmills 2009: Personal Learning Networks
Building Windmills 2009: Personal Learning Networks
 
Computer Games Based Learning in Schools: BETT 2010
Computer Games Based Learning in Schools: BETT 2010Computer Games Based Learning in Schools: BETT 2010
Computer Games Based Learning in Schools: BETT 2010
 
Integratsioon mat. ja loodusained
Integratsioon mat. ja loodusainedIntegratsioon mat. ja loodusained
Integratsioon mat. ja loodusained
 
$15 per Month Answering Service
$15 per Month Answering Service$15 per Month Answering Service
$15 per Month Answering Service
 
Consultation on Zero Waste Regulations
Consultation on Zero Waste RegulationsConsultation on Zero Waste Regulations
Consultation on Zero Waste Regulations
 
The Awaited Savior
The Awaited SaviorThe Awaited Savior
The Awaited Savior
 
Cit 2008 Kindle I Phone Sdk
Cit 2008 Kindle I Phone SdkCit 2008 Kindle I Phone Sdk
Cit 2008 Kindle I Phone Sdk
 
AOC Personalisation
AOC PersonalisationAOC Personalisation
AOC Personalisation
 
Kokkuvõte 1
Kokkuvõte 1Kokkuvõte 1
Kokkuvõte 1
 
Jaka wartosc ma tresc blogow?
Jaka wartosc ma tresc blogow?Jaka wartosc ma tresc blogow?
Jaka wartosc ma tresc blogow?
 
The Roles Of Scientists
The Roles Of ScientistsThe Roles Of Scientists
The Roles Of Scientists
 
恐龍愛玩耍 戴浩政
恐龍愛玩耍  戴浩政恐龍愛玩耍  戴浩政
恐龍愛玩耍 戴浩政
 
LACA Foundation in El Salvador
LACA Foundation in El SalvadorLACA Foundation in El Salvador
LACA Foundation in El Salvador
 
KeyNote Ulster
KeyNote UlsterKeyNote Ulster
KeyNote Ulster
 
Fours And Fives
Fours And FivesFours And Fives
Fours And Fives
 
Mimas
MimasMimas
Mimas
 

Semelhante a Build Widgets

Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScriptAndrew Dupont
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptDonald Sipe
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to CeleryIdan Gazit
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade ServerlessKatyShimizu
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade ServerlessKatyShimizu
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Librariesjeresig
 
JavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashJavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashBret Little
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2Leonid Maslov
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVCRichard Paul
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: FunctionsAdam Crabtree
 

Semelhante a Build Widgets (20)

Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to Celery
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
JavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashJavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and Lodash
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 
meet.js - QooXDoo
meet.js - QooXDoomeet.js - QooXDoo
meet.js - QooXDoo
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Gephi Toolkit Tutorial
Gephi Toolkit TutorialGephi Toolkit Tutorial
Gephi Toolkit Tutorial
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
 
Ngrx meta reducers
Ngrx meta reducersNgrx meta reducers
Ngrx meta reducers
 

Mais de scottw

Getting the Maximum Benefit from Free and Open Source Software
Getting the Maximum Benefit from Free and Open Source SoftwareGetting the Maximum Benefit from Free and Open Source Software
Getting the Maximum Benefit from Free and Open Source Softwarescottw
 
How to engage students in real open source projects
How to engage students in real open source projectsHow to engage students in real open source projects
How to engage students in real open source projectsscottw
 
Free, Libre and Open Source Software and Further Education
Free, Libre and Open Source Software and Further EducationFree, Libre and Open Source Software and Further Education
Free, Libre and Open Source Software and Further Educationscottw
 
Open Forges and App Stores
Open Forges and App StoresOpen Forges and App Stores
Open Forges and App Storesscottw
 
Delivering Web To Mobile
Delivering Web To MobileDelivering Web To Mobile
Delivering Web To Mobilescottw
 
Creating mobile web apps
Creating mobile web appsCreating mobile web apps
Creating mobile web appsscottw
 
Widgets and Mashups for Personal and Institutional Technologies
Widgets and Mashups for Personal and Institutional Technologies Widgets and Mashups for Personal and Institutional Technologies
Widgets and Mashups for Personal and Institutional Technologies scottw
 
Open Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C WidgetsOpen Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C Widgetsscottw
 
Dissemination beyond academic circles
Dissemination beyond academic circlesDissemination beyond academic circles
Dissemination beyond academic circlesscottw
 
Android
AndroidAndroid
Androidscottw
 
Wookie Intro
Wookie IntroWookie Intro
Wookie Introscottw
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetupscottw
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetupscottw
 
Life of a Wookie
Life of a WookieLife of a Wookie
Life of a Wookiescottw
 
CRM & HE
CRM & HECRM & HE
CRM & HEscottw
 
Presence
PresencePresence
Presencescottw
 
FeedForward at RSP
FeedForward at RSPFeedForward at RSP
FeedForward at RSPscottw
 
Boxcri
BoxcriBoxcri
Boxcriscottw
 
Widgets And Wookies
Widgets And WookiesWidgets And Wookies
Widgets And Wookiesscottw
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie projectscottw
 

Mais de scottw (20)

Getting the Maximum Benefit from Free and Open Source Software
Getting the Maximum Benefit from Free and Open Source SoftwareGetting the Maximum Benefit from Free and Open Source Software
Getting the Maximum Benefit from Free and Open Source Software
 
How to engage students in real open source projects
How to engage students in real open source projectsHow to engage students in real open source projects
How to engage students in real open source projects
 
Free, Libre and Open Source Software and Further Education
Free, Libre and Open Source Software and Further EducationFree, Libre and Open Source Software and Further Education
Free, Libre and Open Source Software and Further Education
 
Open Forges and App Stores
Open Forges and App StoresOpen Forges and App Stores
Open Forges and App Stores
 
Delivering Web To Mobile
Delivering Web To MobileDelivering Web To Mobile
Delivering Web To Mobile
 
Creating mobile web apps
Creating mobile web appsCreating mobile web apps
Creating mobile web apps
 
Widgets and Mashups for Personal and Institutional Technologies
Widgets and Mashups for Personal and Institutional Technologies Widgets and Mashups for Personal and Institutional Technologies
Widgets and Mashups for Personal and Institutional Technologies
 
Open Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C WidgetsOpen Source Junction: Apache Wookie and W3C Widgets
Open Source Junction: Apache Wookie and W3C Widgets
 
Dissemination beyond academic circles
Dissemination beyond academic circlesDissemination beyond academic circles
Dissemination beyond academic circles
 
Android
AndroidAndroid
Android
 
Wookie Intro
Wookie IntroWookie Intro
Wookie Intro
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetup
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetup
 
Life of a Wookie
Life of a WookieLife of a Wookie
Life of a Wookie
 
CRM & HE
CRM & HECRM & HE
CRM & HE
 
Presence
PresencePresence
Presence
 
FeedForward at RSP
FeedForward at RSPFeedForward at RSP
FeedForward at RSP
 
Boxcri
BoxcriBoxcri
Boxcri
 
Widgets And Wookies
Widgets And WookiesWidgets And Wookies
Widgets And Wookies
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie project
 

Último

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 Takeoffsammart93
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
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.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
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
 
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 WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 MenDelhi Call girls
 
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 Servicegiselly40
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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...Miguel Araújo
 
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
 

Último (20)

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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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)
 
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...
 
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
 

Build Widgets

  • 1. Lets Build Some Widgets!
  • 2. Anatomy of a Widget • Config.xml <- W3C Widgets P&C Spec • icon.png • index.html <- HTML start file • JavaScript code, CSS • Zip it up, change ext to .wgt, and you’re done
  • 3. Widget metadata • Id • Height, Width • Name • Description • Version • Features • Author info • License
  • 4. A Silly Example: config.xml <?xml version="1.0" encoding="utf-8"?> <widget xmlns="http://www.w3.org/ns/widgets" id="http://www.getwookie.org/widgets/tea" version="1.0” height="150” width="125"> <name>Tea</name> <description>A silly Tea widget</description> <author>Scott Wilson</author> </widget>
  • 5. A Silly Example: index.html <html> <body> <img src="tea.jpg" /> <p>Time for a break, mate</p> </body> </html>
  • 6. Make your own basic widget 1. Make an index.html file 2. Make a config.xml file 3. Zip them up, and change suffix to “.wgt” 4. Upload to a wookie server
  • 7. Uploading • Go to http://192.168.2.161/wookie • Click “admin” • Login with java/java • Click “add new widget” • Find your .wgt file • OK!
  • 8. Previewing a widget • Go to 192.168.2.161:8080/wookie • Click “View Widget Gallery” • Click the “demo” link under your widget • Your widget will show
  • 9. Preferences • You can store preferences for an instance of a widget using: widget.preferences.setItem(“key”, “value”) widget.preferences.getItem(“key”)
  • 10. Collaborative Widgets • State and Participants • State is shared across widgets with the same IRI in the same shared context. • State is propagated to related widgets using an event callback • State is set by submitting deltas
  • 11. State example wave.setStateCallback(stateUpdated); stateUpdated = function(){ var keys = wave.getState().getKeys(); for (var i = 0; i < keys.length; i++) { alert(wave.getState().get(keys[i])); } }; wave.getState().submitValue(“key”, “value”);
  • 12. Participants • Register callbacks with: wave.setParticipantCallback(myfunction); • Methods: – getViewer() - get the current user – getParticipants() - get map of all participants • Model: – getId(), getDisplayName(), getThumbnailUrl()
  • 13. Making a collaborative app • This requires some more planning 1. Draw up a design 2. Create a working test page 3. Implement models, action handlers and event handlers 4. Create the config.xml, icon.png, zip it up and run it
  • 14. Design • Start with the view - what the widget looks like • Create the model - what are the objects in the state model? • Add the actions - how you interact with it • Wire it all up…
  • 15.
  • 16. Prototyping • Make a regular html page to test out your view. Populate it with fake model, and don’t wire up the actions yet • You can reuse this for the real widget - just take out your fake state info sections
  • 17. Implementing • Create a “Model” object for your state model • Create a “Controller” object, and a method in it for each action • Register the participant and state event handlers with an “update view” method that populates the view when running
  • 18. Models • Models can be implemented in typical “bean” fashion • Save/Find methods need to access wave state • Can use JSON (e.g. with json.js) or just plain strings for storage function Task(id,name,status,assigned){ this.task_id = id; this.name = name; this.status = status; this.assigned_to = assigned; } Task.prototype.save = function(){ wave.getState().submitValue(this.task_id, JSON.stringify(this)); }
  • 19. Static model methods Task.create = function(json){ var obj = JSON.parse(json); var task = new Task(obj.task_id, obj.name,obj.status,obj.assigned_to); return task; • Typically need } methods to turn state Task.find = function(task_id){ var keys = wave.getState().getKeys(); for (var i = 0; i < keys.length; i++) { strings back into var key = keys[i]; if (key == task_id){ model instances return Task.create(task_id, wave.getState().get(key)); } } • Also finder methods to } return null; get a particular model Task.findAll = function(){ object var tasks = {}; var keys = wave.getState().getKeys(); for (var i = 0; i < keys.length; i++) { • This isn’t the only way var key = keys[i]; var task = Task.create(key, wave.getState().get(key)); tasks[key] = task; to do this, but is an } return tasks; OK pattern }
  • 20. Controllers /** * The Controller object * This is used to wire up the view and model with actions • Methods for each */ var Controller = { action, making // Action handlers changes to the model // Toggle task state between completed and to-do toggleTask: function(task_id){ • You usually don’t }, need to do any code // Create a new task newTask: function(){ }, that interacts with // Abandon task for someone else to do HTML, as the event abandonTask: function(task_id){ }, handlers should do // Claim a task (assign to self) claimTask: function(task_id){ that } }
  • 21. Event Handlers // Update the view when state has been updated These fire whenever the state or participants stateUpdated: function(){ are updated (e.g. by another instance). var tasks = Task.findAll(); if (tasks && tasks != null){ var tasklist = ""; Event handlers need to be registered like so: for (key in tasks) { var task = tasks[key]; wave.setStateCallback(Controller.stateUpdated); wave.setParticipantCallback(Controller.participantsUpdated); tasklist += // the task stuff to show dwr.util.setValue("tasklist", tasklist, { escapeHtml:false }); Also useful to have these methods called var objDiv = document.getElementById("tasklist"); from onLoad() in an init() function to objDiv.scrollTop = objDiv.scrollHeight; create initial view } }, participantsUpdated: function(){ You can import JQuery if you like for Controller.updateUser(); setting the view content, or do it using } DOM
  • 22. Packaging You need to add this to your config.xml to tell Wookie to include the Wave Gadget API methods: <feature name="http://wave.google.com" required="true"/>
  • 23. Uploading, debugging and testing • You need a • I’ve set up a Moodle collaborative instance at: environment to test your widget properly 192.168.2.XXX Login as ws1,ws2,ws3, or ws4
  • 24. Other stuff… • AJAX • Camera access If you want to call If you want to access the external sites from user’s camera from a within the widget, call widget, there is an myurl = example of how to do widget.proxify(url) first to call it via proxy. this in the moodle Also need to add the course (topic 3) site to the server whitelist.