5 Replies Latest reply on Mar 12, 2008 9:33 AM by Alessandro_Vernet

    Taking pages offline

    Alessandro_Vernet
      I am comparing AIR with Gears, and I am wondering if AIR has the ability of taking a page from my site offline, and then making that page accessible to the AIR application under its initial URL.

      Imagine that I create an AIR application for the New York Times. I want essentially the UI to be the same as the one you have when you to the NY Times site, except a "take this article offline" button is added on each page. When users click the "take this article offline", the page and all the resources (images, CSS, script) needed for the page are save in a local store. If the user later browses back to the same article, the data will be loaded from the local store instead of being loaded from the NY Times site.

      Is it possible to implement this in AIR? Or would this not be inline with the intended architecture for AIR applications?

      Alex
        • 1. Taking pages offline
          wouter vdb
          Edit: After rereading the question I rather agree with the next reply... indeed this is possible, not trivial, but possible. After my initial reading I somehow thought that you wanted to access the 'offline' pages of the site from within a regular browser. I'm sorry if I have been confusing people ;-)

          AIR is not suited for this kind of 'non-flushing-cache' functionality. I'm not sure if Gears or HTML5 would be useful either though. Do they allow for the local interception of a request when not online?

          What you could for instance do in AIR is build a 'NYT-browser' (as a distinct desktop app) that does exactly what you're describing.
          • 2. Re: Taking pages offline
            anirudhs Level 2
            Hi,

            It should be possible to do what you said, but just like Gears (or what I understand about it), you'd need to work to get it done in AIR.

            Deciding if a URL has to hit the local datastore or not will have to be handled by the application. You can store the entire web page on the hard disk and access from there without any problems in AIR.

            Though you'd have to write code for "take this article offline" sort of a feature. AIR has no built-in API to dynamically save all associated resources with any HTML page. I don't think Gears does either. You'd have to do it in code yourself.

            This is the "data layer" you have to put in your application to make it easy for offline features. AIR and Gears provide APIs to make it possible to have data locally among other things.

            Did that answer your question or confuse you futher? :)
            • 3. Re: Taking pages offline
              Alessandro_Vernet Level 1
              @anirudhs,

              You are right, I don't think that Gears has a feature to automatically take offline a page and all the resources it depends on. With Gears, you need to list the resources you want to take offline. But once you have done that, if a request is made in the browser to a URL that has been taken offline, instead of hitting the web site, the content will be loaded from a local store. So with AIR, here is how this could be done:

              1) When the user decides to take a page offline, JavaScript code downloads the page (and all the resources it needs) and saves that somewhere under app-storage:/. Then it redirects the user to the a URL that starts with app-storage:/ and that loads the data we just saved.
              2) If there is a "summary page" in the application (in the NY Times example, that would be a page with a list of current articles), JavaScript code needs to be embedded in the page to check for each article linked if that article has been moved offline. If it has, the JavaScript code changes the URL to point to somewhere under app-storage:/ instead of somewhere under http://www.nytimes.com/.

              Is this understanding accurate?

              Alex
              • 4. Re: Taking pages offline
                anirudhs Level 2
                > Is this understanding accurate?

                Yes.
                • 5. Re: Taking pages offline
                  Alessandro_Vernet Level 1
                  Thank you for confirming this.

                  Alex