Skip to content

Instantly share code, notes, and snippets.

@yurenju
Last active January 3, 2016 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurenju/8452422 to your computer and use it in GitHub Desktop.
Save yurenju/8452422 to your computer and use it in GitHub Desktop.

webapp-zip.js

This article expand how webapp-zip.js works, please take a look into webapp-zip.js

webapp-zip.js is used to compress a gaia app into application.zip which is in profile/webapps/APPNAME.gaiamobile.org/ since we have some rule to decide which files should be compressed.

Single file handler

Exclude

  • locales/ and locales.ini: if GAIA_INLINE_LOCALES or GAIA_CONCAT_LOCALES is 1.
  • locales-obj: if GAIA_CONCAT_LOCALES is not 1
  • shared/ and test/: always exclude.

Add files in shared into zip

If is HTML and used files in shared OR gaia_shared.json exists, and those files into zip.

Compression option

we need to add file into zip without compression if zip property is specified in metadata.json, it looks like:

{
  external: false,
  zip: {
    no_compression: [
      ...
    ]
  }
}

if file path is specified in no_compression, the file should be added into zip without compression.

Files in shared directory

Since got files in shared directory which is included in certain HTML file, we also need to add them into zip from GAIA_DIR/shared directory. there are some types of file need to be copied: js, locales, resources, style and style_unstable and we also have some different rules to decide which files need to be copied:

  • branding: if OFFICIAL is 1, file in "official" directory need to be copied, otherwise file in "unofficial" will be copied.
  • localeFile: we need copy localeFile from LOCALES_FILE environment variable.
  • resource file with @(NUMBER)x: right resolution file will be copied into zip. e.g., if GAIA_DEV_PIXELS_PER_PX is 2, we need copy IMAGE_FILE@2x.png into zip.
  • ringtones: cusotmization ringtones will be copied if DIST_DIR/ringtones exists.

Customization handler per app

  • system: add DIST_DIR/power/ to resources/power/ if exists
  • wallpaper: add DIST_DIR/wallpapers/ to resources/320x480/ if exists
  • homescreen: add DIST_DIR/temp/apps/conf/singlevariantconf.json to js/singlevariantconf.json if exists
  • communications: if DIST_DIR/variant.json exists
    • Generate a JSON and add to resources/customization.json
    • add resources into resources/
  • keyboard: add a localized manifest file into zip

Localization

use l10nManager.localize() to localize manifest.webapp, *.ini & *.properties and replace original files in zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment