Class PWAOfflinePage

java.lang.Object
com.iizix.pwa.PWAOfflinePage

public final class PWAOfflinePage extends Object
The offline page of an application, /app/<appID>/offline.html?lang=<lang> (work order CC-PWA-V5C-APP-WORKER; design CC-DESIGN-APP-URL-V2 section 2.5, PWA-DESIGN section 7.1): what an installed application shows when its server is out of reach - the application's Service Worker precaches one per language at install and answers a navigation with it when the network fails. Branded with the application's name and theme colour, localised, and it reconnects by itself: the page probes the application's URL with growing pauses, at once when the Browser reports the network back or the page becomes visible again, and at a tap on its button, and replaces itself with the application as soon as the server answers.

Everything is inline - styles, script, no image, no font, no other request - because the page is shown precisely when nothing else can be loaded. It is generated, not a file, like the worker: the wiring is the application directory's (order V5-E).

The texts exist in the languages the client itself is localised in (iz/strings_en.js and iz/loc/strings_*.js: English, German, Spanish, French, Italian, Japanese, Russian, Swedish and Chinese); any other language gets the English texts, in a page whose lang is still the requested one.

Author:
Christopher Mindus
  • Field Details

    • FILE_NAME

      public static final String FILE_NAME
      The name of the page in the application's directory.
      See Also:
    • DEFAULT_THEME_COLOR

      public static final String DEFAULT_THEME_COLOR
      The default theme colour when the application has none or an invalid one: the dark text colour of the IIZI pages.
      See Also:
    • LANGUAGES

      public static final Set<String> LANGUAGES
      The language codes the page has texts for, lower case.
  • Method Details

    • html

      public static String html(String appID, String appName, String language, String themeColor)
      Generates the offline page of an application in one language.
      Parameters:
      appID - The canonical application ID: the page probes and reopens /app/<appID>/, with ?lang= when a language is given.
      appName - The application's name in the language, null or empty for the ID.
      language - The language code the page is for (the lang entry parameter, as the directory resolved it), null or empty for the default language: it is the page's lang, selects the texts, and is carried back to the application's URL.
      themeColor - The application's theme colour, null or invalid for the default.
      Returns:
      The page, a complete HTML document, LF line ends.
      Throws:
      IllegalArgumentException - If the application ID is not a valid one.