Make VC helper fields configurable
Adds KALAMAR_VC_HELPER_FIELDS environment variable and vc_helper_fields
configuration option to add or remove fields from the virtual corpus
builder at runtime.
Syntax: KALAMAR_VC_HELPER_FIELDS=+award:text,-docTitle
+name:type adds a field
-name removes a field
The result is always sorted alphabetically. Analogous to
KALAMAR_HINT_FOUNDRIES (aa6709c).
Required for DeLiKo@DNB
Change-Id: If9ad570133f78515aa6ed0ef87424c0843e76d9c
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 34c7408..6832b36 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -375,6 +375,21 @@
};
$self->defaults(hint_foundries => $hint_foundries);
+ # Configure VC helper fields for the virtual corpus builder
+ # Can be overridden via KALAMAR_VC_HELPER_FIELDS environment variable (comma-separated)
+ # or via vc_helper_fields config option (array)
+ # Items starting with '+' add a field (format: +name:type), e.g. '+award:text'
+ # Items starting with '-' remove a field by name, e.g. '-docTitle'
+ # The result is always sorted alphabetically by field name
+ my $vc_helper_fields_spec = '';
+
+ if ($ENV{'KALAMAR_VC_HELPER_FIELDS'}) {
+ $vc_helper_fields_spec = $ENV{'KALAMAR_VC_HELPER_FIELDS'};
+ } elsif (exists $conf->{vc_helper_fields}) {
+ $vc_helper_fields_spec = join(',', @{$conf->{vc_helper_fields}});
+ };
+ $self->defaults(vc_helper_fields => $vc_helper_fields_spec);
+
# Configure documentation navigation
my $doc_navi = Mojo::File->new($self->home->child('templates','doc','navigation.json'))->slurp;
$doc_navi = $doc_navi ? decode_json($doc_navi) : [];