Motivations

  1. Developers need to have the ability to contribute to the Drupal application, without the requirement of knowing Drupal development.
  2. Many apps exist that don't need to be duplicated within Drupal's codebase, and can run as-is without a dedicated server component. Drupal can simply deploy a version of those apps and host the content within it's server.

Definitions

  1. SPA developer - The creator of the external single page app
  2. SPA administrator - anyone with the appropriate role in Drupal to create or edit SPA deployments in Drupal.
  3. SPA - A single page app, that does not change URL (save for hashes) and can be loaded via HTML/CSS/JS and static resources.
  4. SPA in Drupal - The single page app as it exists in the Drupal environment
  5. fields - Drupal configurations per content that define how the SPA should be deployed/downloaded.
  6. Chroming - the theme/styling that defines the Drupal/Customer Portal environment and "sandwiches" the viewed content.

Configuring the Single Page Apps module

The Single Page Apps module comes with a submodule called Single Page Apps configuration (single_page_app_config). This is a Features-based module, that configures the Single Page App content type and fields when the Single Page Apps configuration module is enabled. To restore Single Page Apps settings on your environment, run a feature revert of the Single Page Apps configuration module. After this is done, the following fields will be available on your Single Page App content type:

  1. App Name * - The name of the SPA in Drupal. Used when browsing Drupal's admin content pages.
  2. Body - An optional description for the SPA. Currently not displayed to the end user.
  3. SPA build path - if the deployable app code is housed in a different path from the downloaded tarball/git repo, that can be specified here. If the app code is located in the build/ directory, then "build/" can be entered and Drupal will only link to the build/ directory.
  4. SPA install URL - The default way in which apps will be downloaded/deployed. This should link to a URL that houses a tarball/zip file of the app. Drupal will periodically download this tarball and update the app, if necessary.
  5. SPA install path - The path under Drupal's file system in which the SPA will be saved. Usually a directory name that relates to the App name field.
  6. SPA install file - Alternatively, if the SPA developer wants to install a local tarball/zip file, that can be done with this option by simply uploading the file to Drupal.
  7. SPA index page - if the HTML page to load isn't "index.html" in the root of the build path, that can be specified here ("main.html" for example).
  8. Under URL path settings - URL alias - The URL path which this app will be located at.

There are also several git deployment related fields that may be implemented, but these aren't enabled yet. Those will be enabled once the SPA extras module is completed.

Chroming

An important part of the SPA module is the ability to take configuration out of the SPA developers hands, namely with theming the app inside of the parent environment. With the SPA module, we'll leverage Drupal caching abilities for saving the chrome in cache, and loading this when the single page application content is viewed. The SPA developer only needs to specify where we should insert the chrome on display via these three HTML variables:

A system variable exists at admin/config/content/spa that defines the prefix for where to download this styled chroming from (for example, http://example.com/services/chrome/).

For filesystem chroming, the head/header/footer files can also be saved into templates files, so for Drupal installations these can be specified by setting a Drupal variable in the database:

drush vset single_page_app_tpl 1 - loads the tpl files saved under the SPA module install location

Example tpl files are supplied with the SPA module, but these should be updated to reflect your environments chroming.

Single Page Apps Extras

Included in this module is the option to install Single Page Apps with git deployments. If your Single Page App exists at an external git repository, you can include the git repo to clone from when creating a Single Page App. This requires that Apache has access to run "git" on your Drupal environment.

Note: In order to have oversight over what Single Page Apps are being deployed via git, there is an approval process for allowing these deployments to occur. Once a git-based Single Page App piece of content has been created, the Single Page App will initially be unavailable. A user with permission to approve Single Page Apps must approve the requested git repo under admin/config/content/spa-approval. Once the git repo has been approved, a cron job will deploy the Single Page App on the next run.