Screencast of Dojo Offline + Demo + Release Download

By on February 26, 2007 8:37 am

[Note: This blog post is out of date. For up to date information on Dojo Offline please see the official web page.]

Hi folks; lots of news on the Dojo Offline front.First, we have put up a screencast that shows a demo of Dojo Offline named Moxie. Moxie is an example application bundled with Dojo Offline that shows how to use the Dojo Offline framework. It is a web-based word processor that features local storage and offline access. Moxie is now finished for Dojo Offline.

Thumbnail of beginning of Dojo Offline screencast for 02-20-2007

Watch the Dojo Offline Screencast

Next, we’ve finished the JavaScript layer of Dojo Offline. Dojo Offline consists of two major pieces: a JavaScript API that is included with a web application, and which helps with syncing, on/offline status notification, caching of data and resources, etc.; and a local small web proxy download that is cross-platform and cross-browser and which is web application independent. The JavaScript API is now finished, and can actually be used even though we have not finished the local web proxy yet. This is done by having the JavaScript layer be able to use the browser’s native cache if no offline cache is available. This means you can start playing with Dojo Offline right now, with the download link included in this blog post below. Note that using the browser cache instead of the web proxy is only suitable for prototyping and should not be deployed on production applications; it will work with varying degrees of success on Internet Explorer and Firefox, but not consistently on Safari. Higher levels of reliability will only come when we deliver the local web proxy component.

To start using Dojo Offline now in conjunction with the browser cache, you must have the following in your JavaScript code: dojo.off.requireOfflineCache = false. You must also turn on HTTP caching headers on your web server; how to turn on these HTTP headers and which ones to turn on are explained in the Dojo Storage FAQ. See the Moxie code links below for more examples of how to use the API. Note that the Dojo Offline JavaScript API has changed, especially for syncing, since our API blog post about a month ago and has become much simpler — see the Moxie source for details.
The demo of Moxie shown in the screencast above can also be played with right in your browser. Please note that both Moxie and Dojo Offline are still alpha; you are literally seeing Dojo Offline being developed in front of your eyes, and glitches remain in both of them. Please debug and provide test cases for errors you find to help development.

Live Demo of Dojo Offline/Moxie here (alpha)

View the source code for Moxie’s JavaScript and HTML

You can also download a release of Dojo Offline from about two weeks ago that has the functionality described above, including the Dojo Offline JavaScript layer, Dojo, and Moxie:

Download Latest Dojo Offline Release (release-02-20-2007.zip)

Here’s some info on the directory layout. Look in release-02-20-2007/demos/storage to see the Moxie client side JavaScript and HTML files, and in release-02-20-2007/demos/storage/server/ to see the Java server side, composed of a Java servlet, a RESTian API, a simple data model and database abstraction layer, and a MySQL database.

The Dojo Offline JavaScript source code consists of the main dojo.off package inside release-02-20-2007/src/off.js; the dojo.off.ui package inside release-02-20-2007/src/off/ui.js; the dojo.off.files package inside of release-02-20-2007/src/off/files.js; and the dojo.sync package inside of release-02-20-2007/src/sync.js.

We highly encourage you to start hacking with Dojo Offline, using it to prototype offline web apps, using the Moxie client and server source as scaffolding for your own applications. All are open source and open for you to include and modify; please provide feedback and patches should you find or fix important bugs or add features.

The next step, began about 1 1/2 weeks ago actually, is development of the Dojo Offline download piece, the small web proxy. Development is moving along at a brisk pace on this. Already Polipo, the existing web based proxy written in cross-platform C, has been modified to load and save our list of offline-enabled web sites; produce a dynamically generated Proxy AutoConfig file based on this list; and to expose a simple API that can be scripted from our JavaScript in a reliable way to add or remove sites and see if the proxy is running and installed. The JavaScript layer has also been modified to tie into the local web proxy if it is available for adding or removing offline-enabled web sites transparently. I also setup a cross compilation environment with GCC and Mingw on my machine so that I can produce Windows executables from my Mac OS X box, which speeds up my productivity for producing cross-platform C builds.

To view the source so far, you can see off.h and off.c, two new files added to Polipo. The local web server bundled with Polipo (inside local.c) was also modified for our API that is scripted from JavaScript (see the newest version of dojo.off inside off.js on the Subversion repository here). Other files were also modified; see the full Dojo Offline Polipo directory here (this is inside the Dojo Subversion repository).

The next step is to continue working on the proxy, getting the on/offline detection code between the JavaScript layer and the local proxy better, as well as having the local proxy automatically go offline if it can not reach the network to resolve a proxy request, reattempting the proxy request from the local cache instead.

If the community wants to help, I would love if someone got the background JavaScript thread that looks for the network appearing and disappearing down to 1 through 5 seconds. It is currently at 15 seconds since I ran into some strange glitches on Firefox when I made it less. If you can reliably get it much lower, and test it across Safari, IE, and Firefox, that would be a great patch from the community.

Comments

  • Pingback: Dojo Offline Toolkit » Blog Archive » Dojo Offline Toolkit Status Report for Week Ending February 25th, 2007()

  • nice to hear it man :D

    cant wait to get it work on New Firefox Release as a Brendan Eich (Firefox) @ The AJAX Experience, Boston. He make some demo that proofing Offline thinks on web application.
    (http://www.scribemedia.org/2007/02/15/firefox-javascript-eich/)

  • I am so proud of you, sweetheart…even though I am not the kind of geek who can take this all in. so much for going to bed early….

    happy anniversary. love, bek

  • Great stuff! With regards to the background thread to check offline/online. For firefox you could use the offline and online event notifications which would remove the need for the polling:

    http://www.whatwg.org/specs/web-apps/current-work/#offline

    Is there the ability to do this type of browser specific optimisation in the toolkit/

  • @Chris: The on/offline event defined in the WhatWG spec will only be in Firefox 3; currently it is controlled by the user selecting Work Offline from the File menu, which has usability issues and which does not check the network. When Firefox 3 comes out Dojo Offline will be modified to transparently use its offline cache and on/offline detection abilities rather than needing a local proxy.

  • Can you please put a downloadable version of the screencast?

  • And Boom! :)

    Steve Jobs should watch his back.

  • Roger

    Hi Brad,

    Great job you done here !! I spend a little time playing with moxie under a php/mysql environment.

    Just a reflexion, we all dream of an application that runs on and offline without that the user is thinking about it. This can be a reality with the offline toolkit.

    Nevertheless what an enorm work you have to do at the client side to achieve input controls, synchronisation between master and detail datagrids, conditionnal contains of combos depending of which data was just input or selected. It seems that you have to download the whole database before you can work offline and then code long long javascripts to do what a simple SQL order can achieve in a few lines.

    Don’t you think this sort of technologies must be reserved only for applications that needs a small amount of data in a small amont of tables ?

    Best regards,

    Roger

  • Pingback: Dojo Offline Toolkit » Blog Archive » Dojo Offline Toolkit Status Report for Week Ending March 5th, 2007()

  • Don

    Brad,

    I’ve set up my test environment such that I have two web apps running in a tomcat server. One web app has the moxie client app while the other has the offline server component.

    I was hoping (though not exactly expecting) that if I were to stop the server-support web app (keeping the other, client web app running) and then tried to save a file, moxie would give me an option to work offline.

    Perhaps this is too much of a different problem? I mean, working offline because you’re actually offline …versus working offline because the server is down or just very slow/busy. Will dojo offline suport the latter case?

    Don

  • Michael

    Brad,

    I’ve been playing around with the new code and reading the different blog posts you’ve made. The one that interested me the most was the ‘this week’ portion of the Feb. 11th status report. The new code doesn’t seem to fully carry out this theory of using existing client-side functions to take care of sending create, delete, update, etc. commands to the server. Is there an example of this approach?

    Maybe what would be the most help (to me at least) would be a simpler example, like the contacts list discussed in the api: add a contact, delete a contact, update a contact, list contacts. From my php world I would imagine 4 ‘actions’ in a server file, one returning a serialized array for list contacts, success bits for update and delete, and the id for add. Seeing how this would work into a client side offline approach would be a huge help.

    Michael

  • Michael: I dropped having a custom sync wire protocol in favor of letting the client-side have more responsibility when replaying the events, requiring the application programmer to replay the event and call its appropriate pre-existing web service for the different action types, like creating a new task. Having a custom wire sync protocol turned out to be a red herring that actually made things more complicated, harder to use, and required much more custom support on the server-side.

    I agree about needing a simpler example; I’m not sure if I will get to one, since Moxie itself is kind of my example app that I maintain and I’m not sure I want to maintain two, but I might create a very simple Hello World file.

    Brad

  • Pingback: TechNayak » Push for offline web applications()

  • Pingback: Push for offline web applications « TechNayak(mirror)()