diff options
| author | Marin Ivanov <[email protected]> | 2024-08-21 03:30:16 +0300 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2024-08-21 03:30:16 +0300 |
| commit | 193f4933a8a83ee191b5d3bb8b8b8237dc03bf7d (patch) | |
| tree | 3ee0c8a99c73e60840723267834c1e22a468713b | |
| parent | 3ea3e8694dca23910c10552d24d804b344f7adb9 (diff) | |
make toml config
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile | 11 | ||||
| -rw-r--r-- | config.js | 44 | ||||
| -rw-r--r-- | config.toml | 37 | ||||
| -rw-r--r-- | toml2json.py | 4 |
5 files changed, 50 insertions, 47 deletions
@@ -1,2 +1,3 @@ /main.js /main.css +/config.js @@ -1,8 +1,13 @@ -all: main.js main.css +all: main.js main.css config.js main.js: ka.js app.js - cat $? | esbuild --minify --loader=js > $@ + cat $^ | esbuild --minify --loader=js > $@ main.css: style.css - cat $? | esbuild --minify --loader=css > $@ + cat $^ | esbuild --minify --loader=css > $@ + +config.js: config.toml + echo -n "config=" > $@ + python3 ./toml2json.py < $< >> $@ + echo -n ";" >> $@ diff --git a/config.js b/config.js deleted file mode 100644 index 814371e..0000000 --- a/config.js +++ /dev/null @@ -1,44 +0,0 @@ -config = { - device: "Device Name", - swVersion: "1.0", - hwVersion: "1.0", - sections: { - network: { - title: "Network", - fields: [ - { - id: "macaddr", - type: "mac", - title: "MAC address", - pattern: "[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}", - invalidmsg: "Enter MAC address. E.g. 00:11:22:33:44:55", - required: true, - }, - { - id: "ipaddr", - type: "ip", - title: "IP address", - pattern: "\\d+.\\d+.\\d+.\\d+", - hint: "192.168.4.2", - invalidmsg: "Enter IP address. E.g. 192.168.4.2", - required: true, - }, - { - id: "netmask", - type: "netmask", - title: "Netmask", - pattern: "\\d+.\\d+.\\d+.\\d+", - hint: "255.255.255.0", - invalidmsg: "Enter network mask. E.g. 255.255.255.0", - required: true, - }, - { - id: "gateway", - type: "ip", - title: "Gateway", - pattern: "\\d+.\\d+.\\d+.\\d+", - }, - ], - }, - }, -} diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..f5546a7 --- /dev/null +++ b/config.toml @@ -0,0 +1,37 @@ +device = "Device Name" +swVersion = "1.0" +hwVersion = "1.0" + +[sections] + +[sections.network] +title = "Network" + +[[sections.network.fields]] +id = "macaddr" +title = "MAC address" +pattern = "[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}" +invalidmsg = "Enter MAC address. E.g. 00:11:22:33:44:55" +required = true + +[[sections.network.fields]] +id = "ipaddr" +title = "IP address" +pattern = "\\d+.\\d+.\\d+.\\d+" +hint = "192.168.4.2" +invalidmsg = "Enter IP address. E.g. 192.168.4.2" +required = true + +[[sections.network.fields]] +id = "netmask" +title = "Netmask" +pattern = "\\d+.\\d+.\\d+.\\d+" +hint = "255.255.255.0" +invalidmsg = "Enter network mask. E.g. 255.255.255.0" +required = true + +[[sections.network.fields]] +id = "gateway" +type = "ip" +title = "Gateway" +pattern = "\\d+.\\d+.\\d+.\\d+" diff --git a/toml2json.py b/toml2json.py new file mode 100644 index 0000000..320b414 --- /dev/null +++ b/toml2json.py @@ -0,0 +1,4 @@ +import sys, json, tomllib + +data = tomllib.load(open(0,'rb',closefd=False)) +json.dump(data, sys.stdout, separators=(',',':')) |
