Skip to content

Commit

Permalink
doc: how to use local files for development
Browse files Browse the repository at this point in the history
  • Loading branch information
DE MERINGO Olivier committed Nov 8, 2024
1 parent abf96b1 commit ec4f9cd
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand All @@ -122,7 +131,7 @@ source venv/bin/activate

---

### Run local server
#### Run local server

To run the server on `http://localhost:8800`:

Expand All @@ -140,3 +149,31 @@ Files will be locally served on :

- `http://localhost:8800/content/<path:folder_path>/<string:filename>`
- `http://localhost:8800/statics/<path:folder_path>/<string:filename>`

### 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.

0 comments on commit ec4f9cd

Please sign in to comment.