Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis-wr authored May 6, 2024
2 parents f20ed62 + 3f1d4fa commit 7dc117a
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 2 deletions.
259 changes: 259 additions & 0 deletions 6.1curlcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1496,3 +1496,262 @@ curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin

## Beta Versions:
As updates and additions are made, they will be added to a /betatest sub-folder which will make them accessible to users via github.io without affecting people who are using the latest numbered release (e.g. v1.4). When previewers in the betatest branch are included in the next release (e.g. v1.5), sites may wish to change their registration of the tools to use the stable version as the betatest version may continue to receive changes.
### 3D model Previewer using X_ITE X3D (beta)

__Note:__ There are many mimetypes that can be rendered as 3D models. The following example is for X3D files. You can add more mimetypes by adding more entries to the "contentType" field.

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Read 3D model",
"description":"Read the 3D model file using X3D from X_ITE.",
"toolName":"3D model Previewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/X3DPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/x3d+xml",
"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
}
]
}'
```

More types for 3D models that X_ITE can load below.

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Read 3D model",
"description":"Read the 3D model file using X3D from X_ITE.",
"toolName":"3D model Previewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/X3DPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/vrml",
"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
}
]
}'
```

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Read 3D model",
"description":"Read the 3D model file using X3D from X_ITE.",
"toolName":"3D model Previewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/X3DPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/gltf-binary",
"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
}
]
}'
```

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Read 3D model",
"description":"Read the 3D model file using X3D from X_ITE.",
"toolName":"3D model Previewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/X3DPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/obj",
"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
}
]
}'
```

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Read 3D model",
"description":"Read the 3D model file using X3D from X_ITE.",
"toolName":"3D model Previewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/X3DPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/stl",
"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
}
]
}'
```

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Read 3D model",
"description":"Read the 3D model file using X3D from X_ITE.",
"toolName":"3D model Previewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/v1.4/X3DPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
]
},
"contentType":"model/x-ply",
"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
}
]
}'
```


6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ The Spreadsheet Previewer was contributed by [anncie-pcss](https://github.com/an

[Jan Range](https://github.com/JR-1991) contributed the H5Web Previewer, Rich Html Previewer.

[Paul Boon](https://github.com/PaulBoon) contributed the 3D Previewer.


## How can I help?

If you are interested in adding additional previewers, or in maintaining/enhancing existing ones, contact us at [[email protected]](mailto:[email protected]) or work through github to fork/make pull-requests against the repository.
Expand All @@ -94,8 +97,7 @@ By committing code to the repository, Contributors are agreeing to make it avail
## Example Curl commands to configure these tools with your Dataverse instance.
The examples configure Previewers from the specified location within https://github.io/gdcc/ corresponding to a given branch. To use older versions or locally installed versions of the previewers, you can change the "toolUrl" being used.


Previewers v1.4 (with betatest versions of newer previewers as noted)
Previewers v1.4 (with betatest versions of newer previewers as noted, e.g. 3D Previewer)
- [Dataverse 6.1+](6.1curlcommands.md) - using SignedUrls
- [Dataverse 5.2+](5.2curlcommands.md) - using API tokens, not recommended beyond Dataverse 6.0

Expand Down
37 changes: 37 additions & 0 deletions previewers/betatest/X3DPreview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<html>

<head>
<meta charset="utf-8">
<title class="textPreview">3D model Preview</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="css/preview.css" />
<!-- X_ITE, latest stable fixed version -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/x_ite.min.js"></script>
</head>

<body class="container">
<main><img id='logo' alt='Site Logo'>
<h1 class="page-title x3dPreview">3D model Preview</h1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'>
<!-- Small because it is a preview, you can go full-screen via the menu if needed -->
<x3d-canvas debug="true" id="x3dpreviewcanvas" style="width: 100%; height: 480px;"></x3d-canvas>
</div>
</div>
</main>
<script type="text/javascript" src="js/x3dview.js"></script>
</body>

</html>
23 changes: 23 additions & 0 deletions previewers/betatest/js/x3dview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$(document).ready(function() {
startPreview(true);
});

function translateBaseHtmlPage() {
var x3dPreviewText = $.i18n( "x3dPreviewText" );
$( '.x3dPreviewText' ).text( x3dPreviewText );
}

function writeContentAndData(data, fileUrl, file, title, authors) {
addStandardPreviewHeader(file, title, authors);

/** Human readable formats could also be displayed (as text or xml or json).
options = {}; // Custom rules
$('.preview').append($("<pre/>").html(filterXSS(data,options)));
*/

var browser = X3D.getBrowser("x3d-canvas#x3dpreviewcanvas");
console.log("X3D Browser: " + browser.getName() + " " + browser.getVersion());
console.log("Start loading file: " + fileUrl);
browser.loadURL(new X3D.MFString(fileUrl));
//browser.viewAll();
}

0 comments on commit 7dc117a

Please sign in to comment.