Skip to content

Commit 619e069

Browse files
committed
add json schemas
provides the ability to use autocompletion and validation on all editors that supports json schemas.
1 parent d80445b commit 619e069

File tree

6 files changed

+314
-0
lines changed

6 files changed

+314
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: "Edit JSON files with vscode"
3+
description: "edit json files locally"
4+
bookCollapseSection: true
5+
---
6+
7+
# Edit JSON files with vscode
8+
9+
You can use a json schema which can provide you the ability for autocompletion and validation in your favorite editor. This article describes it for vscode.
10+
11+
Schemas:
12+
13+
* [content-json-schema.json](/teddyCloud/tecdoc/content-json-schema.json)
14+
* [tonies-custom-json-schema.json](/teddyCloud/tecdoc/tonies-custom-json-schema.json)
15+
* [tonieboxes-custom-json-schema.json](/teddyCloud/tecdoc/tonieboxes-custom-json-schema.json)
16+
* [plalist-tap-json-schema.json](/teddyCloud/tecdoc/plalist-tap-json-schema.json)
17+
18+
## content.json
19+
20+
Add the Schemaurl to the json file.
21+
22+
Example:
23+
24+
```json
25+
{
26+
"$schema": "{{< siteurl >}}teddyCloud/tecdoc/content-json-schema.json",
27+
"live": false,
28+
"nocloud": false,
29+
"source": "",
30+
"skip_seconds": 0,
31+
"cache": false,
32+
"cloud_ruid": "",
33+
"cloud_auth": "",
34+
"cloud_override": false,
35+
"tonie_model": "",
36+
"_version": 5
37+
}
38+
39+
```
40+
41+
## tonies.custom.json / tonieboxes.custom.json
42+
43+
To configure this for vscode you have to edit `.vscode/settings.json`.
44+
45+
Add the following parts to the `settings.json`:
46+
47+
```json
48+
{
49+
"json.schemaDownload.enable": true,
50+
"json.schemas": [
51+
{
52+
"fileMatch": ["tonies.custom.json"],
53+
"url": "{{< siteurl >}}teddyCloud/tecdoc/tonies-custom-json-schema.json"
54+
},
55+
{
56+
"fileMatch": ["tonieboxes.custom.json"],
57+
"url": "{{< siteurl >}}teddyCloud/tecdoc/tonieboxes-custom-json-schema.json"
58+
}
59+
]
60+
}
61+
```
62+
63+
## Plalist (TAP) Files
64+
65+
```json
66+
{
67+
"$schema": "{{< siteurl >}}teddyCloud/tecdoc/plalist-tap-json-schema.json",
68+
"type": "tap",
69+
"audio_id": 0,
70+
"filepath": "lib://by/tapID/radio.taf",
71+
"name": "Radio",
72+
"files": [
73+
{
74+
"filepath": "lib://by/audioID/1234567890.taf",
75+
"name": "Hörspiel Tonie"
76+
},
77+
{
78+
"filepath": "lib://mp3/album/title.mp3",
79+
"name": "A Song"
80+
},
81+
{
82+
"filepath": "http://nas.intranet/musiclibrary/album/song.mp3",
83+
"name": "Network Audio"
84+
}
85+
]
86+
}
87+
```

layouts/shortcodes/siteurl.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ .Site.BaseURL }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Tonie Configuration Schema",
4+
"type": "object",
5+
"additionalProperties": false,
6+
"properties": {
7+
"live": {
8+
"type": "boolean",
9+
"default": false,
10+
"description": "Always start the content from the beginning and redownload its content"
11+
},
12+
"nocloud": {
13+
"type": "boolean",
14+
"default": false,
15+
"description": "Do not sync the TAF with the boxine cloud"
16+
},
17+
"source": {
18+
"type": "string",
19+
"default": "",
20+
"description": "Use this TAF as content or convert this file into a TAF (supports any ffmpeg-decoded source)"
21+
},
22+
"skip_seconds": {
23+
"type": "integer",
24+
"minimum": 0,
25+
"maximum": 4294967295,
26+
"default": 0,
27+
"description": "Skips the audio by given seconds (source)"
28+
},
29+
"cache": {
30+
"type": "boolean",
31+
"default": false,
32+
"description": "Do not delete the TAF converted via `source` after sending it"
33+
},
34+
"cloud_ruid": {
35+
"type": "string",
36+
"default": "",
37+
"pattern": "^[0-9a-fA-F]*$",
38+
"description": "rUID of the Tonie (hexadecimal string)"
39+
},
40+
"cloud_auth": {
41+
"type": "string",
42+
"default": "",
43+
"description": "Content password of the Tonie"
44+
},
45+
"cloud_override": {
46+
"type": "boolean",
47+
"default": false,
48+
"description": "Reroute a tag to a different one (requires cloud_ruid/cloud_auth)"
49+
},
50+
"tonie_model": {
51+
"type": "string",
52+
"default": "",
53+
"description": "Identify the Tonie"
54+
},
55+
"_version": {
56+
"type": "integer",
57+
"minimum": 0,
58+
"maximum": 4294967295,
59+
"default": 5,
60+
"description": "Version of the file"
61+
}
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Playlist Configuration Schema",
4+
"type": "object",
5+
"additionalProperties": false,
6+
"properties": {
7+
"type": {
8+
"type": "string",
9+
"default": "tap",
10+
"description": "Sets the type of playlist"
11+
},
12+
"audio_id": {
13+
"type": "integer",
14+
"minimum": 0,
15+
"maximum": 4294967295,
16+
"default": 0,
17+
"description": "Audio ID for cached files (0 forces recreation)"
18+
},
19+
"filepath": {
20+
"type": "string",
21+
"default": "",
22+
"description": "Output path for TAF file generated by ffmpeg"
23+
},
24+
"name": {
25+
"type": "string",
26+
"default": "",
27+
"description": "Name of the playlist"
28+
},
29+
"files": {
30+
"type": "array",
31+
"default": [],
32+
"items": {
33+
"type": "object",
34+
"additionalProperties": false,
35+
"properties": {
36+
"filepath": {
37+
"type": "string",
38+
"default": "",
39+
"description": "Path to audio resource (ffmpeg-compatible)"
40+
},
41+
"name": {
42+
"type": "string",
43+
"default": "",
44+
"description": "Display name for the audio resource"
45+
}
46+
}
47+
},
48+
"description": "List of audio files in the playlist"
49+
}
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Custom Toniebox Configuration Schema",
4+
"type": "array",
5+
"items": {
6+
"type": "object",
7+
"required": ["id", "name", "img_src", "crop"],
8+
"additionalProperties": false,
9+
"properties": {
10+
"id": {
11+
"type": "string",
12+
"pattern": "^\\d{2}-\\d{4}$",
13+
"examples": ["11-0001"],
14+
"description": "Unique model number (must not conflict with existing models)"
15+
},
16+
"name": {
17+
"type": "string",
18+
"examples": ["Customized Toniebox"],
19+
"description": "Display name for the customized Toniebox"
20+
},
21+
"img_src": {
22+
"type": "string",
23+
"format": "uri",
24+
"examples": ["http://.../customToniebox.png"],
25+
"description": "URL of the custom Toniebox image"
26+
},
27+
"crop": {
28+
"type": "array",
29+
"minItems": 3,
30+
"maxItems": 3,
31+
"items": {
32+
"type": "number"
33+
},
34+
"examples": [[0, 0, 1]],
35+
"description": "Image transformation parameters [x-shift, y-shift, scale]"
36+
}
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Custom Tonie Configuration Schema",
4+
"type": "array",
5+
"items": {
6+
"type": "object",
7+
"required": ["model", "series"],
8+
"additionalProperties": false,
9+
"properties": {
10+
"no": {
11+
"type": "string",
12+
"examples": ["0"]
13+
},
14+
"model": {
15+
"type": "string",
16+
"examples": ["123456"]
17+
},
18+
"audio_id": {
19+
"type": "array",
20+
"items": {
21+
"type": "string",
22+
"pattern": "^\\d+$"
23+
},
24+
"examples": [["369519776"]]
25+
},
26+
"hash": {
27+
"type": "array",
28+
"items": {
29+
"type": "string",
30+
"pattern": "^[a-fA-F0-9]+$"
31+
},
32+
"examples": [["af9e6..b04515"]]
33+
},
34+
"title": {
35+
"type": "string",
36+
"examples": ["Custom Tonie Example Title"]
37+
},
38+
"series": {
39+
"type": "string",
40+
"examples": ["Custom Tonie"]
41+
},
42+
"episodes": {
43+
"type": "string",
44+
"examples": ["This is my custom tonie"]
45+
},
46+
"tracks": {
47+
"type": "array",
48+
"items": {
49+
"type": "string"
50+
},
51+
"examples": [["Title 1", "Title 2"]]
52+
},
53+
"release": {
54+
"type": "string",
55+
"examples": ["0"]
56+
},
57+
"language": {
58+
"type": "string",
59+
"pattern": "^[a-z]{2}-[a-z]{2}$",
60+
"examples": ["de-de"]
61+
},
62+
"category": {
63+
"type": "string",
64+
"examples": ["custom"]
65+
},
66+
"pic": {
67+
"type": "string",
68+
"format": "uri",
69+
"examples": ["https://.../Logo.png"]
70+
}
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)