Installing BWEB

BWEB ships in the BSPK Tools component, which bundles every BSPOKE tool: BWEB, the ATL, code and method execution, the JSON object editor. Installation happens in two stages: 4D loads the component as a dependency of your project, then the component's wizard installs BWEB into your database.

Before you start

  • 4D 21. The component is built for 4D 21: its version number starts with 4D's (for instance 21.6.85).
  • A 4D project, new or existing, opened locally and not compiled: the wizard refuses to run otherwise.
  • Internet access on first start: 4D downloads the component and its own dependencies from GitHub, then keeps them in cache.
  • Node.js: BWEB needs it to build its stylesheets. If it is missing, the wizard offers to install it.

1. Declare the component

The component is published on GitHub, in the public bspoke-dev/BSPK-Tools repository, where every version is listed. You declare it as a dependency of your project, from 4D:

  1. Menu Design > Project Dependencies.
  2. Click the + button at the bottom of the window, then choose the GitHub tab.
  3. Enter the repository path: bspoke-dev/BSPK-Tools.
  4. Choose Exact Version (Tag) with a tag such as 21.6.85: you decide when to move to the next version. Click Add.
  5. The dependency is listed as Available after restart: restart 4D.

On restart, the component is downloaded, and it pulls the official 4D components it needs by itself: there is nothing else to declare. The dependencies window then lists BSPK Tools with its version, next to 4D NetKit, 4D Progress, 4D SVG and 4D Widgets.

The window only writes the project's Project/Sources/dependencies.json file. You can also declare the component there directly:

{
  "dependencies": {
    "BSPK Tools": {
      "github": "bspoke-dev/BSPK-Tools",
      "tag": "21.6.85"
    }
  }
}

What about the Components folder? Copying the component into the project's Components folder, as with older versions, still works. A dependency is nevertheless the recommended method: it is the 4D standard, and moving to a new version is done from the dependencies window, without handling any folder.

2. Run the wizard

Run the _BSPK_LAUNCH method. It opens the component's launcher, which gives access to every tool. Click BWEB. As long as BWEB is not installed, the launcher first shows Before installing: the list of the changes the installation will make to your database, based on its current state. Read it, then click I have read these changes and I accept them. Accept the licence, then click Start installation.

The wizard lists its steps and ticks them as it goes. They fall into these groups:

  1. Environment: prerequisite check, Node.js and npm installation if needed, libraries, and stylesheet build.
  2. Web server: 4D web server configuration and SSL certificate installation. The wizard asks for your cert.pem and key.pem files; you can continue without them for a local trial.
  3. Files and methods: the web folder, configuration files and BSPH_* methods are copied into your project; the On Startup, On Web Connection and On Exit database methods (and their server counterparts) are modified. The existing code of On Web Connection is commented out, line by line; some of the added lines, including the toolbar one, are commented out too: see The launcher, startup and the toolbar.
  4. Structure: the BSPK_* tables are created, with their relations and indexes. Your application restarts at this step: that is expected, and installation resumes on its own.
  5. First domain: the wizard asks for the name of your first site, then offers to add it to the machine's hosts file so that it answers locally. Changing the hosts file requires administrator rights. If you decline, or if the change fails, the step shows an error; on failure, a message gives the line to add yourself.

The BSPK_* tables added to your structure belong to BWEB: do not delete or rename them.

The installation also copies parameter file templates, including DEV_PARAMETERS: a fresh installation therefore starts in DEV mode. On a production server, delete DEV_PARAMETERS and PREPROD_PARAMETERS.

Installing BWEB in a database that already serves web pages

The Before installing screen details these changes for your database. In short:

  • On Web Connection: its code is commented out, line by line, under a dated line, and replaced by the call to BWEB. The routes it handled stop answering until you move them to the BSPH_WEB_ON_CONNECTION method, which BWEB calls on every request. It receives the client's IP address: $vo_Param.vt_Browser_IP, and vt_ClientIp, the real address behind a declared proxy. To handle a request yourself, send the response (WEB SEND TEXT…) and return True; return False, or nothing, to let BWEB handle it.
  • Web settings: the HTML root becomes ./bweb and the session mode becomes 1. Pages served from the former root are no longer served.
  • Privileges: roles.json is replaced; the original is kept in roles.json.backup.
  • .gitignore: if there is one, it is completed (parameter files, installation state, bweb_dependencies, generated CSS, certificates). It is never created.
  • Compilation: a Compiler_BSPH method is added. It declares the variables of the BSPH_* methods for databases whose compilation requires every variable to be declared in Compiler_ methods.

There is no uninstall: these changes stay in place if you remove the component.

3. Check

At the end, click Test BWEB in the launcher: your browser opens your domain's administration, at https://<your domain>/bweb. If you continued without a certificate, or with a self-signed one, the browser shows a security warning: you can proceed for a local trial.

If the login page appears, BWEB is installed.

What next