Skip to content

Commit 54e9b05

Browse files
committed
metadata: added dynamic mapping show case
1 parent 28107ae commit 54e9b05

6 files changed

Lines changed: 156 additions & 65 deletions

example.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"plugin-example": {
3+
"chat-gpt": {
4+
"fields": {
5+
"filename": "trabant.jpg",
6+
"description": {
7+
"de-DE": "Das Bild zeigt ein Gemälde eines weißen Trabant-Autos, das durch eine Wand bricht. Die Illusion von zerbrochenem Putz und Ziegeln verstärkt den Eindruck einer Durchbrechung. Auf dem Nummernschild steht 'NOV 9-89', ein Hinweis auf den Tag des Mauerfalls in Berlin. Das Kunstwerk ist von Birgit Kinder signiert.",
8+
"en-US": "The image shows a painting of a white Trabant car breaking through a wall. The illusion of broken plaster and bricks enhances the impression of the car crashing through. The license plate reads 'NOV 9-89', referencing the date of the Berlin Wall's fall. The artwork is signed by Birgit Kinder."
9+
},
10+
"keywords": [
11+
{
12+
"de-DE": "Trabant",
13+
"en-US": "Trabant"
14+
},
15+
{
16+
"de-DE": "Berlin",
17+
"en-US": "Berlin"
18+
},
19+
{
20+
"de-DE": "Mauer",
21+
"en-US": "Wall"
22+
},
23+
{
24+
"en-US": "Art"
25+
},
26+
{
27+
"de-DE": "Wand",
28+
"en-US": "Crash"
29+
},
30+
{
31+
"de-DE": "Durchbruch",
32+
"en-US": "Breakthrough"
33+
},
34+
{
35+
"de-DE": "Mauerfall",
36+
"en-US": "Wall Fall"
37+
},
38+
{
39+
"de-DE": "Illusion",
40+
"en-US": "Illusion"
41+
},
42+
{
43+
"de-DE": "Birgit Kinder",
44+
"en-US": "Birgit Kinder"
45+
},
46+
{
47+
"de-DE": "Auto",
48+
"en-US": "Car"
49+
}
50+
],
51+
"title": {
52+
"de-DE": "Auto durch die Mauer",
53+
"en-US": "Car Breaking Through Wall"
54+
}
55+
},
56+
"timestamp": "2024-10-18T13:15:11+02:00"
57+
}
58+
}
59+
}

fas_config/cookbook_metadata_example.yml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,27 @@ recipes:
1919
name: "example_metadata.json"
2020
example-request-only:
2121
class: _metadata
22+
extensions:
23+
- jpg
24+
- exe
2225
metadata:
2326
- file: "example_metadata.json"
2427
displayname:
2528
de-DE: Beispiel Metadaten Mapping
2629
en-US: Example Metadaten Mapping
27-
mapping:
28-
exec:
29-
service: node
30-
commands:
31-
- prog: node
32-
stdout:
33-
type: body
34-
args:
35-
- "-e"
36-
- "require('fs').createReadStream(process.argv[1]).pipe(process.stdout)"
37-
- "%_exec.pluginDir%/fas_config/request_only_mapping.json"
3830
execs:
3931
- service: node
4032
commands:
4133
- prog: node
4234
args:
4335
- "-e"
4436
# read request_only_metadata.json (arg 1) and write to example_metadata.json (arg 2)
45-
- "console.error('Current working directory:', process.cwd()); require('fs').createReadStream(process.argv[1]).pipe(require('fs').createWriteStream(process.argv[2]));"
37+
- "console.error('Current working directory:', process.cwd()); const fs = require('fs'); fs.writeFileSync(process.argv[2], fs.readFileSync(process.argv[1], 'utf8').replaceAll('_custom_', '%custom%'));"
4638
- "%_exec.pluginDir%/fas_config/request_only_metadata.json"
4739
- type: file_out
4840
file:
4941
name: "example_metadata.json"
50-
example-request-only-with-error:
51-
class: _metadata
52-
metadata:
53-
- file: "example_metadata.json"
54-
displayname:
55-
de-DE: Beispiel Metadaten Mapping (with error)
56-
en-US: Example Metadaten Mapping (with error)
57-
mapping:
42+
dynamic:
5843
exec:
5944
service: node
6045
commands:
@@ -64,7 +49,15 @@ recipes:
6449
args:
6550
- "-e"
6651
- "require('fs').createReadStream(process.argv[1]).pipe(process.stdout)"
67-
- "%_exec.pluginDir%/fas_config/request_only_mapping_with_error.json"
52+
- "%_exec.pluginDir%/fas_config/recipe_dynamic_request_only.json"
53+
54+
example-request-only-with-error:
55+
class: _metadata
56+
metadata:
57+
- file: "example_metadata.json"
58+
displayname:
59+
de-DE: Beispiel Metadaten Mapping (with error)
60+
en-US: Example Metadaten Mapping (with error)
6861
execs:
6962
- service: node
7063
commands:
@@ -76,4 +69,16 @@ recipes:
7669
- "%_exec.pluginDir%/fas_config/request_only_metadata_with_error.json"
7770
- type: file_out
7871
file:
79-
name: "example_metadata.json"
72+
name: "example_metadata.json"
73+
dynamic:
74+
exec:
75+
service: node
76+
commands:
77+
- prog: node
78+
stdout:
79+
type: body
80+
args:
81+
- "-e"
82+
- "require('fs').createReadStream(process.argv[1]).pipe(process.stdout)"
83+
- "%_exec.pluginDir%/fas_config/recipe_dynamic_request_only_with_error.json"
84+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"params": {
3+
"custom": {
4+
"type": "string",
5+
"description": "custom text to include in metadata",
6+
"mandatory": true
7+
}
8+
},
9+
"mapping": {
10+
"import": {
11+
"fields": [
12+
{
13+
"name": "filename",
14+
"displayname": {
15+
"de-DE": "Dateiname",
16+
"en-US": "Filename"
17+
},
18+
"json_import": "plugin-example.chat-gpt.fields.filename",
19+
"json_import_type": "text"
20+
},
21+
{
22+
"name": "title",
23+
"displayname": {
24+
"de-DE": "Titel",
25+
"en-US": "Title"
26+
},
27+
"json_import": "plugin-example.chat-gpt.fields.title",
28+
"json_import_type": "text_l10n"
29+
},
30+
{
31+
"name": "description",
32+
"displayname": {
33+
"de-DE": "Beschreibung",
34+
"en-US": "Description"
35+
},
36+
"json_import": "plugin-example.chat-gpt.fields.description",
37+
"json_import_type": "text_l10n"
38+
},
39+
{
40+
"name": "keywords",
41+
"displayname": {
42+
"de-DE": "Schlagwörter",
43+
"en-US": "Keywords"
44+
},
45+
"json_import": "plugin-example.chat-gpt.fields.keywords",
46+
"json_import_type": "text_l10n"
47+
}
48+
]
49+
}
50+
}
51+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"mapping": {
3+
"import": {
4+
"fields": [
5+
{
6+
"name": "dummy1",
7+
"displayname": {
8+
"de-DE": "Dummy Field 1",
9+
"en-US": "Dummy Field 1"
10+
},
11+
"error_json_import": "plugin-example.test.error",
12+
"json_import": "plugin-example.test.fields.dummy",
13+
"json_import_type": "text"
14+
}
15+
]
16+
}
17+
}
18+
}

fas_config/request_only_mapping.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

fas_config/request_only_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"fields": {
55
"filename": "trabant.jpg",
66
"description": {
7-
"de-DE": "Das Bild zeigt ein Gemälde eines weißen Trabant-Autos, das durch eine Wand bricht. Die Illusion von zerbrochenem Putz und Ziegeln verstärkt den Eindruck einer Durchbrechung. Auf dem Nummernschild steht 'NOV 9-89', ein Hinweis auf den Tag des Mauerfalls in Berlin. Das Kunstwerk ist von Birgit Kinder signiert.",
7+
"de-DE": "_custom_: Das Bild zeigt ein Gemälde eines weißen Trabant-Autos, das durch eine Wand bricht. Die Illusion von zerbrochenem Putz und Ziegeln verstärkt den Eindruck einer Durchbrechung. Auf dem Nummernschild steht 'NOV 9-89', ein Hinweis auf den Tag des Mauerfalls in Berlin. Das Kunstwerk ist von Birgit Kinder signiert.",
88
"en-US": "The image shows a painting of a white Trabant car breaking through a wall. The illusion of broken plaster and bricks enhances the impression of the car crashing through. The license plate reads 'NOV 9-89', referencing the date of the Berlin Wall's fall. The artwork is signed by Birgit Kinder."
99
},
1010
"keywords": [

0 commit comments

Comments
 (0)