Skip to content

Commit 00f3d91

Browse files
committed
metadata: added dynamic mapping / parameters show case
see #78207
1 parent 28107ae commit 00f3d91

6 files changed

Lines changed: 103 additions & 82 deletions

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_de_', '%custom_de%').replaceAll('_custom_en_', '%custom_en%'));"
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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"params": {
3+
"custom_de": {
4+
"type": "string",
5+
"description": "custom text to include in metadata description (de-DE)",
6+
"usereditable": true
7+
},
8+
"custom_en": {
9+
"type": "string",
10+
"description": "custom text to include in metadata description (en-EN)",
11+
"usereditable": false
12+
}
13+
},
14+
"mapping": {
15+
"import": {
16+
"fields": [
17+
{
18+
"name": "filename",
19+
"displayname": {
20+
"de-DE": "Dateiname",
21+
"en-US": "Filename"
22+
},
23+
"json_import": "plugin-example.chat-gpt.fields.filename",
24+
"json_import_type": "text"
25+
},
26+
{
27+
"name": "title",
28+
"displayname": {
29+
"de-DE": "Titel",
30+
"en-US": "Title"
31+
},
32+
"json_import": "plugin-example.chat-gpt.fields.title",
33+
"json_import_type": "text_l10n"
34+
},
35+
{
36+
"name": "description",
37+
"displayname": {
38+
"de-DE": "Beschreibung",
39+
"en-US": "Description"
40+
},
41+
"json_import": "plugin-example.chat-gpt.fields.description",
42+
"json_import_type": "text_l10n"
43+
},
44+
{
45+
"name": "keywords",
46+
"displayname": {
47+
"de-DE": "Schlagwörter",
48+
"en-US": "Keywords"
49+
},
50+
"json_import": "plugin-example.chat-gpt.fields.keywords",
51+
"json_import_type": "text_l10n"
52+
}
53+
]
54+
}
55+
}
56+
}
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_mapping_with_error.json

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

fas_config/request_only_metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
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.",
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."
7+
"de-DE": "_custom_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": "_custom_en_: 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": [
1111
{

0 commit comments

Comments
 (0)