10
Quick Create Sakai Tools in Pure HTML and JavaScript Lovemore Nalube Developer University of Cape Town 17 June 2010

Quick Create Sakai Tools in Pure HTML and JavaScript

Embed Size (px)

DESCRIPTION

This session will provide a technical overview on how to leverage Sakai’s REST creation abilities provided by EntityBroker to create ‘on-the-fly’ tools in just HTML, JavaScript and CSS. Sakai development time is grossly affected by the numerous UI rendering toolkits available out there. From RSF to JSF, tweaking the UI to do a simple thing can become time consuming. We will focus on moving UI development back to simple client-side coding and relying on the web services already in Sakai. REST enables you to run queries against a server and retrieve server/database specific information such as site identification or assignments results. Using this technique, UI developers can concentrate on UI and client-side development. A solid separation of concerns is created. Javascript will become the ‘link’ between server and UI. From this session, users will find out how to quickly code acceptable JavaScript applying proper anatomy, namespacing, scoping, dependency handling and error handling. Sample tools will focus on the work done by UCT on the Group Manager tool (http://tinyurl.com/yjtkafl), SMS Credits Transfer Tool, Course Evaluations and SMS Tool. ==================== VIEW VIDEOS CAST: http://www.ustream.tv/recorded/7723054

Citation preview

Page 1: Quick Create Sakai Tools in Pure HTML and JavaScript

Quick Create Sakai Tools in Pure HTML and JavaScript

Lovemore NalubeDeveloper

University of Cape Town17 June 2010

Page 2: Quick Create Sakai Tools in Pure HTML and JavaScript

Overview

• What you need• The JavaScript canvas• Sakai dependencies• Getting Sakai data• Dropping the app into a site• Demo

• Lets make a “Join a site widget”• A new Group Manager Interface for Sakai• SMS Credits Transfer tool

211th Sakai Conference - June 15-17, 2010

Page 3: Quick Create Sakai Tools in Pure HTML and JavaScript

What you need

• jQuery – latest v 1.4.2• HTML• Firebug

• Pretty cool to use:• Fluid infusion – i18n, accessibility• QUnit – jQuery unit testing

311th Sakai Conference - June 15-17, 2010

Page 4: Quick Create Sakai Tools in Pure HTML and JavaScript

The JavaScript canvas

• Namespace your code to avoid collisions and make code easy to understand.

411th Sakai Conference - June 15-17, 2010

var siteJoin = function($){

//private functions and vars var privateMe = {}; var privateFunction = function(){ };

//public functions return { init: function(){

} }}($);

Page 5: Quick Create Sakai Tools in Pure HTML and JavaScript

Activate our namespace

• Namespace your code to avoid collisions and make code easy to understand.

511th Sakai Conference - June 15-17, 2010

$(document).ready(function() { siteJoin.init();});

Page 6: Quick Create Sakai Tools in Pure HTML and JavaScript

Sakai dependencies

• REST webservices• Entity Broker

• Entity Provider

• Actions:• PUT, POST, GET, DELETE

611th Sakai Conference - June 15-17, 2010

-> sakai level

-> tool level

Page 7: Quick Create Sakai Tools in Pure HTML and JavaScript

Getting Sakai data

• Use jQuery standards

711th Sakai Conference - June 15-17, 2010

$.ajax({ url: "/direct/membership/join/site/" + siteId, type: "POST", success: function(){ alert("You have joined!");

}, error: function(xhr){ alert("Sorry, you cannot join this site."); } });

Page 8: Quick Create Sakai Tools in Pure HTML and JavaScript

Dropping the app into a site

• Put code into a static folder like /library/ so that it is accessible via a url like this: {server}/library/myApp/app.html

• Use the Web Content tool to pull it in.• Add any parameters needed eg:

• {server}/library/myApp/app.html?site=${SITE_ID}

811th Sakai Conference - June 15-17, 2010

Page 9: Quick Create Sakai Tools in Pure HTML and JavaScript

Let’s make a toolGroup manager Demo

Fun

11th Sakai Conference - June 15-17, 2010 9

Page 10: Quick Create Sakai Tools in Pure HTML and JavaScript

More Info

• http://confluence.sakaiproject.org/display/GRPMGR/

1011th Sakai Conference - June 15-17, 2010