Follow

How to Customise Manifests

Every post has a manifest file detailing any extra files or images the Pugpig should download with its edition. Each manifest file should be declared in your edition atom feed, as follows:

<link type="text/cache-manifest" href="file/path/[filename].manifest" rel="related"/>

This should be nested under the <entry> tag for the relevant edition. The contents of a manifest file will have the following structure:

CACHE MANIFEST
../css/styles.css
../scripts/jquery-1.7.2.min.js
assets/image.jpg

You can view the generated manifest for each page by clicking the manifest link from the post view.


Testing Content Offline

It is important to ensure all the assets required have been included in the manifests so they are downloaded for offline use.

Manual

In order to test manually, you should:

  1. Delete and reinstall the app to ensure no cached content is stored on the device
  2. From the edition selector, download the edition
  3. Go offline (if this is a 3G-enabled device, use Airplane mode)
  4. View the content while offline

Pugpig will automatically generate the following in the manifests:

  • All the static files in the selected theme directory
  • All the static files contained in ad package ZIP bundles

Excluding assets from the manifest

In some cases, you may not want the entire theme assets included in the manifests. If you wish to exclude them (for some or all cases), implement the following filter:

// Exclude the theme assets for the fancy advert content type
// Ignore theme assets
add_filter('pugpig_theme_manifest_items', 'pugpig_ignore_theme_manifest_items', 10, 2);
function pugpig_ignore_theme_manifest_items($output, $post) {
  if ($post->post_type != MY_POST_TYPE) return $output;
return "\n# AD BUNDLE: Ignoring theme manifest\n"; }

If you wish to exclude the attachments on a post from the manifest, use the following filter:

// Ignore attachments
add_filter('pugpig_attachment_manifest_items', 'pugpig_ignore_attachment_manifest_items',10,2);
function pugpig_ignore_attachment_manifest_items($output, $post) {
  if ($post->post_type != MY_POST_TYPE) return $output;
return "\n# AD BUNDLE: Ignoring attachment manifest items\n"; }

Extending the manifest

If you have assets that are not included using the rules above, you'll need to add them using the hook in the extension module. Any extra image fields that you create will have to be added to the manifest.

add_filter('pugpig_extra_manifest_items', 'my_manifest_items',10,2);
function my_manifest_items($output, $post) {
  if ($post->post_type != MY_POST_TYPE) return $output;
 
  $ret .=  "\n# CUSTOM: Do stuff\n" . pugpig_get_custom_field_manifest_item ($post, 'pugpig_image');

return $output . $ret; }
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk