Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 5.2curlcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,31 @@ curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin
}'
```

### Jupyter Notebook Previewer

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Show Jupyter Notebook",
"description":"View the Jupyter Notebook file.",
"toolName":"jupyterPreviewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/JupyterPreview.html",
"toolParameters": {
"queryParameters":[
{"fileid":"{fileId}"},
{"siteUrl":"{siteUrl}"},
{"datasetid":"{datasetId}"},
{"datasetversion":"{datasetVersion}"},
{"locale":"{localeCode}"}
{"key":"{apiToken}"}
]
},
"contentType":"application/x-ipynb+json"
}'
```

### ESRI Shape Previewer

This previewer includes a hard-coded file size limit of a zipped shp file of 20 MB (larger zips will not be loaded). If you want to change this limit you can change the value in "previewers/v1.5/js/mapshp.js", but then you have to host the customised previewer yourself (e.g. via github pages). Instructions on how to build external tools yourself can be found here: https://guides.dataverse.org/en/latest/api/external-tools.html.
Expand Down
36 changes: 36 additions & 0 deletions 6.1curlcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,42 @@ curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin
]
}'
```

### Jupyter Notebook Previewer

```bash
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
'{
"displayName":"Show Jupyter Notebook",
"description":"View the Jupyter Notebook file.",
"toolName":"jupyterPreviewer",
"scope":"file",
"types":["preview"],
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/JupyterPreview.html",
"contentType":"application/x-ipynb+json",
"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
}
]
}'
```

### ESRI Shape Previewer

This previewer includes a hard-coded file size limit of a zipped shp file of 20 MB (larger zips will not be loaded). If you want to change this limit you can change the value in "previewers/v1.5/js/mapshp.js", but then you have to host the customised previewer yourself (e.g. via github pages). Instructions on how to build external tools yourself can be found here: https://guides.dataverse.org/en/latest/api/external-tools.html.
Expand Down
91 changes: 91 additions & 0 deletions previewers/betatest/JupyterPreview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
content="Jupyter Notebook previewer for Dataverse - renders .ipynb files with syntax highlighting, markdown support, and mathematical expressions">

<!-- Page title - dynamically updated via i18n -->
<title class="jupyterPreviewText">Jupyter Notebook Preview</title>

<!-- Core JavaScript libraries -->
<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>

<!-- Prism.js for syntax highlighting in code cells -->
<!-- Provides comprehensive syntax highlighting for multiple programming languages commonly used in Jupyter notebooks -->
<link rel="stylesheet" href="https://unpkg.com/prismjs/themes/prism.css">
<script src="https://unpkg.com/prismjs/prism.js"></script>
<script src="https://unpkg.com/prismjs/components/prism-python.min.js"></script>
<script src="https://unpkg.com/prismjs/components/prism-julia.min.js"></script>
<script src="https://unpkg.com/prismjs/components/prism-r.min.js"></script>

<!-- Markdown rendering and notebook parsing libraries -->
<!-- marked.js converts markdown text in notebook cells to HTML -->
<!-- notebookjs parses and renders the complete Jupyter notebook structure -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/notebook.min.js"></script>

<!-- KaTeX for mathematical expression rendering -->
<!-- Provides fast, high-quality rendering of LaTeX mathematical notation commonly found in scientific notebooks -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/contrib/auto-render.min.js"></script>

<!-- Internationalization (i18n) support -->
<!-- Enables multi-language support for the previewer interface -->
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>

<!-- Application-specific JavaScript modules -->
<script type="text/javascript" src="js/retriever.js"></script>
<script type="text/javascript" src="js/jupyter.js"></script>

<!-- Bootstrap CSS framework for responsive layout and styling -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<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">

<!-- Custom stylesheets for preview functionality and loading animations -->
<link type="text/css" rel="stylesheet" href="css/preview.css" />
<link type="text/css" rel="stylesheet" href="css/lds-spinner.css" />

<!-- Custom stylesheet for Jupyter notebook styling -->
<link type="text/css" rel="stylesheet" href="css/jupyter.css" />

</head>

<body class="container">
<main>
<img id='logo' alt='Site Logo'>
<h1 class="page-title jupyterPreviewText">Jupyter Notebook Preview</h1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'>
<div class="lds-spinner">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div id="notebook"></div>
</div>
</div>
</main>
</body>

</html>

</html>
185 changes: 185 additions & 0 deletions previewers/betatest/css/jupyter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* Custom CSS for Jupyter Notebook styling
* Mimics the appearance and layout of Jupyter notebooks to provide familiar user experience
*/

/* CSS custom properties for consistent spacing throughout the notebook */
:root {
--notebook-padding: 0.4em;
}

/*
* Heading styles with visual hierarchy and full-width underlines
* Creates clear section separation similar to rendered Jupyter markdown cells
*/
#notebook h1,
#notebook h2,
#notebook h3,
#notebook h4,
#notebook h5,
#notebook h6 {
padding-top: var(--notebook-padding);
padding-bottom: var(--notebook-padding);
border-bottom: 2px solid #ddd;
width: 100%;
margin-bottom: var(--notebook-padding);
}

/* Primary heading with prominent underline for document structure */
#notebook h1 {
border-bottom-width: 3px;
border-bottom-color: #333;
}

/* Secondary heading with medium emphasis */
#notebook h2 {
border-bottom-width: 2px;
border-bottom-color: #666;
}

/* Tertiary and lower headings with subtle underlines */
#notebook h3,
#notebook h4,
#notebook h5,
#notebook h6 {
border-bottom-width: 1px;
border-bottom-color: #999;
}

/* Paragraph styling for readable text flow in markdown cells */
#notebook p {
margin-bottom: var(--notebook-padding);
line-height: 1.6;
}

/* Base cell styling with clean background and transparent borders */
.nb-cell {
border: 1px solid transparent;
background: #fff;
}

/*
* Input cell layout using flexbox for proper alignment
* Ensures prompt numbers and code content are properly positioned
*/
#notebook .input {
page-break-inside: avoid;
display: flex;
flex-direction: row;
}

/*
* Prompt styling for input/output cell numbers
* Maintains consistent width and right-alignment for clean appearance
*/
#notebook .prompt {
min-width: 14ex;
padding: var(--notebook-padding);
margin: 0;
font-family: monospace;
text-align: right;
line-height: 1.21429em;
color: #303f9f;
flex: 0 0 auto;
}

/* Inner cell content area that expands to fill available space */
#notebook .inner_cell {
flex: 1 1 auto;
}

/*
* Code block styling for consistent monospace presentation
* Provides syntax highlighting background and proper spacing
*/
#notebook pre {
padding: var(--notebook-padding);
margin: 0;
font-family: monospace;
font-size: 12px;
line-height: 1.21429em;
overflow: auto;
background: #f7f7f7;
border: 1px solid #cfcfcf;
border-radius: 2px;
}

/*
* Output cell styling with distinctive left border and background
* Visually separates output from input cells for better readability
*/
.nb-output {
margin: var(--notebook-padding);
padding: var(--notebook-padding);
background: #fafafa;
border-left: 3px solid #e0e0e0;
border-radius: 2px;
border: 1px solid #cfcfcf;
position: relative;
}

/* Output label for clear identification of cell output sections */
.nb-output::before {
content: "Output:";
display: block;
font-family: monospace;
font-size: 11px;
font-weight: 600;
color: #666;
text-transform: uppercase;
letter-spacing: 0.5px;
}

/* Input cell container with consistent spacing and positioning */
.nb-input {
margin-top: var(--notebook-padding);
margin-bottom: var(--notebook-padding);
padding: var(--notebook-padding);
position: relative;
}

/* Input label styling for consistency with output labels */
.nb-input::before {
display: block;
font-family: monospace;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}

/* Output-specific code block styling with cleaner appearance */
.nb-output pre {
background: #fff;
border: 1px solid #e8e8e8;
}

/* Markdown cell styling for text content with appropriate padding */
.nb-markdown-cell {
padding: var(--notebook-padding) var(--notebook-padding);
}

/* Responsive image handling to prevent overflow in notebook content */
#notebook img {
max-width: 100%;
}

/*
* Table styling for data presentation in notebook outputs
* Provides clean, readable formatting for tabular data commonly found in data science notebooks
*/
#notebook table {
border-collapse: collapse;
border-spacing: 0;
}

#notebook table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}

#notebook table th,
#notebook table td {
padding: var(--notebook-padding) var(--notebook-padding);
border: 1px solid #ddd;
}
1 change: 1 addition & 0 deletions previewers/betatest/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"mdPreviewText": "Markdown Preview",
"ncmlPreviewText": "NcML Preview",
"rocratePreviewText": "RO-Crate Preview",
"jupyterPreviewText": "Jupyter Notebook Preview",
"prev": "Previous",
"next": "Next",
"pageText": "Page:",
Expand Down
1 change: 1 addition & 0 deletions previewers/betatest/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"mdPreviewText": "Previsualización de Markdown",
"ncmlPreviewText": "Previsualización de NcML",
"rocratePreviewText": "Previsualización de RO-Crate",
"jupyterPreviewText": "Previsualización de Jupyter Notebook",
"prev": "Anterior",
"next": "Siguiente",
"pageText": "Página:",
Expand Down
1 change: 1 addition & 0 deletions previewers/betatest/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"mdPreviewText": "Aperçu Markdown",
"ncmlPreviewText": "Aperçu NcML",
"rocratePreviewText": "Aperçu RO-Crate",
"jupyterPreviewText": "Aperçu Jupyter Notebook",
"prev": "Précédent",
"next": "Suivant",
"pageText": "Page:",
Expand Down
Loading