UNPKG

18.3 kBMarkdownView Raw
1# ember-web-app
2[![Build Status](https://travis-ci.org/san650/ember-web-app.svg?branch=master)](https://travis-ci.org/san650/ember-web-app)
3[![Ember Observer Score](https://emberobserver.com/badges/ember-web-app.svg)](https://emberobserver.com/addons/ember-web-app)
4
5This Ember addon helps you configure and manage the web app manifest and related meta tags needed to create a Progressive Web Application
6
7From [MDN](https://developer.mozilla.org/en-US/docs/Web/Manifest)
8
9> The web app manifest provides information about an application (such as name,
10> author, icon, and description) in a text file. The purpose of the manifest is
11> to install web applications to the homescreen of a device, providing users
12> with quicker access and a richer experience.
13
14Addon features:
15
16* Generates a manifest.ember-web-app.json file using a JavaScript template
17* Uses fingerprint for images
18* Generates equivalent meta tags for supporting other devices (e.g. iPhone)
19* Validates the configuration
20
21Here's a brief list of the main missing features that we intend to add in the future.
22
23* Generate image variants for different devices
24* Generate Microsoft's browserconfig.xml manifest for Win8/Win10 integration
25
26See the [documentation](#documentation) section below for more information.
27
28## Table of content
29
30* [Installation](#installation)
31* [Example](#example)
32* [Configuration](#configuration)
33 * [Disable](#disable)
34 * [Fingerprint](#fingerprint)
35* [API documentation](#api-documentation)
36 * [`name`](#name)
37 * [`short_name`](#short_name)
38 * [`background_color`](#background_color)
39 * [`description`](#description)
40 * [`dir`](#dir)
41 * [`display`](#display)
42 * [`icons`](#icons)
43 * [`lang`](#lang)
44 * [`orientation`](#orientation)
45 * [`prefer_related_applications`](#prefer_related_applications)
46 * [`related_applications`](#related_applications)
47 * [`scope`](#scope)
48 * [`start_url`](#start_url)
49 * [`theme_color`](#theme_color)
50 * [`apple`](#apple)
51 * [`apple.statusBarStyle`](#applestatusbarstyle)
52 * [`apple.precomposed`](#appleprecomposed)
53 * [`apple.formatDetection`](#appleformatdetection)
54* [Development](#development)
55* [Project's health](#projects-health)
56* [License](#license)
57
58## Installation
59
60```sh
61$ ember install ember-web-app
62```
63
64This generates a config/manifest.js configuration file.
65
66## Example
67
68Having the following configuration file `config/manifest.js`
69
70```js
71module.exports = function() {
72 return {
73 name: "Let's Cook",
74 short_name: "Let's Cook",
75 description: "An app for organizing your weekly menu and groceries list.",
76 start_url: "/",
77 display: "standalone",
78 background_color: "#ffa105",
79 theme_color: "#ffa105",
80
81 icons: [
82 {
83 src: "/images/icons/android-chrome-192x192.png",
84 sizes: "192x192",
85 type: "image/png"
86 },
87 {
88 src: "/images/icons/android-chrome-512x512.png",
89 sizes: "512x512",
90 type: "image/png"
91 },
92 {
93 src: "/images/icons/apple-touch-icon.png",
94 sizes: "180x180",
95 type: "image/png",
96 targets: ['apple']
97 }
98 ],
99
100 apple: {
101 statusBarStyle: 'black-translucent'
102 }
103 }
104}
105```
106
107It will generate the following meta tags
108
109`index.html`
110
111```html
112<link rel="manifest" href="/manifest.webmanifest">
113<link rel="apple-touch-icon" href="/images/icons/android-chrome-192x192-883114367f2d72fc9a509409454a1e73.png" sizes="192x192">
114<link rel="apple-touch-icon" href="/images/icons/android-chrome-512x512-af3d768ff652dc2be589a3c22c6dc827.png" sizes="512x512">
115<link rel="apple-touch-icon" href="/images/icons/apple-touch-icon-36cba25bc155e8ba414265f9d85861ca.png" sizes="180x180">
116<meta name="theme-color" content="#ffa105">
117<meta name="apple-mobile-web-app-capable" content="yes">
118<meta name="apple-mobile-web-app-title" content="Let's Cook">
119<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
120```
121
122and the following `manifest.webmanifest` file
123
124```json
125{
126 "name": "Let's Cook",
127 "short_name": "Let's Cook",
128 "description": "An app for organizing your weekly menu and groceries list.",
129 "start_url": "/",
130 "display": "standalone",
131 "background_color": "#ffa105",
132 "theme_color": "#ffa105",
133 "icons": [
134 {
135 "src": "/images/icons/android-chrome-192x192-883114367f2d72fc9a509409454a1e73.png",
136 "sizes": "192x192",
137 "type":"image/png"
138 },
139 {
140 "src": "/images/icons/android-chrome-512x512-af3d768ff652dc2be589a3c22c6dc827.png",
141 "sizes": "512x512",
142 "type": "image/png"
143 }
144 ]
145}
146```
147
148## Configuration
149
150### Disable
151
152You can disable the addon by adding a configuration option to `ember-cli-build.js` build file.
153
154```js
155var EmberApp = require('ember-cli/lib/broccoli/ember-app');
156
157module.exports = function(defaults) {
158 var options = {
159 'ember-web-app': {
160 enabled: false
161 }
162 };
163
164 var app = new EmberApp(defaults, options);
165
166 return app.toTree();
167};
168```
169
170### Fingerprint
171
172You can add fingerprint checksum to your manifest.webmanifest file by configuring [broccoli-asset-rev](https://github.com/rickharrison/broccoli-asset-rev).
173
174The following example prepends with a custom domain and adds fingerprint checksum to the manifest.webmanifest file.
175
176`ember-cli-build.js`
177
178```js
179var EmberApp = require('ember-cli/lib/broccoli/ember-app');
180
181module.exports = function(defaults) {
182 var defaultExtensions = ['js', 'css', 'png', 'jpg', 'gif', 'map'];
183 var options = {
184 fingerprint: {
185 extensions: defaultExtensions.concat(['webmanifest']),
186 prepend: 'https://www.example.com/'
187 }
188 };
189
190 var app = new EmberApp(defaults, options);
191
192 return app.toTree();
193};
194```
195
196Note that the `replaceExtensions` configuration from `broccoli-asset-rev` is updated internally by `ember-web-app` so you don't have to configure yourself on your project.
197
198## API documentation
199
200This Ember addon generates a [Web Application Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) at build time using the `config/manifest.js` configuration file.
201
202It also generates some compatibility meta tags for supporting vendor specific web application features like Apple's [Web Content For Safari](https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/Introduction/Introduction.html) and Microsoft's [Browser configuration schema](https://msdn.microsoft.com/en-us/library/dn320426%28v=vs.85%29.aspx) that don't yet support the Web Application Manifest standard.
203
204Internally, this addon takes into account four different types of targets for generating the web app manifest taking care of including some backward compatibility meta tags in order to support as many devices and browsers as possible. These targets are:
205
206* manifest (default target)
207* apple (to target iOS devices)
208* ms (to target Win8/Win10 devices)
209* android (to target options specific for android devices)
210
211Not all targets are used for all properties (actually, most properties are not affected by the targets).
212
213### List of supported properties.
214
215* [`name`](#name)
216* [`short_name`](#short_name)
217* [`background_color`](#background_color)
218* [`description`](#description)
219* [`dir`](#dir)
220* [`display`](#display)
221* [`icons`](#icons)
222* [`lang`](#lang)
223* [`orientation`](#orientation)
224* [`prefer_related_applications`](#prefer_related_applications)
225* [`related_applications`](#related_applications)
226* [`scope`](#scope)
227* [`start_url`](#start_url)
228* [`theme_color`](#theme_color)
229* [`apple.statusBarStyle`](#applestatusbarstyle)
230
231#### `name`
232
233> Provides a human-readable name for the application as it is intended to be displayed to the user, for example among a list of other applications or as a label for an icon.
234
235Example
236
237```js
238manifest.name = "dummy";
239```
240
241| Target | Generates |
242| --- | --- |
243| `manifest` | `{ "name": "dummy" }`
244| `apple` | `<meta name="apple-mobile-web-app-title" content="dummy">`
245| `ms` | `<meta name="application-name" content="dummy">`
246| `android` | does not apply
247
248#### `short_name`
249
250> Provides a short human-readable name for the application. This is intended for use where there is insufficient space to display the full name of the web application.
251
252Example
253
254```js
255manifest.short_name = "dummy";
256```
257
258| Target | Generates |
259| --- | --- |
260| `manifest` | `{ "short_name": "dummy" }`
261| `apple` | does not apply
262| `ms` | does not apply
263| `android` | does not apply
264
265#### `background_color`
266
267> Defines the expected background color for the web application.
268
269Example
270
271```js
272manifest.background_color = "#fff";
273```
274
275| Target | Generates |
276| --- | --- |
277| `manifest` | `{ "background_color": "#fff" }`
278| `apple` | does not apply
279| `ms` | does not apply
280| `android` | does not apply
281
282#### `description`
283
284> Provides a general description of what the web application does.
285
286Example
287
288```js
289manifest.description = "Lorem ipsum dolor";
290```
291
292| Target | Generates |
293| --- | --- |
294| `manifest` | `{ "description": "Lorem ipsum dolor" }`
295| `apple` | does not apply
296| `ms` | does not apply
297| `android` | does not apply
298
299#### `dir`
300
301> Specifies the primary text direction for the `name`, `short_name`, and description members.
302
303Possible values:
304 * ltr (left-to-right)
305 * rtl (right-to-left)
306 * auto
307
308Example
309
310```js
311manifest.dir = "ltr";
312```
313
314| Target | Generates |
315| --- | --- |
316| `manifest` | `{ "dir": "ltr" }`
317| `apple` | does not apply
318| `ms` | does not apply
319| `android` | does not apply
320
321#### `display`
322
323> Defines the developer's preferred display mode for the web application.
324
325Possible values:
326 * fullscreen
327 * standalone
328 * minimal-ui
329 * browser
330
331The default value for `display` is `browser` when is not defined.
332
333Example
334
335```js
336manifest.display = "fullscreen";
337```
338
339| Target | Generates |
340| --- | --- |
341| `manifest` | `{ "display": "fullscreen" }`
342| `apple` | `<meta name="apple-mobile-web-app-capable" content="yes">`
343| `ms` | does not apply
344| `android` | does not apply
345
346__Note that for iOS the meta tag will be render with value `yes` only when display is `fullscreen` or `standalone`.__
347
348#### `icons`
349
350> Specifies an array of image objects that can serve as application icons in various contexts. For example, they can be used to represent the web application amongst a list of other applications, or to integrate the web application with an OS's task switcher and/or system preferences.
351
352Image object members:
353 * `src` The path to the image file.
354 * `sizes` A string containing space-separated image dimensions.
355 * `type` A hint as to the media type of the image.
356 * `targets` **Non standard** Targets for the images. ['manifest', 'apple'] by default.
357
358Example
359
360```js
361icons: [
362 {
363 src: '/foo/bar.png',
364 sizes: '180x180'
365 },
366 {
367 src: '/bar/baz.png',
368 sizes: '280x280',
369 targets: ['apple'] // non-standard property
370 },
371 {
372 src: '/bar/fav.png',
373 sizes: '32x32',
374 targets: ['favicon']
375 }
376];
377```
378
379| Target | Generates |
380| --- | --- |
381| `manifest` | `{ "icons": [ { "src": "/foo/bar.png", "sizes": "180x180" } ] }`
382| `apple` | `<link rel="apple-touch-icon" href="/foo/bar.png" sizes="180x180">` `<link rel="apple-touch-icon" href="/foo/bar.png" sizes="280x280">`
383| `ms` | does not apply (for now)
384| `android` | does not apply
385| `favicon` | `<link rel="icon" href="/bar/fav.png" sizes="32x32">`
386
387#### `lang`
388
389> Specifies the primary language for the values in the name and short_name members.
390
391Example
392
393```js
394manifest.lang = "es-UY";
395```
396
397| Target | Generates |
398| --- | --- |
399| `manifest` | `{ "lang": "es-UY" }`
400| `apple` | does not apply
401| `ms` | does not apply
402| `android` | does not apply
403
404#### `orientation`
405
406> Defines the default orientation for all the web application's top level browsing contexts.
407
408Possible values:
409 * any
410 * natural
411 * landscape
412 * landscape-primary
413 * landscape-secondary
414 * portrait
415 * portrait-primary
416 * portrait-secondary
417
418Example
419
420```js
421manifest.orientation = "portrait";
422```
423
424| Target | Generates |
425| --- | --- |
426| `manifest` | `{ "orientation": "portrait" }`
427| `apple` | does not apply
428| `ms` | does not apply
429| `android` | does not apply
430
431#### `prefer_related_applications`
432
433> Specifies a boolean value that hints for the user agent to indicate to the user that the specified related applications are available, and recommended over the web application.
434
435Possible values:
436 * true
437 * false
438
439Example
440
441```js
442manifest.prefer_related_applications = true;
443```
444
445| Target | Generates |
446| --- | --- |
447| `manifest` | `{ "prefer_related_applications": true }`
448| `apple` | does not apply
449| `ms` | does not apply
450| `android` | does not apply
451
452#### `related_applications`
453
454> Specifies an array of "application objects" representing native applications that are installable by, or accessible to, the underlying platform.
455
456Application object members:
457 * `platform` The platform on which the application can be found.
458 * `url` The URL at which the application can be found.
459 * `id` The ID used to represent the application on the specified platform.
460
461Example
462
463```js
464manifest.prefer_related_applications = true;
465manifest.related_applications = [
466 {
467 "platform": "itunes",
468 "url": "https://itunes.apple.com/app/example-app1/id123456789"
469 }
470];
471```
472
473| Target | Generates |
474| --- | --- |
475| `manifest` | `{ "prefer_related_applications": true, "related_applications": [{"platform": "itunes", "url": "https://itunes.apple.com/app/example-app1/id123456789" }] }`
476| `apple` | does not apply
477| `ms` | does not apply
478| `android` | does not apply
479
480#### `scope`
481
482> Defines the navigation scope of this web application's application context. This basically restricts what web pages can be viewed while the manifest is applied.
483
484Example
485
486```js
487manifest.scope = "/myapp/";
488```
489
490| Target | Generates |
491| --- | --- |
492| `manifest` | `{ "scope": "/myapp/" }`
493| `apple` | does not apply
494| `ms` | does not apply
495| `android` | does not apply
496
497#### `start_url`
498
499> Specifies the URL that loads when a user launches the application from a device.
500
501Example
502
503```js
504manifest.start_url = "./?utm_source=web_app_manifest";
505```
506
507| Target | Generates |
508| --- | --- |
509| `manifest` | `{ "start_url": "./?utm_source=web_app_manifest" }`
510| `apple` | does not apply
511| `ms` | does not apply
512| `android` | does not apply
513
514#### `theme_color`
515
516> Defines the default theme color for an application. This sometimes affects how the application is displayed by the OS.
517
518Example
519
520```js
521manifest.theme_color = "aliceblue";
522```
523
524| Target | Generates |
525| --- | --- |
526| `manifest` | `{ "theme_color": "aliceblue" }`
527| `apple` | does not apply
528| `ms` | does not apply
529| `android` | `<meta name="theme-color" content="aliceblue">`
530
531### Vendor specific properties (non-standard)
532
533#### `apple`
534
535> Turns on/off the generation of apple specific meta and link tags.
536
537Possible values:
538 * `true` Turn on. This is the default value.
539 * `false` Turn off.
540 * An object with custom settings (see the settings below)
541
542Example
543
544```js
545manifest.apple = false;
546```
547
548| Target | Generates |
549| --- | --- |
550| `manifest` | `{ "apple": false }`
551| `apple` | __returns an empty string__
552| `ms` | does not apply
553| `android` | does not apply
554
555#### `apple.statusBarStyle`
556
557> Sets the style of the status bar for a web application in iOS
558
559See [Changing the Status Bar Appearance](https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html#//apple_ref/doc/uid/TP40002051-CH3-SW1)
560
561Possible values:
562 * `default` The status bar appears normal.
563 * `black` The status bar has a black background.
564 * `black-translucent` The status bar is black and translucent.
565
566Note that if set to default or black, the web content is displayed below the status bar. If set to black-translucent, the web content is displayed on the entire screen, partially obscured by the status bar.
567
568Example
569
570```js
571manifest.apple = {
572 statusBarStyle: 'black-translucent'
573};
574```
575
576| Target | Generates |
577| --- | --- |
578| `manifest` | does not apply
579| `apple` | `<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">`
580| `ms` | does not apply
581| `android` | does not apply
582
583#### `apple.precomposed`
584
585> Adds `precomposed` suffix to apple touch icons
586
587See [Precomposed Keyword for apple touch icons](https://mathiasbynens.be/notes/touch-icons#effects)
588
589Possible values:
590 * `true` Adds precomposed suffix.
591 * `false` (default) Does not add precomposed suffix.
592
593Example
594
595```js
596manifest.apple = {
597 precomposed: 'true'
598};
599```
600
601| Target | Generates |
602| --- | --- |
603| `manifest` | does not apply
604| `apple` | `<link rel="apple-touch-icon-precomposed" href="/images/icons/apple-touch-icon-192x192.png" sizes="192x192">`
605| `ms` | does not apply
606| `android` | does not apply
607
608#### `apple.formatDetection`
609
610> Adds `format-detection` meta tag if needed
611
612See [Safari HTML Reference](https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW5)
613
614Possible values:
615 * An object with following settings
616 * `telephone: false` Disables automatic phone number detection.
617
618Example
619
620```js
621manifest.apple = {
622 formatDetection: {
623 telephone: false
624 }
625};
626```
627
628| Target | Generates |
629| --- | --- |
630| `manifest` | does not apply
631| `apple` | `<meta name="format-detection" content="telephone=no">`
632| `ms` | does not apply
633| `android` | does not apply
634
635## Development
636
637```sh
638$ git clone https://github.com/san650/ember-web-app.git
639$ cd $_
640$ yarn # (or npm install)
641```
642
643Running tests
644
645```sh
646$ npm test
647```
648
649## Project's health
650
651[![Build Status](https://travis-ci.org/san650/ember-web-app.svg?branch=master)](https://travis-ci.org/san650/ember-web-app)
652[![Ember Observer Score](https://emberobserver.com/badges/ember-web-app.svg)](https://emberobserver.com/addons/ember-web-app)
653
654## License
655
656ember-web-app is licensed under the MIT license.
657
658See [LICENSE](./LICENSE) for the full license text.