From ec4f9cdbdfe8acb2f89d2bd905b7670216c339bd Mon Sep 17 00:00:00 2001 From: DE MERINGO Olivier Date: Fri, 8 Nov 2024 16:40:41 +0100 Subject: [PATCH] doc: how to use local files for development --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b316af2..fd0b646 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,10 @@ It defines a data model that can be used to build an inventory of the tools. - [Data format](#data-format) - [draft dataset](#draft-dataset) - [Example Datami widgets](#example-datami-widgets) - - [Mini server for local development](#mini-server-for-local-development) - - [Run local server](#run-local-server) + - [Local development](#local-development) + - [1. Install the mini server for local development](#1-install-the-mini-server-for-local-development) + - [Run local server](#run-local-server) + - [2. Configure the widget to use the local files](#2-configure-the-widget-to-use-the-local-files) ## Access the data @@ -98,7 +100,14 @@ See [draft dataset](old-examples/ict-sustainability-tools.csv) --- -## Mini server for local development +## Local development + +To ease development and configuration of the widget, we can work with a local data set and local configuration files. + +1. Run a local server to expose the *data* and *configuration* files locally (see below). +2. Modify `index.html` to use the local files (configure the `localdev` properties to `true`). + +### 1. Install the mini server for local development A mini server is written in the `server.py` to serve this folder's files. @@ -122,7 +131,7 @@ source venv/bin/activate --- -### Run local server +#### Run local server To run the server on `http://localhost:8800`: @@ -140,3 +149,31 @@ Files will be locally served on : - `http://localhost:8800/content//` - `http://localhost:8800/statics//` + +### 2. Configure the widget to use the local files + +Modify `index.html` to use the local files (configure the `localdev` properties to `true`) + +```json +{ + "title": "Tools Landscape", + "activate": true, + "localdev": true, + "gitfilelocal": "http://localhost:8800/statics/ictst/data/tools.csv", + "gitfile": "https://github.com/Boavizta/ict-sustainability-tools/blob/main/ictst/data/tools.csv", + +[....] + + "schema": { + "localdev": true, + "filelocal": "http://localhost:8800/statics/ictst/model/tools.frictionless-table-schema.json", + "file": "https://github.com/Boavizta/ict-sustainability-tools/blob/main/ictst/model/tools.frictionless-table-schema.json" + }, + "fields-custom-properties": { + "localdev": true, + "filelocal": "http://localhost:8800/statics/ictst/widget/tools.fields-custom-properties.json", + "file": "https://github.com/Boavizta/ict-sustainability-tools/blob/main/ictst/widget/tools.fields-custom-properties.json" + }, +``` + +💡 You can now open the local `index.html` in a web browser and update data or configurations. Reload the page and changes are immediately visible.