Skip to content

Standalone

benloh edited this page Aug 20, 2025 · 3 revisions

Standalone Mode

Standalone Mode allows you to create a static version of a Net.Create graph that can be hosted on a static web server.

  • Nodes and Edges are read-only
  • Nodes, Edges, Tables, and Filters are all interactive
  • Comments can be viewed, but not added

You will need a static web server to host the files.

Tip

You can use python3 -m http.server to start a static server on your local Mac (assuming you have python3 installed). You can also set the port using python3 -m http.server 4000 (python defaults to port 8000).

Saving Data for Standalone Mode

To save the data from the last run to publish on a standalone read-only web server:

Caution

Make sure the project's template is set to NOT require login. Standalone mode does not have a login form. If requireLogin is set, no graph will be displayed. However, you can still view the graph by adding the login to the url, e.g. http://localhost:3000/#/edit/A-B-G3X. You can use this method to hide graphs from anyone without the special URL.

  1. open Terminal and cd to the project's build directory (e.g. cd ~/dev/netcreate-itest/)
  2. load and run the database you want to publish, e.g. ./nc.js --dataset=tacitus
  3. hit Ctrl-C to quite the app.
  4. type npm run package to generate the standalone files.
  5. copy the files in /public to your web server.
  6. point your browser to the web server to view the data.

See Pull Request #46 for more information.

Loading Data in Standalone Mode

bb7b12c introduced a hack for loading arbitrary databases.

Standalone mode uses JSON data files to load the graph data. Since these are no longer directly used, you need to use npm run package to build the necessary JSON files.

To target a specific database:

  1. Make sure you have a JSON data file in /app-data/*.json . If you don't have a *.json file available:

    1. ./nc.js --dataset=<yourdbname> -- Make sure the database gets created and that NC_CONFIG is set. Running nc.js will do this.

    2. npm run package -- This should create and copy both <yourdb>.json and <yourdb>.template.toml files into /app-data, and then /public/data

      [!WARNING] npm run package will overwrite both the current dataset's *.json and *.template.toml as well as the standalone-db.json and standalone.template.toml files.

    3. Confirm that you have a file named /public/data/<yourdbname>.json

  2. Set up your server -- Copy all the /public folders to your server.

  3. And add ?dataset=name to the url (right before the #, with no space or punctuation)

For example: http://netcreate.org/SampleNetworks/Package/#/

Becomes: http://netcreate.org/SampleNetworks/Package/?dataset=<yourdbname>#/

NOTES:

  • To debug standalone mode, use npm run package:debug to get live updates

How Standalone Mode Works

Overview

  • When you run npm run package
    1. *.json and standalone-db.json files are created using the current database (as defined in NC_CONFIG).
    2. *.template.toml and standalone.template.toml files are copied from the current database.
    3. static files are generated in the /public folder.
    4. db and template files in /app-data are copied over to /public/data
  • Copy these to a static web server and point the browser at the index.html file.

The database that is generated for the standalone server is the current dataset as defined in your NC_CONFIG. e.g. if you used ./nc.js --dataset=tacitus to create the database, when you run npm run package and start your static server, the dataset will be tacitus. This is saved as standalone-db.json and standalone.template.toml.

Any files in /app-data are automatically copied over to /public/data, so over time you can build multiple databases that can be called up -- the one loaded by default is the last one you used when you called npm run package.

Method Static URL Source Data "Packaged" Location Public Location
default http://< server >/index.html /runtime/tacitus.loki /app-data/standalone-db.json /public/data/standalone-db.json
dataset=xxx override http://< server >/index.html?dataset=tacitus /runtime/tacitus.loki /app-data/tacitus-db.json /public/data/tacitus-db.json
Clone this wiki locally