Skip to main content

Overview

Overview

The "reader," codename Volpe, is a single-page web application (SPA) designed for the sole purpose of enabling users to read, listen to, and interact with content. While content can originate from various formats such as PDF, EPUB, or Audiobooks, all content undergoes preprocessing and optimization before being used within the reader.

The reader is always embedded within a host, referred to as volpe_host. The host is responsible for:

  • Bootstrapping the reader.
  • Providing essential metadata and session details.
  • Acting as a proxy or gateway between the reader and the broader Publica.la platform.

The reader cannot function independently; it must be embedded within a host.

Embedding Methods

The reader is embedded differently depending on the host type:

  • Web: Embedded using a secured <iframe>.
  • Mobile and Desktop Apps: Embedded using a WebView (platform-specific implementations for iOS, Android, and Electron).

Reader Host Interaction

Host Components

  1. reader-host-template.html:

    • Contains an <iframe> element for loading the reader.
    • Initially, the <iframe> does not have an src attribute, allowing controlled loading.
  2. reader-host-manager.js:

    • Responsible for bootstrapping the reader (Volpe).
    • Sends publication metadata and configuration to the reader.
    • Acts as a communication bridge between the reader and the host.

Reader Load Sequence

  1. The host initiates the loading of the reader's index.html.
  2. When the onload event triggers, the host sends a setHostLocation event to the reader, including the host's location:
    {
    "hostLocation": "window.location.href"
    }
    • This ensures precise communication between the host and the reader using the postMessage API.
  3. The reader continues loading and, once ready, emits a readerInitialized event.
  4. The host listens for readerInitialized and responds with readingSessionData, providing full session details to complete the loading process.

Events and Communication

Events from Reader to Host

The reader communicates key events to the host, including:

  1. readerInitialized - Signals that the reader is ready to receive content and configuration.
  2. close - Requests the host to close the reader.
  3. locationChanged - Notifies the host of content position changes.
  4. shareContent - Provides shareable content details for the OS's native sharing UI.
  5. favoriteIssuesToggler - Requests the host to toggle a publication as a favorite.

Events from Host to Reader

The reader expects the following events from the host: 6. setHostLocation - Provides the host's URL for accurate communication. 7. **readingSessionData


X

Graph View