Le manifeste d'application

  • Raccourci de la révision : Applications/Le_manifeste_d'application
  • Titre de la révision : Le manifeste d'application
  • ID de la révision : 45441
  • Créé :
  • Créateur : Goofy
  • Version actuelle ? Non
  • Commentaire 9 words added

Contenu de la révision

{{ TranslationInProgress() }}


statut : traduction en cours

Le manifeste d'une application contient toutes les informations dont un navigateur a besoin pour interagir avec elle. Il fournit à la fois des éléments lisibles par un être humain (un nom, un jeu d'icônes et une description, en de multiples langues si nécessaire) et d'autres qui ne sont lisibles que par une machine et permettent au navigateur d'afficher et faire tourner les applications. Le manifeste et l'origine de l'application (protocole, nom de l'hôte et numéro de port) constituent à eux deux la description complète d'une application installée. Le manifeste est encodé dans une structure de données de fichier JSON ; l'installation d'une application consiste à donner l'URL de ce fichier au navigateur.

Pour publier vous-même une application, sur une page qui vous appartient, vous déclenchez son installation (par exemple, en appelant navigator.mozApps.install() depuis un bouton). Quand un magasin ou une instance autorisée publie une application, il déclenche son installation en fournissant au navigateur l'adresse URL du manifeste de l'application hébergéee.

Un exemple de manifeste

Vous pouvez copier le texte suivant dans un fichier texte et remplacer les valeurs par vos propres informations.

{{ syntax.javascript{code: "{\n  \"version\": \"1.0\",\n  \"name\": \"MozillaBall\",\n  \"description\": \"Exciting Open Web development action!\",\n  \"icons\": {\n    \"16\": \"/img/icon-16.png\",\n    \"48\": \"/img/icon-48.png\",\n    \"128\": \"/img/icon-128.png\"\n  },\n  \"widget\": {\n    \"path\": \"/widget.html\",\n    \"width\": 100,\n    \"height\": 200\n  },\n  \"developer\": {\n    \"name\": \"Mozilla Labs\",\n    \"url\": \"http://mozillalabs.com\"\n  },\n  \"installs_allowed_from\": [\n    \"https://appstore.mozillalabs.com\"\n  ],\n  \"locales\": {\n    \"es\": {\n      \"description\": \"¡Acción abierta emocionante del desarrollo del Web!\",\n      \"developer\": {\n        \"url\": \"http://es.mozillalabs.com/\"\n      }\n    },\n    \"fr\": {\n      \"description\": \"Une façon nouvlle et excitante de développer des applications pour le Web!\",\n      \"développeur\": {\n        \"url\": \"http://fr.mozillalabs.com/\"\n      }\n    },\n    \"it\": {\n      \"description\": \"Azione aperta emozionante di sviluppo di fotoricettore!\",\n      \"developer\": {\n        \"url\": \"http://it.mozillalabs.com/\"\n      }\n    }\n  },\n  \"default_locale\": \"en\"\n}\n"} }}

Définition des champs

Voici les champs autorisés dans le manifeste de l'application :

nom
Un nom pour l'application, lisible par un être humain, d'un elongueur maximum de 128 caractères).
description
A human-readable description of the app (maximum length is 1024 characters).
launch_path
(optional) The path within the app's origin that is loaded when the app starts. If not provided, the app's origin is treated as the launch URL. See Path Handling.
icons
(optional) A map of icon sizes to paths (which may be absolute paths, or data URLs). Each must contain square images that visually represent the app.
developer
(optional) Information about the developer of the app, suitable for use in repository and dashboard UIs:
name
The name of the developer.
url
The URL of a site containing more information about the app's developer. This URL is typically rendered when the user clicks on the name of the app's developer while viewing details about an app inside the dashboard (or browser).
locales
(optional) A map of locale-specific overrides of the data contained in the manifest, which UIs use to provide localized views. Each locale entry is keyed on a locale tag, and contains a sparse representation of the manifest; any field that is present in the locale value overrides the matching field in the manifest. Certain fields cannot be overridden, including default_locale, locales itself, and installs_allowed_from; a manifest that overrides any of these fields is invalid. When locales is present, default_locale must also be present.
default_locale
(required when locales is present) The locale tag for the "default" translation of manifest properties. That is, the locale of values not included in the locales map.
installs_allowed_from
(optional) An array of origins that are allowed to trigger installation of this app. This field allows you to explicitly delegate installation privileges to sites or stores with whom you have a relationship. This field must be respected by the app repository (eventually, the user agent). If omitted, installation may be triggered only from the origin where the app is hosted. The array ["*"] means that installations of this app are allowed from any site.
version
(optional) A string that represents the version of the app. The repository does not use this value in any way, but you can embed this string into the manifest and extract it to help deal with various update cases. See the section on updating, below.
widget
(optional) An HTML document that is designed to be rendered inside an {{ HTMLElement("iframe") }} to give users an abbreviated view of your app.
path
The path to the HTML document to be displayed. See Path Handling. If not present, the widget URL is assumed to be the same as the app origin.
width
An integer between 10 and 1000 (inclusive) representing the desired rendered width of the widget.
height
An integer between 10 and 1000 (inclusive) representing the desired rendered height of the widget.

Path handling

All fields which hold paths in the manifest must be absolute paths (for example, '/images/myicon.png'), and are served from the same origin as the app.

Serving manifests

The app manifest must be served from the same origin that the app is served from.

When served from static files, it is RECOMMENDED that the manifest be stored with a file extension of .webapp.  App manifests MUST be served with a Content-Type header of application/x-web-app-manifest+json.  Manifests MAY be served over SSL to mitigate certain classes of attacks.

Le document doit en principe être en UTF-8, mais un autre encodage peut être précisé avec un paramètre charset dans le Content-Type de l'en-tête (i.e. Content-Type: application/x-web-app-manifest+json; charset=ISO-8859-4).

User Agents when possible SHOULD meaningfully message the site identity and TLS status when prompting a user to install an app.

Mise à jour des manifestes

An app respects the normal rules for Web caching, and may optionally use advanced mechanisms for improved start-up, like the HTML5 AppCache. Given this, there are no special considerations for updating the normal resources that an app uses.

Web apps are different, however, in the handling of the manifest. Some changes to a manifest may require user approval. Depending on the implementation of the app repository, it may be unclear whether an update has occurred.

As a clean way to deal with this issue, you can provide a version property in the app manifest. You can later check the version by inspecting the return value of the navigator.mozApps.getInstalledBy() function. If the user's installed version is not up-to-date, you can trigger an update using navigator.mozApps.install().

La valeur attribuée à version est une chaîne qui sera opaque pour le is an opaque string to the repository, so you may use whatever versioning scheme you desire.

Source de la révision

<div class="wikistyle"> <p>{{ TranslationInProgress() }}</p> <p><br> <span style="background-color:#ffff00;">statut : traduction en cours</span></p> <p>Le manifeste d'une application contient toutes les informations dont un navigateur a besoin pour interagir avec elle. Il fournit à la fois des éléments lisibles par un être humain (un nom, un jeu d'icônes et une description, en de multiples langues si nécessaire) et d'autres qui ne sont lisibles que par une machine et permettent au navigateur d'afficher et faire tourner les applications. Le manifeste et l'origine de l'application (protocole, nom de l'hôte et numéro de port) constituent à eux deux la description complète d'une application installée. Le manifeste est encodé dans une structure de données de fichier <a class="external" href="http://www.json.org/" title="http://www.json.org/">JSON</a> ; l'installation d'une application consiste à donner l'URL de ce fichier au navigateur.</p> <p>Pour publier vous-même une application, sur une page qui vous appartient, vous déclenchez son installation (par exemple, en appelant <a href="/en/Apps/Apps_JavaScript_API/navigator.mozApps.install" title="en/Apps/Apps_JavaScript_API/navigator.mozApps.install"><code>navigator.mozApps.install()</code></a> depuis un bouton). Quand un magasin ou une instance autorisée publie une application, il déclenche son installation en fournissant au navigateur l'adresse URL du manifeste de l'application hébergéee.</p> <h2>Un exemple de manifeste</h2> <p>Vous pouvez copier le texte suivant dans un fichier texte et remplacer les valeurs par vos propres informations.</p> <p>{{ syntax.javascript{code: "{\n  \"version\": \"1.0\",\n  \"name\": \"MozillaBall\",\n  \"description\": \"Exciting Open Web development action!\",\n  \"icons\": {\n    \"16\": \"/img/icon-16.png\",\n    \"48\": \"/img/icon-48.png\",\n    \"128\": \"/img/icon-128.png\"\n  },\n  \"widget\": {\n    \"path\": \"/widget.html\",\n    \"width\": 100,\n    \"height\": 200\n  },\n  \"developer\": {\n    \"name\": \"Mozilla Labs\",\n    \"url\": \"http://mozillalabs.com\"\n  },\n  \"installs_allowed_from\": [\n    \"https://appstore.mozillalabs.com\"\n  ],\n  \"locales\": {\n    \"es\": {\n      \"description\": \"¡Acción abierta emocionante del desarrollo del Web!\",\n      \"developer\": {\n        \"url\": \"http://es.mozillalabs.com/\"\n      }\n    },\n    \"fr\": {\n      \"description\": \"Une façon nouvlle et excitante de développer des applications pour le Web!\",\n      \"développeur\": {\n        \"url\": \"http://fr.mozillalabs.com/\"\n      }\n    },\n    \"it\": {\n      \"description\": \"Azione aperta emozionante di sviluppo di fotoricettore!\",\n      \"developer\": {\n        \"url\": \"http://it.mozillalabs.com/\"\n      }\n    }\n  },\n  \"default_locale\": \"en\"\n}\n"} }}</p> <h2>Définition des champs</h2> <p>Voici les champs autorisés dans le manifeste de l'application :</p> <dl> <dt>nom</dt> <dd>Un nom pour l'application, lisible par un être humain, d'un elongueur maximum de 128 caractères).</dd> <dt>description</dt> <dd>A human-readable description of the app (maximum length is 1024 characters).</dd> <dt>launch_path</dt> <dd>(optional) The path within the app's origin that is loaded when the app starts. If not provided, the app's origin is treated as the launch URL. See <a href="#path-handling">Path Handling</a>.</dd> <dt>icons</dt> <dd>(optional) A map of icon sizes to paths (which may be <a href="#path-handling">absolute paths</a>, or data URLs). Each must contain square images that visually represent the app.</dd> <dt>developer</dt> <dd>(optional) Information about the developer of the app, suitable for use in repository and dashboard UIs: <dl> <dt>name</dt> <dd>The name of the developer.</dd> <dt>url</dt> <dd>The URL of a site containing more information about the app's developer. This URL is typically rendered when the user clicks on the name of the app's developer while viewing details about an app inside the dashboard (or browser).</dd> </dl> </dd> <dt>locales</dt> <dd>(optional) A map of locale-specific overrides of the data contained in the manifest, which UIs use to provide localized views. Each locale entry is keyed on a <a class="external" href="http://www.ietf.org/rfc/rfc4646.txt">locale tag</a>, and contains a sparse representation of the manifest; any field that is present in the <code>locale</code> value overrides the matching field in the manifest. Certain fields cannot be overridden, including <code>default_locale</code>, <code>locales</code> itself, and <code>installs_allowed_from</code>; a manifest that overrides any of these fields is invalid. When <code>locales</code> is present, <code>default_locale</code> must also be present.</dd> <dt>default_locale</dt> <dd>(required when <code>locales</code> is present) The locale tag for the "default" translation of manifest properties. That is, the locale of values not included in the <code>locales</code> map.</dd> <dt>installs_allowed_from</dt> <dd>(optional) An array of origins that are allowed to trigger installation of this app. This field allows you to explicitly delegate installation privileges to sites or stores with whom you have a relationship. This field must be respected by the app repository (eventually, the user agent). If omitted, installation may be triggered only from the origin where the app is hosted. The array [<code>"*"]</code> means that installations of this app are allowed from any site.</dd> <dt>version</dt> <dd>(optional) A string that represents the version of the app. The repository does not use this value in any way, but you can embed this string into the manifest and extract it to help deal with various update cases. See the section on updating, below.</dd> <dt>widget</dt> <dd>(optional) An HTML document that is designed to be rendered inside an {{ HTMLElement("iframe") }} to give users an abbreviated view of your app. <dl> <dt>path</dt> <dd>The path to the HTML document to be displayed. See <a href="#path-handling">Path Handling</a>. If not present, the widget URL is assumed to be the same as the app origin.</dd> <dt>width</dt> <dd>An integer between 10 and 1000 (inclusive) representing the desired rendered width of the widget.</dd> <dt>height</dt> <dd>An integer between 10 and 1000 (inclusive) representing the desired rendered height of the widget.</dd> </dl> </dd> </dl> <h3>Path handling <a name="path-handling"></a></h3><a name="path-handling"> <p>All fields which hold paths in the manifest must be absolute paths (for example, '/images/myicon.png'), and are served from the same origin as the app.</p> <h2>Serving manifests</h2> <p>The app manifest must be served from the same origin that the app is served from.</p> <p>When served from static files, it is RECOMMENDED that the manifest be stored with a file extension of <code>.webapp</code>.  App manifests MUST be served with a <code>Content-Type</code> header of <code>application/x-web-app-manifest+json</code>.  Manifests MAY be served over SSL to mitigate certain classes of attacks.</p> <p>Le document doit en principe être en UTF-8, mais un autre encodage peut être précisé avec un paramètre <code>charset</code> dans le <code>Content-Type</code> de l'en-tête (i.e. <code>Content-Type: application/x-web-app-manifest+json; charset=ISO-8859-4</code>).</p> <p>User Agents when possible SHOULD meaningfully message the site identity and TLS status when prompting a user to install an app.</p> <h2>Mise à jour des manifestes</h2> </a><p><a name="path-handling">An app respects the normal rules for Web caching, and may optionally use advanced mechanisms for improved start-up, like the </a><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#offline">HTML5 AppCache</a>. Given this, there are no special considerations for updating the normal resources that an app uses.</p> <p>Web apps are different, however, in the handling of the manifest. Some changes to a manifest may require user approval. Depending on the implementation of the app repository, it may be unclear whether an update has occurred.</p> <p>As a clean way to deal with this issue, you can provide a <code>version</code> property in the app manifest. You can later check the version by inspecting the return value of the <a href="/en/Apps/Apps_JavaScript_API/navigator.mozApps.getInstalledBy" title="en/Apps/Apps_JavaScript_API/navigator.mozApps.getInstalledBy"><code>navigator.mozApps.getInstalledBy()</code></a> function. If the user's installed version is not up-to-date, you can trigger an update using <code><a href="/en/Apps/Apps_JavaScript_API/navigator.mozApps.install" title="https://developer.mozilla.org/en/Apps/Apps_JavaScript_API/navigator.mozApps.install">navigator.mozApps.install()</a>.</code></p> <p>La valeur attribuée à <code>version</code> est une chaîne qui sera opaque pour le is an opaque string to the repository, so you may use whatever versioning scheme you desire.</p>
</div>
Revenir à cette révision