diff --git a/doc/release-notes/8722-custom-script.md b/doc/release-notes/8722-custom-script.md new file mode 100644 index 00000000000..e38987fedca --- /dev/null +++ b/doc/release-notes/8722-custom-script.md @@ -0,0 +1,3 @@ +## New DB Settings + +- :ControlledVocabularyCustomJavaScript \ No newline at end of file diff --git a/doc/sphinx-guides/source/admin/metadatacustomization.rst b/doc/sphinx-guides/source/admin/metadatacustomization.rst index 094f310a156..ff1b265cef7 100644 --- a/doc/sphinx-guides/source/admin/metadatacustomization.rst +++ b/doc/sphinx-guides/source/admin/metadatacustomization.rst @@ -571,6 +571,8 @@ Configuration involves specifying which fields are to be mapped, whether free-te These are all defined in the :ref:`:CVocConf <:CVocConf>` setting as a JSON array. Details about the required elements as well as example JSON arrays are available at https://github.com/gdcc/dataverse-external-vocab-support, along with an example metadata block that can be used for testing. The scripts required can be hosted locally or retrieved dynamically from https://gdcc.github.io/ (similar to how dataverse-previewers work). +Please note that in addition to the :ref:`:CVocConf` described above, an alternative is the :ref:`:ControlledVocabularyCustomJavaScript` setting. + Tips from the Dataverse Community --------------------------------- diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index ab0bad70206..9460b2b9479 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -2832,6 +2832,23 @@ Scripts that implement this association for specific service protocols are maint ``curl -X PUT --upload-file cvoc-conf.json http://localhost:8080/api/admin/settings/:CVocConf`` +.. _:ControlledVocabularyCustomJavaScript: + +:ControlledVocabularyCustomJavaScript ++++++++++++++++++++++++++++++++++++++ + +``:ControlledVocabularyCustomJavaScript`` allows a JavaScript file to be loaded into the dataset page for the purpose of showing controlled vocabulary as a list (with optionally translated values) such as author names. + +To specify the URL for a custom script ``covoc.js`` to be loaded from an external site: + +``curl -X PUT -d 'https://example.com/js/covoc.js' http://localhost:8080/api/admin/settings/:ControlledVocabularyCustomJavaScript`` + +To remove the custom script URL: + +``curl -X DELETE http://localhost:8080/api/admin/settings/:ControlledVocabularyCustomJavaScript`` + +Please note that :ref:`:CVocConf` is a better option if the list is large or needs to be searchable from an external service using protocols such as SKOSMOS. + .. _:AllowedCurationLabels: :AllowedCurationLabels diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java index 192052c68c5..9bc5a5c09a7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java @@ -672,6 +672,10 @@ public List getVocabScripts( Map cvocConf) { for(JsonObject jo: cvocConf.values()) { scripts.add(jo.getString("js-url")); } + String customScript = settingsService.getValueForKey(SettingsServiceBean.Key.ControlledVocabularyCustomJavaScript); + if (customScript != null && !customScript.isEmpty()) { + scripts.add(customScript); + } return Arrays.asList(scripts.toArray(new String[0])); } diff --git a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java index c12b8f6e452..26f737b213a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java @@ -534,7 +534,11 @@ Whether Harvesting (OAI) service is enabled /** * LDN Inbox Allowed Hosts - a comma separated list of IP addresses allowed to submit messages to the inbox */ - LDNMessageHosts + LDNMessageHosts, + /* + * Allow a custom JavaScript to control values of specific fields. + */ + ControlledVocabularyCustomJavaScript ; @Override