Proposal #7: Applications Support - geosolutions-it/MapStore GitHub Wiki

Overview

Support MapStore Applications that are composed by a core MapStore together with custom plugins and templates, without the need to create a MapStore branch.

Proposed By

Mauro Bartolomeoli (mbarto), Tobia Di Pisa (tdipisa)

Assigned to Release

TBD, tentatively 1.7

State

Choose one of: Under Discussion, In Progress, Completed, Rejected, Deferred

Motivation

Developing MapStore for several customers, we identified the necessity to build custom plugins and templates that cannot be generalized for common use (and so integrated in the master MapStore repo).

The usual pattern is to create a new branch of MapStore, where the custom stuff resides, together with a full copy of MapStore.

This can be difficult to mantain if we want to be always in synch with the MapStore master.

The issue can be solved using two different repositories for MapStore and the custom stuff. The custom stuff will be packaged into a standard structure, to create a MapStore Application.

Proposal

The MapStore Applications mechanism

An application is basically a tree of files that reside inside the mapcomposer/app/applications/<application_name> folder.

So, each application will have its own root folder, that will reside on a different repository.

Inside the application folder these files will be present:

  • config.js: RingoJS file with endpoints for the application
  • index.js: and other RingoJS that implement a particular endpoint for the application
  • buildjs.cfg: js build file, including custom plugins and needed standard ones
  • templates/app_template.html: one or more custom template for the application
  • static: container folder for the static custom stuff (plugins, widgets, config files, css, images)

The static folder will usually contains:

  • config: folder for application configuration files
  • css: folder for application stylesheet files
  • images: folder for application image files
  • script: folder for application javascript files (plugins, widgets, etc.)

A first prototype together with a sample application can be found here: https://github.com/mbarto/mapstore/tree/mapstore_application

Launching a MapStore application in debug mode

To launch a specific application in debug mode, simply launch the command (from the root MapStore folder):

ant debug -Dapplication=application_name

The application_name is the name of the folder containing the application files.

Building a MapStore application

To build a specific application war, simply launch the command (from the root MapStore folder):

ant war -Dapplication=application_name

The application_name is the name of the folder containing the application files.

Feedback

This section should contain feedback provided by members who may have a problem with the proposal.

Tobia Di Pisa:

  • Why we need the config.js file? We can't manage this internally in MapStore (i.e. defining an external templates configuration that can be used inside the core config.js)?
  • I think that the buildjs.cfg should overrides single dependency blocks.

Mauro Bartolomeoli: I am going to investigate if both requests (that make sense) are quite simple to implement for a first release.

Lorenzo Pini:
The static files loading order can be changed from "MapStore first" to "Application first".
For example, the application may want to override some original files with others with the same name.
To enable this behaviour, the config.js of the application must be modified to check for static files into the application folder first:

middleware.unshift(require("ringo/middleware/static").middleware({base: module.resolve("static")}));

Note the "unshift" instead of the "push"

Backwards Compatibility

Voting

Mauro Bartolomeoli:+1:

Lorenzo Natali :+1:

Lorenzo Pini: :+1:

Tobia Di Pisa:+1: