IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
882 stars 494 forks source link

enable previewers in containers #10506

Open pdurbin opened 7 months ago

pdurbin commented 7 months ago

In today's Containerization Working Group meeting (recording, notes) I explained that I would like to have file previewers in our containerized dev and demo environments.

(I want other things too such as language packs and CVOC scripts but previewers feels like a good place to start.)

There were several suggestions of how to accomplish this, but I said I'd start with the simplest one, which is to use the previewers hosted on GitHub Pages. Unfortunately, this doesn't work, due to CORS.

This is the URL I'm using to try to preview the file: http://localhost:8080/file.xhtml?fileId=18&version=DRAFT&toolType=PREVIEW

Here's the curl command I used from https://github.com/gdcc/dataverse-previewers/blob/1.4/6.1curlcommands.md

curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
  "displayName":"Read Text",
  "description":"Read the text file.",
  "toolName":"textPreviewer",
  "scope":"file",
  "types":["preview"],
  "toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/TextPreview.html",
  "toolParameters": {
      "queryParameters":[
        {"fileid":"{fileId}"},
        {"siteUrl":"{siteUrl}"},
        {"datasetid":"{datasetId}"},
        {"datasetversion":"{datasetVersion}"},
        {"locale":"{localeCode}"}
      ]
    },
  "contentType":"text/plain",
  "allowedApiCalls": [
    {
      "name": "retrieveFileContents",
      "httpMethod": "GET",
      "urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=true",
      "timeOut": 3600
    },
    {
      "name": "downloadFile",
      "httpMethod": "GET",
      "urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=false",
      "timeOut": 3600
    },
    {
      "name": "getDatasetVersionMetadata",
      "httpMethod": "GET",
      "urlTemplate": "/api/v1/datasets/{datasetId}/versions/{datasetVersion}",
      "timeOut": 3600
    }
  ]
}'

Here's the CORS error:

Image

Image

We'll need to determine what to try next. Possible solutions:

Related discussion:

pdurbin commented 3 weeks ago

Should we consider enabling all previewers? And let people delete the ones they don't want?

dataverse-ansible already installs some previewers. Can we share a script between ansible and our Docker images?

https://github.com/gdcc/dataverse-previewers/blob/develop/6.1curlcommands.md is fine as a README but it feels a bit weird to copy each curl command into a script.

pdurbin commented 1 week ago

This just in, @gschmutz of Platys fame has some ideas:

pdurbin commented 1 week ago

We can warm up this thread if we like: https://dataverse.zulipchat.com/#narrow/channel/375812-containers/topic/enable.20previewers/near/434165029