diff --git a/5.2curlcommands.md b/5.2curlcommands.md index 2d56f6cb..dd701361 100644 --- a/5.2curlcommands.md +++ b/5.2curlcommands.md @@ -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. diff --git a/6.1curlcommands.md b/6.1curlcommands.md index 7d30af1e..30cd793b 100644 --- a/6.1curlcommands.md +++ b/6.1curlcommands.md @@ -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. @@ -1797,3 +1833,137 @@ 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.5). When previewers in the betatest branch are included in the next release (e.g. v1.6), sites may wish to change their registration of the tools to use the stable version as the betatest version may continue to receive changes. +### CDI Previewer + +```bash +curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \ +'{ + "displayName":"View CDI Metadata", + "description":"View DDI Cross-Domain Integration (CDI) metadata file using SHACL shapes.", + "toolName":"cdiPreviewer", + "scope":"file", + "types":["preview"], + "toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/CdiPreview.html", + "toolParameters": { + "queryParameters":[ + {"fileid":"{fileId}"}, + {"siteUrl":"{siteUrl}"}, + {"datasetid":"{datasetId}"}, + {"datasetversion":"{datasetVersion}"}, + {"locale":"{localeCode}"} + ] + }, + "contentType":"application/ld+json; profile=\"http://www.w3.org/ns/json-ld#flattened http://www.w3.org/ns/json-ld#compacted https://ddialliance.org/specification/ddi-cdi/1.0\"", + "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 + } + ] +}' +``` + +### QDAS Previewers + +These previewers support the [REFI-QDA standard](https://www.qdasoftware.org/) format for qualitative research files. +They allow viewing of the authors, codes, sources, annotations, and relationships listed in the codebook, +with added functionality to view code use frequency and filter by the entries in these tables. The REFI-QDA Project previewer +also allows viewing the annotation anchor text retrieved from the zipped source files. + +```bash +curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \ +'{ + "displayName":"View REFI-QDA Project", + "description":"View the contents of a REFI-QDA project file.", + "toolName":"refiqdaProjectPreviewer", + "scope":"file", + "types":["preview"], + "toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/REFIQDPXPreview.html", + "toolParameters": { + "queryParameters":[ + {"fileid":"{fileId}"}, + {"siteUrl":"{siteUrl}"}, + {"datasetid":"{datasetId}"}, + {"datasetversion":"{datasetVersion}"}, + {"locale":"{localeCode}"} + ] + }, + "contentType":"application/x-zip-refiqda", + "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":"View REFI-QDA Codebook", + "description":"View the contents of a REFI-QDA codebook file.", + "toolName":"refiqdaCodebookPreviewer", + "scope":"file", + "types":["preview"], + "toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/REFIQDAPreview.html", + "toolParameters": { + "queryParameters":[ + {"fileid":"{fileId}"}, + {"siteUrl":"{siteUrl}"}, + {"datasetid":"{datasetId}"}, + {"datasetversion":"{datasetVersion}"}, + {"locale":"{localeCode}"} + ] + }, + "contentType":"text/x-xml-refiqda", + "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 + } + ] +}' +``` \ No newline at end of file diff --git a/README.md b/README.md index d5951c1b..9728734a 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ The image previewer only works with image/tiff files on some browsers (as of ~Ja The original tools were developed through the [Qualitative Data Repository](https://qdr.syr.edu) but are being offered to the Dataverse community at large. -[qqmyers](https://github.com/qqmyers) - developer of the original previewer framework, contributions to the Rich Html Previewer, Voyager Previewer, updating to use signed URLs +[qqmyers](https://github.com/qqmyers) - developer of the original previewer framework, contributions to the Rich Html Previewer, Voyager Previewer, REFI-QDA previewers, updating to use signed URLs The Spreadsheet Previewer was contributed by [anncie-pcss](https://github.com/anncie-pcss). @@ -84,7 +84,7 @@ The Spreadsheet Previewer was contributed by [anncie-pcss](https://github.com/an [Max Planck Digital Library](https://github.com/MPDL) contributed the ZIP Previewer. -[erykkul](https://github.com/erykkul) contributed the Markdown (MD) Previewer and the RO-Crate previewer. +[erykkul](https://github.com/erykkul) contributed the Markdown (MD) Previewer, the RO-Crate previewer, and the CDI (DDI Cross-Domain Integration) previewer. The CDI previewer displays all JSON-LD data nodes and properties with real-time SHACL validation, smart property classification (required/optional/extra fields), support for complex nested objects, and editing capabilities. See [https://github.com/libis/cdi-viewer](https://github.com/libis/cdi-viewer) for the source code, documentation and implementation details. [Jan Range](https://github.com/JR-1991) contributed the H5Web Previewer, Rich Html Previewer. diff --git a/previewers/betatest/AudioPreview.html b/previewers/betatest/AudioPreview.html index c62e75a0..317dff45 100644 --- a/previewers/betatest/AudioPreview.html +++ b/previewers/betatest/AudioPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/CdiPreview.html b/previewers/betatest/CdiPreview.html new file mode 100644 index 00000000..0a071842 --- /dev/null +++ b/previewers/betatest/CdiPreview.html @@ -0,0 +1,25 @@ + + + + + + CDI Data Viewer & Editor + + + + + + + + + + + + + + + + diff --git a/previewers/betatest/HtmlPreview.html b/previewers/betatest/HtmlPreview.html index 0d83b43a..dc275689 100644 --- a/previewers/betatest/HtmlPreview.html +++ b/previewers/betatest/HtmlPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/HypothesisPreview.html b/previewers/betatest/HypothesisPreview.html index e3df34fc..af83313d 100644 --- a/previewers/betatest/HypothesisPreview.html +++ b/previewers/betatest/HypothesisPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/ImagePreview.html b/previewers/betatest/ImagePreview.html index 64e7ed0d..9105ef1c 100644 --- a/previewers/betatest/ImagePreview.html +++ b/previewers/betatest/ImagePreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/JupyterPreview.html b/previewers/betatest/JupyterPreview.html new file mode 100644 index 00000000..f981356d --- /dev/null +++ b/previewers/betatest/JupyterPreview.html @@ -0,0 +1,91 @@ + + + + + + + + + + Jupyter Notebook Preview + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Jupyter Notebook Preview

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/previewers/betatest/MapPreview.html b/previewers/betatest/MapPreview.html index 3031e4f8..f9fe0006 100644 --- a/previewers/betatest/MapPreview.html +++ b/previewers/betatest/MapPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/MapRasterPreview.html b/previewers/betatest/MapRasterPreview.html index 63cb3821..83f7e9f9 100644 --- a/previewers/betatest/MapRasterPreview.html +++ b/previewers/betatest/MapRasterPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/MapShpPreview.html b/previewers/betatest/MapShpPreview.html index 6b20b6a2..e2d8b52f 100644 --- a/previewers/betatest/MapShpPreview.html +++ b/previewers/betatest/MapShpPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/MdPreview.html b/previewers/betatest/MdPreview.html index 7d51b0a1..6e9ea9b0 100644 --- a/previewers/betatest/MdPreview.html +++ b/previewers/betatest/MdPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/NcmlPreview.html b/previewers/betatest/NcmlPreview.html index 18836e3a..5cd7a167 100644 --- a/previewers/betatest/NcmlPreview.html +++ b/previewers/betatest/NcmlPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/PDFPreview.html b/previewers/betatest/PDFPreview.html index f0299787..48db49a6 100644 --- a/previewers/betatest/PDFPreview.html +++ b/previewers/betatest/PDFPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/REFIQDAPreview.html b/previewers/betatest/REFIQDAPreview.html new file mode 100644 index 00000000..06e2e35c --- /dev/null +++ b/previewers/betatest/REFIQDAPreview.html @@ -0,0 +1,42 @@ + + + + + + REFI-QDA Preview + + + + + + + + + + + + + + + + + + + + + + + +
+ +

REFI-QDA Codebook Preview

+
+
+
+
+
+ + + diff --git a/previewers/betatest/REFIQDPXPreview.html b/previewers/betatest/REFIQDPXPreview.html new file mode 100644 index 00000000..3a45b106 --- /dev/null +++ b/previewers/betatest/REFIQDPXPreview.html @@ -0,0 +1,43 @@ + + + + + + REFI-QDA Preview + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

REFI-QDA Project Preview

+
+
+
+
+
+ + + diff --git a/previewers/betatest/ROCrate.html b/previewers/betatest/ROCrate.html index da31654b..6d181874 100644 --- a/previewers/betatest/ROCrate.html +++ b/previewers/betatest/ROCrate.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/RichHtmlPreview.html b/previewers/betatest/RichHtmlPreview.html index 434f11a6..6a279cb1 100644 --- a/previewers/betatest/RichHtmlPreview.html +++ b/previewers/betatest/RichHtmlPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/SpreadsheetPreview.html b/previewers/betatest/SpreadsheetPreview.html index cad65cf2..7520bb4d 100644 --- a/previewers/betatest/SpreadsheetPreview.html +++ b/previewers/betatest/SpreadsheetPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/TextPreview.html b/previewers/betatest/TextPreview.html index 260d1daa..8005b9de 100644 --- a/previewers/betatest/TextPreview.html +++ b/previewers/betatest/TextPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/VideoPreview.html b/previewers/betatest/VideoPreview.html index 06cbe940..1024d20e 100644 --- a/previewers/betatest/VideoPreview.html +++ b/previewers/betatest/VideoPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/X3DPreview.html b/previewers/betatest/X3DPreview.html index be39130c..67dff03c 100644 --- a/previewers/betatest/X3DPreview.html +++ b/previewers/betatest/X3DPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/ZipPreview.html b/previewers/betatest/ZipPreview.html index 0af4869f..1cde9d8a 100644 --- a/previewers/betatest/ZipPreview.html +++ b/previewers/betatest/ZipPreview.html @@ -1,3 +1,4 @@ + diff --git a/previewers/betatest/css/jupyter.css b/previewers/betatest/css/jupyter.css new file mode 100644 index 00000000..33691b7a --- /dev/null +++ b/previewers/betatest/css/jupyter.css @@ -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; +} \ No newline at end of file diff --git a/previewers/betatest/css/refiqdas.css b/previewers/betatest/css/refiqdas.css new file mode 100644 index 00000000..caeea1ec --- /dev/null +++ b/previewers/betatest/css/refiqdas.css @@ -0,0 +1,66 @@ + +.selection-tooltip { + position: relative; + cursor: help; + border-bottom: 1px dotted #666; +} + +.selection-tooltip .tooltip-content { + visibility: hidden; + width: 400px; + background-color: #555; + color: #fff; + text-align: left; + border-radius: 6px; + padding: 10px; + position: absolute; + z-index: 1000; + bottom: 125%; + left: 50%; + margin-left: -200px; + opacity: 0; + transition: opacity 0.3s; + font-size: 12px; + line-height: 1.4; + max-height: 300px; + overflow-y: auto; + white-space: pre-wrap; + word-wrap: break-word; + box-shadow: 0 2px 8px rgba(0,0,0,0.3); +} + +.selection-tooltip .tooltip-content::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; +} + +.selection-tooltip:hover .tooltip-content { + visibility: visible; + opacity: 1; +} + +.tooltip-loading { + font-style: italic; + color: #ccc; +} + +.tooltip-error { + color: #ffaaaa; +} + +.tooltip-positions { + font-weight: bold; + margin-bottom: 8px; + padding-bottom: 5px; + border-bottom: 1px solid #777; +} + +.tooltip-text { + margin-top: 5px; +} \ No newline at end of file diff --git a/previewers/betatest/i18n/en.json b/previewers/betatest/i18n/en.json index d4685b29..7d28728e 100644 --- a/previewers/betatest/i18n/en.json +++ b/previewers/betatest/i18n/en.json @@ -22,6 +22,10 @@ "mdPreviewText": "Markdown Preview", "ncmlPreviewText": "NcML Preview", "rocratePreviewText": "RO-Crate Preview", + "jupyterPreviewText": "Jupyter Notebook Preview", + "cdiPreviewText": "CDI Preview", + "refiqdpxPreviewText": "REFI-QDA Project Preview", + "refiqdcPreviewText": "REFI-QDA Codebook Preview", "prev": "Previous", "next": "Next", "pageText": "Page:", diff --git a/previewers/betatest/i18n/es.json b/previewers/betatest/i18n/es.json index 27d7a635..5afda031 100644 --- a/previewers/betatest/i18n/es.json +++ b/previewers/betatest/i18n/es.json @@ -21,6 +21,10 @@ "mdPreviewText": "Previsualización de Markdown", "ncmlPreviewText": "Previsualización de NcML", "rocratePreviewText": "Previsualización de RO-Crate", + "jupyterPreviewText": "Previsualización de Jupyter Notebook", + "cdiPreviewText": "Previsualización de CDI", + "refiqdpxPreviewText": "Previsualización del proyecto REFI-QDA", + "refiqdcPreviewText": "Previsualización del libro de códigos REFI-QDA", "prev": "Anterior", "next": "Siguiente", "pageText": "Página:", diff --git a/previewers/betatest/i18n/fr.json b/previewers/betatest/i18n/fr.json index 955a7404..147f8bde 100644 --- a/previewers/betatest/i18n/fr.json +++ b/previewers/betatest/i18n/fr.json @@ -22,6 +22,10 @@ "mdPreviewText": "Aperçu Markdown", "ncmlPreviewText": "Aperçu NcML", "rocratePreviewText": "Aperçu RO-Crate", + "jupyterPreviewText": "Aperçu Jupyter Notebook", + "cdiPreviewText": "Aperçu CDI", + "refiqdpxPreviewText": "Aperçu du projet REFI-QDA", + "refiqdcPreviewText": "Aperçu du codebook REFI-QDA", "prev": "Précédent", "next": "Suivant", "pageText": "Page:", diff --git a/previewers/betatest/images/Loading_icon.gif b/previewers/betatest/images/Loading_icon.gif new file mode 100644 index 00000000..a718bd89 Binary files /dev/null and b/previewers/betatest/images/Loading_icon.gif differ diff --git a/previewers/betatest/js/jupyter.js b/previewers/betatest/js/jupyter.js new file mode 100644 index 00000000..eaa20eb4 --- /dev/null +++ b/previewers/betatest/js/jupyter.js @@ -0,0 +1,84 @@ +$(document).ready(function () { + // Configure notebookjs with markdown and syntax highlighting when it loads + if (typeof nb !== 'undefined') { + // Configure markdown rendering + if (typeof marked !== 'undefined') { + nb.markdown = function (text) { + return marked.parse(text); + }; + } + + // Configure Prism syntax highlighting + nb.highlighter = function (text, pre, code, lang) { + if (typeof lang === 'undefined') { + lang = 'text'; + } + + // Map notebook language to Prism language + var languageMap = { + 'ipython': 'python', + 'ipython3': 'python', + 'python': 'python', + 'python3': 'python', + 'julia': 'julia', + 'r': 'r', + 'javascript': 'javascript', + 'js': 'javascript' + }; + + var prismLang = languageMap[lang.toLowerCase()] || lang.toLowerCase(); + + // Set classes for styling + pre.className = 'language-' + prismLang; + if (typeof code !== 'undefined') { + code.className = 'language-' + prismLang; + } + + // Highlight if Prism has the language + if (typeof Prism !== 'undefined' && Prism.languages[prismLang]) { + return Prism.highlight(text, Prism.languages[prismLang], prismLang); + } + + return text; + }; + } + + // Start the preview, requesting file data retrieval + startPreview(true); +}); + +function translateBaseHtmlPage() { + // Jupyter Notebook Previewer has the title text + var jupyterPreviewText = $.i18n("jupyterPreviewText"); + $('.jupyterPreviewText').text(jupyterPreviewText); +} + +function writeContentAndData(data, fileUrl, file, title, authors) { + addStandardPreviewHeader(file, title, authors); + + try { + // Check if notebookjs is loaded + if (typeof nb === 'undefined') { + reportFailure('Error: notebookjs library failed to load. ', 'Library not available'); + return; + } + + // Parse the notebook JSON + var ipynbJson = JSON.parse(data); + + // Parse and render the notebook + var notebook = nb.parse(ipynbJson); + var rendered = notebook.render(); + + // Hide spinner and display notebook + $('.lds-spinner').hide(); + var notebookDiv = document.getElementById('notebook'); + notebookDiv.innerHTML = ''; + notebookDiv.appendChild(rendered); + + } catch (error) { + reportFailure('Error rendering notebook: ' + error.message, error.toString()); + console.error('Rendering error:', error); + } +} + diff --git a/previewers/betatest/js/refiqda.js b/previewers/betatest/js/refiqda.js new file mode 100644 index 00000000..957d8666 --- /dev/null +++ b/previewers/betatest/js/refiqda.js @@ -0,0 +1,15 @@ +function writeContent(fileUrl, file, title, authors) { + addStandardPreviewHeader(file, title, authors); + options = { + "stripIgnoreTag": true, + "stripIgnoreTagBody": ['script', 'head'] + }; // Custom rules + wait = $('
').attr('id', 'waiting'); + $('').width('15%').attr('src','images/Loading_icon.gif').attr('id','throbber').appendTo(wait); + $('').text('Retrieving File...').appendTo(wait); + wait.appendTo($('.preview')); + + fetch(fileUrl) + .then(response => response.text()) + .then(data => parseData(data)); +} diff --git a/previewers/betatest/js/refiqdacore.js b/previewers/betatest/js/refiqdacore.js new file mode 100644 index 00000000..8d40f2af --- /dev/null +++ b/previewers/betatest/js/refiqdacore.js @@ -0,0 +1,1133 @@ + +var userMap = new Map(); +var codeMap = new Map(); +var sourceMap = new Map(); +var noteMap = new Map(); +var tableWidth = '90%'; +var selectedGUIDs = new Array(); +var noteDataTable; +var userDataTable; +var codeDataTable; +var sourceDataTable; +var setDataTable; +var tables = new Array(); + +var textSourceCache = new Map(); // Cache for loaded text files + +$(document).ready(function() { + startPreview(false); +}); + +function translateBaseHtmlPage() { + var refiqdaPreviewText = $.i18n("refiqdaPreviewText"); + $('.refiqdaPreviewText').text(refiqdaPreviewText); +} + +function addSelectAllAndUnselectButtons(dataTable, tableContainer, tableId) { + // Add "Unselect All" button next to the table title + const unselectAllButton = $('') + .addClass('unselect-all-btn') + .hide() + .on('click', function() { + dataTable.rows({ selected: true }).deselect(); + }); + tableContainer.find('h2').first().append(unselectAllButton); + + // Add "Select All" checkbox to the table header + const selectAllCheckbox = $(''); + $('#' + tableId + ' thead tr').prepend($('').append(selectAllCheckbox)); + $('#' + tableId + ' tbody tr').prepend($('')); // Placeholder for alignment + + selectAllCheckbox.on('click', function() { + if (this.checked) { + dataTable.rows().select(); + } else { + dataTable.rows().deselect(); + } + }); + + // Show/hide "Unselect All" button and manage "Select All" checkbox state + dataTable.on('select deselect', function() { + const selectedRows = dataTable.rows({ selected: true }).count(); + const totalRows = dataTable.rows().count(); + + if (selectedRows > 0) { + unselectAllButton.show(); + } else { + unselectAllButton.hide(); + } + + selectAllCheckbox.prop('checked', selectedRows === totalRows); + }); +} + +var zipUrl = ''; + +//zipUrl is set in refiqdpx.js - the zip file case +function isZipMode() { + return typeof zipUrl !== 'undefined' && zipUrl !== null && zipUrl !== ''; +} + +var wait; +var cy; + + + + +function findDataAttribute(name, attrNamedNodeMap) { + let attr = attrNamedNodeMap[name]; + if (typeof attr !== 'undefined') { + return attr.nodeValue; + } + return ''; +} + +// Start parsing project file +// This function just adds a loading icon and initial text to the page and then calls parseData2 +function parseData(data) { + $('#waiting').remove(); + wait = $('
').attr('id', 'waiting'); + $('').width('15%').attr('src', 'images/Loading_icon.gif').appendTo(wait); + $('').text('Found Project File. Parsing Contents...').appendTo(wait); + wait.appendTo($('.preview')); + + new Promise((resolve) => setTimeout(resolve, 500)).then(() => { parseData2(data) }); +} + +// Reads the project file and walks through the XML creating tables for all the entry types +// Also adds a filter by choice box +function parseData2(data) { + + parser = new DOMParser(); + xmlDoc = parser.parseFromString(data, "text/xml"); + + + //Add a Filter By option + let filterBlock = $('
').width(tableWidth).appendTo($(".preview")); + filterBlock.append($("

").html("Enable Filtering By")); + filterBlock.append($("

").html("Select a table and then select entries in that table to filter the other tables.")); + filterBlock.append($('").addClass("item-dropdown");y.append($("