0

I hope this is the right place to talk about this...

I'm planning to create an HTML5 web application which basically download new contents, something like the financial times app. I want to use drupal such as base where I can upload contents and the export it such as json view. In the web app I would like to create a local database where i will add the contents. To keep it update I will compare the last content creation date in the app with the last content creation date on drupal, if they are not the same it will download the latest contents and add it into the db. This is "quite simple", let's move to my problem now... I've got one image per each content and, to see the images offline, I need to add it to the manifest file every time a new content is added.

How can I get this? Or if you think I should use another method, let me know.

Thanks in advance.

2

images should be attached to content via image field(if not I know another way, just ask), so you can create a new views and fetch only these images

add page display to that views and use it to create manifest, in this way you have dynamic manifest. if you want write it to file, small module is needed.

in this case you need have more than one manifest (multiple manifest), one of them is for your images

steps to create images manifest:

  1. create views to fetch images: named manifest_1
  2. create page display in that views: named page_1
  3. create a small module to create your manifest, dirty sample:

    function mymodule_menu() {
      return array(
          'manifest/images' => array(
              'page callback' => 'mymodule_manifest',
              'access arguments' => array('access content'),
              'type' => MENU_CALLBACK,
          )
      );
    }

    function mymodule_manifest() { $images = views_get_view_result('manifest_1', 'page_1'); //sent header text/manifest //output image paths die(); }

5
  • I will use image field to upload the images, the problem is to add the path to the manifest file, then I will manage the way to update the web app. Can you be a bit more clear about it? Apr 5 '12 at 11:39
  • more description added ;) Apr 5 '12 at 11:57
  • Me gusta :D , but what if I put that code into views-manigest-page-1.tpl.php? Are you suggesting me to create two manifest file, one with the basic file and one with the images? Apr 5 '12 at 12:18
  • yes, I suggest you create multiple manifest files. you shouldn't use any .tpl.php file, you should output image links before theme layer Apr 7 '12 at 7:49
  • Can't you create a manifest.json dynamically? I am trying that with my Django app (not drupal) but it does not seem to work. Is there some type of caching going on?
    – sureshvv
    Nov 27 '16 at 11:20
0

The original question mixes up two different elements of html5: app caching and off line storage. The question concerns the local storage not of application parts but of data: the images concerned are to be used as data. So therefore topic 2, completely different: off line storage.

  1. App caching via a manifest file. This facility serves to cache application parts on the user device. Of course that is only useful for static parts; images, Javascript files and CSS files are good examples.

  2. Off line storage. HTML5 contains a spec for local persistent storage, based on key/value pairs, let us say a generalized cookie idea. You can find plenty Javascript examples on the Net how to sync and manipulate this. Additionally, two other ideas are floating around: a local SQL implementation based on SQLite. This was thrown out of HTML5 because it turned out to be impossible to arrive at a single implementation proposal. The last idea is IndexedDB from Mozilla; no more than an idea. It might become more and then it might not.

So, for now local storage in key/value pairs is the official way to go. Take a look at http://diveintohtml5.info, my favorite site on HTML5. I hope this helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.