Google Gears

31/05/2007 13:14:00

Why Bother? Reliability, Convenience, offline more then you think, performance In a perfect world… One application, one URL, Seamless transitions between online and offline, Ability to use local data, even when online, Available to all users on all platforms. What do Gears apps look like? • Read and write using local store • Changes are queued for later synchronization • Server communication is completely decoupled from UI actions, happens periodically whenever there is a connection. What APIs would one need? • LocalServer, to access the application offline • Database, to store large amounts of structured data • WorkerPool, to perform long operations LocalServer: Run web applications offline • Two types of “offline caches” • ResourceStore: capture individual URLs • ManagedResourceStore: capture entire applications ManagedResourceStore: Capture entire applications • List application resources in a separate manifest

• • • •

Gears captures and updates the application resources automatically Gears automatically updaes application resources on each view (within reason) Always run locally Support multiple users per application

ManagedResourceStore Code Sample myapp.js var localserver = google.gears.factory.create(‘beta.localserver’,’1.0’); var store = localserver.createManagedStore(‘mystore’); store.manifestUrl = ‘’; store.checkForUpdates(); offline-manifest.json { • “betaManifestVersion”: 1, • “version”: 0.5 } Database: local SQL storage • SQLite: Open source, mature, small (343K), fast, full-featured relational database

• •

Gigabytes of storage capacity Strict same-origin security model

Database Code Sample var db = google.gears.factory.create(‘beta.database’, ‘1.0’); db.execute(‘insert into Delicious (Name, NumStars) values (?, ?)’, [‘burrito’, 5]); var rs = db.execute(‘select * from Delicious order by NumStars desc’); while (rs.isValidRow()) { console.log (rs.fieldByName(‘name’)); } rs.close(); Demo: Database • These slides are database-driven • Gears comes with dbquery.html - a web-based command line for local databases • There are also many other 3rd party SQLite apis WorkerPool: Run Javascript in the background • Provides thread-like functionality to JavaScript

• •

No more blocking the browser UI Communication is via IPC, no shared state or threading primitives

WorkerPool Code Sample function nextPrime(n) { google.gears.workerPool.sendMessage(result); } var pool = google.gears.factory.create(‘beta.workerpool’,’1.0’); pool.onmessag Bonus: Full Text Search • Joint Project with SQLLite CREATE VIRTUAL TABLE Search USING FTS2(Title, Content); SELECT TITLE FROM Search WHERE Title MATCH ‘%sql%’; SELECT snippet(Search) FROM Search WHERE Search MATCH ‘sql’; CREATE TABLE Data (Se Fireside Chat at 1:00 Nuts and Bolts .. and Gears at 4:30 Get Gears at:

The Google AJAX APIs

31/05/2007 13:14:00

Google AJAX Search API and Google AJAX Feed API

• •

Covered in this talk (Google Maps API in “Developing with Geo”) Why AJAX? o Large number of “developers” pros … bloggers o Run on any page, any piece of infrastructure o Highly interactive this talk Show what AJAX Search and FEED APIs can do on your pages Show how easy these APIs are to use Introduce you to the API’s layered archtecture

Goal of • • •

Search Page: AJAX Search Page: • Right Sidebar Contains o Tabbed Search Module  Web Search  Blog Search  CSE

o Video Search  YouTube and Google Video  Playback on page o Map Search  Programmable Center  Pre selected Hotspots  Hyperlink can trigger searches AJAX Feed Page: • Slide Show Control o Flikr, PhotoBucket, Picasa, or any Media RSS feed • Blog Roll o Enumerate feed contents o Easy to program and customize • Tune Bar Control o iTunes top albums, artists, and new releases

31/05/2007 13:14:00