SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
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.

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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] 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
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] 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
 

Ähnlich wie 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] 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
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Kürzlich hochgeladen (20)

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

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.