diff --git a/README.md b/README.md index 6e18c51..a8d4015 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,18 @@ A collection of data file previewers that conform to the [Dataverse](https://dat ## Installation -These previewers can be run without downloading them by simply running the curl command(s) below to register then with your local dataverse instance. (You can also create local copies and register those). There is one command per mimetype you wish to preview (i.e. multiple commands to cover different types of images.) You can run any/all of the commands as you like. Note that the Hypothesis annotation previewer assumes a custom mimetype and may not be useful for most Dataverses (contact [QDR](mailto:qdr@syr.edu) for more information). Dataverse 4.11+ is required. +These previewers can be run without downloading them by simply running the curl command(s) below to register then with your local dataverse instance. (You can also create local copies and register those). + +For updates such as enabling Internationalization, which change the parameters you need to register with (Internationalization requires that Dataverse send the localeCode to the previewers), you'll need to delete the registrations for existing previewers (using the Dataverse externalTools API) and re-register them again using the updated curl commands below. + +There is one command per mimetype you wish to preview (i.e. multiple commands to cover different types of images.) You can run any/all of the commands as you like. Note that the Hypothesis annotation previewer assumes a custom mimetype and may not be useful for most Dataverses (contact [QDR](mailto:qdr@syr.edu) for more information). Dataverse 4.11+ is required. Note that Dataverse installations configured to redirect to S3 storage for file downloads will need to enable CORS at the storage layer as well as the application layer (the latter is enabled by default). (See, for example, [Amazon's CORS configuration guidance](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-cors-configuration.html)). +Also note that using the commands below means that your installation will automatically start using updated versions of the previewers when the master branch of this repository is updated. We intend to announce upcoming changes on the dataverse-community@google-groups.com mailing list, but if you do not want this behavior, you can download the previewers and host them on your own server, adjusting the curl commands below to reference your local copies. + ## How do they work? -The tools here are lightweight wrappers around standard HTML5 functionality (e.g. audio, video), or third-party libraries (pdf) or some combination (e.g. standard image displays with a third-party library to allow zooming, simple text/html displays with third-party libraries used to sanitize content to avoid security issues). +The tools here are lightweight wrappers around standard HTML5 functionality (e.g. audio, video), or third-party libraries (pdf, spreadsheets) or some combination (e.g. standard image displays with a third-party library to allow zooming, simple text/html displays with third-party libraries used to sanitize content to avoid security issues). ## Customizations: The previewers will use your favicon if it exists at the default Dataverse location: ```/javax.faces.resource/images/favicondataverse.png.xhtml``` @@ -25,24 +31,30 @@ File creation date is only shown in the header for Dataverse v4.12+. Video seeking does not work on some browsers and some Dataverse instances due to the lack of support in some Dataverse storageIO drivers for partial file downloads. As of now, Seeking does not work in Chrome but does work in Firefox. Other browsers haven't been tested. -The image previewer only works with image/tiff files on some browsers (as of ~Jan 2020), so the registration for that mimetype ha been removed from the list below. +The image previewer only works with image/tiff files on some browsers (as of ~Jan 2020), so the registration for that mimetype has been removed from the list below. -## Acknowledgements +## Acknowledgments The original tools were developed through the [Qualitative Data Repository](https://qdr.syr.edu) but are being offered to the Dataverse community at large. The Spreadsheet Previewer was contributed by [anncie-pcss](https://github.com/anncie-pcss). [pdurbin](https://github.com/pdurbin) updated the retriever.js script to allow previewers to be embedded directly in the Dataverse file pages. +[juancorr](https://github.com/juancorr) added internationlization and provided a Spanish translation for the existing previewers. + +[kaitlinnewson](https://github.com/kaitlinnewson) provided a French translation for the existing previewers. + ## How can I help? If you are interested in adding additional previewers, or in maintaining/enhancing existing ones, contact us at [dataverse-dev@googlegroups.com](mailto:dataverse-dev@googlegroups.com) or work through github to fork/make pull-requests against the repository. +The wiki now contains a [How To Create a Previewer](https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers/wiki/How-to-create-a-previewer) page that provides a detailed guide to developing new previewers starting from the existing HTML/Javascript templates. (You can also build previewers using any language you choose, starting from the External Tools API in Dataverse.) + Contributors are expected to keep the master branch in a 'production-ready' state, as Dataverse instances may be using the html, javascript, and css files there directly via their github.io URLs (see curl commands below). -By commiting code to the repository, Contributors are agreeing to make it available under the [MIT Open Source license](https://globaldataversecommunityconsortium.github.io/dataverse-previewers/LICENSE). +By committing code to the repository, Contributors are agreeing to make it available under the [MIT Open Source license](https://globaldataversecommunityconsortium.github.io/dataverse-previewers/LICENSE). -## Curl commands to configure these tools with your dataverse instance: +## Curl commands to configure these tools with your Dataverse instance: You should be able to cut/paste any/all of the commands below to run on your Dataverse machine: >curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \\ @@ -59,7 +71,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"text/plain\\" @@ -79,7 +92,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"text/html\\" @@ -99,7 +113,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"audio/mp3\\" @@ -119,7 +134,29 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} +> ] +> }, +> \\"contentType\\":\\"audio/mpeg\\" +>}" + +>curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \\ +>"{ +> \\"displayName\\":\\"Play Audio\\", +> \\"description\\":\\"Listen to an audio file.\\", +> \\"scope\\":\\"file\\", +> \\"type\\":\\"explore\\", +> \\"hasPreviewMode\\":\\"true\\", +> \\"toolUrl\\":\\"https://globaldataversecommunityconsortium.github.io/dataverse-previewers/previewers/AudioPreview.html\", +> \\"toolParameters\\": { +> \\"queryParameters\\":[ +> {\\"fileid\\":\\"{fileId}\\"}, +> {\\"siteUrl\\":\\"{siteUrl}\\"}, +> {\\"key\\":\\"{apiToken}\\"}, +> {\\"datasetid\\":\\"{datasetId}\\"}, +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"audio/wav\\" @@ -139,7 +176,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"audio/ogg\\" @@ -159,7 +197,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"image/gif\\" @@ -179,7 +218,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"image/jpeg\\" @@ -199,7 +239,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"image/png\\" @@ -219,7 +260,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"application/pdf\\" @@ -239,7 +281,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"video/mp4\\" @@ -259,7 +302,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"video/ogg\\" @@ -279,7 +323,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"video/quicktime\\" @@ -299,7 +344,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"text/comma-separated-values\\" @@ -319,7 +365,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"text/tab-separated-values\\" @@ -339,7 +386,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"application/x-stata-syntax\\" @@ -359,7 +407,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"type/x-r-syntax\\" @@ -379,7 +428,8 @@ You should be able to cut/paste any/all of the commands below to run on your Dat > {\\"siteUrl\\":\\"{siteUrl}\\"}, > {\\"key\\":\\"{apiToken}\\"}, > {\\"datasetid\\":\\"{datasetId}\\"}, -> {\\"datasetversion\\":\\"{datasetVersion}\\"} +> {\\"datasetversion\\":\\"{datasetVersion}\\"}, +> {\\"locale\\":\\"{localeCode}\\"} > ] > }, > \\"contentType\\":\\"application/x-json-hypothesis\\" diff --git a/previewers/AudioPreview.html b/previewers/AudioPreview.html index 6efe12c..a4bb7c7 100644 --- a/previewers/AudioPreview.html +++ b/previewers/AudioPreview.html @@ -1,8 +1,12 @@ - + + + + + @@ -12,7 +16,7 @@ -

Audio Preview +

Audio Preview

@@ -20,3 +24,4 @@

Audio Preview

+ diff --git a/previewers/HtmlPreview.html b/previewers/HtmlPreview.html index 67da904..5ed68f2 100644 --- a/previewers/HtmlPreview.html +++ b/previewers/HtmlPreview.html @@ -1,8 +1,12 @@ - + + + + + @@ -12,11 +16,11 @@ -

Html Preview +

Html Preview

- \ No newline at end of file + diff --git a/previewers/HypothesisPreview.html b/previewers/HypothesisPreview.html index 3619354..e63eca1 100644 --- a/previewers/HypothesisPreview.html +++ b/previewers/HypothesisPreview.html @@ -1,10 +1,14 @@ - + + + + + @@ -15,7 +19,7 @@

-ATI Annotations +ATIAnnotations

diff --git a/previewers/ImagePreview.html b/previewers/ImagePreview.html index 4a95ea1..2bd8844 100644 --- a/previewers/ImagePreview.html +++ b/previewers/ImagePreview.html @@ -1,9 +1,13 @@ - + + + + + @@ -13,7 +17,7 @@ -

Image Preview +

Image Preview

diff --git a/previewers/PDFPreview.html b/previewers/PDFPreview.html index 31f9ecd..ddeee65 100644 --- a/previewers/PDFPreview.html +++ b/previewers/PDFPreview.html @@ -1,11 +1,15 @@ - + + + + + @@ -17,7 +21,7 @@ -

PDF Preview +

PDF Preview

@@ -26,7 +30,7 @@

PDF Preview     - Page: / + Page: /

diff --git a/previewers/SpreadsheetPreview.html b/previewers/SpreadsheetPreview.html index b0cb04d..1ea8e5e 100644 --- a/previewers/SpreadsheetPreview.html +++ b/previewers/SpreadsheetPreview.html @@ -1,12 +1,16 @@ - + - + + + + + @@ -17,7 +21,7 @@ -

Spreadsheet Viewer +

Spreadsheet Viewer

diff --git a/previewers/TextPreview.html b/previewers/TextPreview.html index 1b17b32..bf7ac9b 100644 --- a/previewers/TextPreview.html +++ b/previewers/TextPreview.html @@ -1,8 +1,13 @@ - + + + + + + @@ -12,7 +17,7 @@ -

Text Preview +

Text Preview

diff --git a/previewers/VideoPreview.html b/previewers/VideoPreview.html index b082e61..21d6987 100644 --- a/previewers/VideoPreview.html +++ b/previewers/VideoPreview.html @@ -1,8 +1,12 @@ - + + + + + @@ -12,7 +16,7 @@ -

Video Preview +

Video Preview

diff --git a/previewers/i18n/en.json b/previewers/i18n/en.json new file mode 100644 index 0000000..f0d64c7 --- /dev/null +++ b/previewers/i18n/en.json @@ -0,0 +1,24 @@ +{ + "filenameText": "Filename: ", + "inText": "In ", + "byText": ", by ", + "uploadedOnText": "File uploaded on ", + "downloadFileText": "Download File", + "closePreviewText": "Close Preview", + "audioPreviewText": "Audio Preview", + "csvPreviewText": "Csv Preview", + "htmlPreviewText": "Html Preview", + "annotationsText": "Annotations", + "imagePreviewText": "Image Preview", + "pdfPreviewText": "PDF Preview", + "spreadsheetViewerText": "Spreadsheet Viewer", + "textPreviewText": "Text Preview", + "videoPreviewText": "Video Preview", + "prev": "Previous", + "next": "Next", + "pageText": "Page:", + "versionText": "version", + "descriptionText": "Description: ", + "footer": "Previewers originally developed by QDR and maintained at https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers. Feedback and contributions welcome.", +"errorText" : "Please try again. The most common issue is that your login has timed out. If the problem persists, please contact the support team of this data repository. Please include any status code included at the end of this message: " +} diff --git a/previewers/i18n/es.json b/previewers/i18n/es.json new file mode 100644 index 0000000..a6cb7d0 --- /dev/null +++ b/previewers/i18n/es.json @@ -0,0 +1,24 @@ +{ + "filenameText": "Nombre del fichero: ", + "inText": "En ", + "byText": ", por ", + "uploadedOnText": "Fichero subido el ", + "downloadFileText": "Descargar fichero", + "closePreviewText": "Cerrar previsualización", + "audioPreviewText": "Previsualización de audio", + "csvPreviewText": "Previsualización de csv", + "htmlPreviewText": "Previsualización de html", + "annotationsText": "Anotaciones", + "imagePreviewText": "Previsualización de imagen", + "pdfPreviewText": "Previsualización de pdf", + "spreadsheetViewerText": "Visor de hojas de cálculo", + "textPreviewText": "Previsualización de texto", + "videoPreviewText": "Previsualización de vídeo", + "prev": "Anterior", + "next": "Siguiente", + "pageText": "Página:", + "versionText": "versión", + "descriptionText": "Descripción: ", + "footer": "Previsualizadores desarrollados inicialmente por QDR y mantenidos por https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers. Agradecemos tanto el feedback como las contribuciones.", + "errorText" : "Inténtelo de nuevo por favor. El problema más común es que su sesión haya caducado. Si el problema continúa puede contactar con el equipo de soporte de su repositorio de datos. Por favor, indique los códigos de estado que encontrará al final de este mensaje: " +} diff --git a/previewers/i18n/fr.json b/previewers/i18n/fr.json new file mode 100644 index 0000000..cc27874 --- /dev/null +++ b/previewers/i18n/fr.json @@ -0,0 +1,24 @@ +{ + "filenameText": "Nom du fichier: ", + "inText": "Dans ", + "byText": ", par ", + "uploadedOnText": "Fichier téléversé le ", + "downloadFileText": "Télécharger le fichier", + "closePreviewText": "Fermer l'aperçu", + "audioPreviewText": "Aperçu audio", + "csvPreviewText": "Aperçu CSV", + "htmlPreviewText": "Aperçu HTML", + "annotationsText": "Annotations", + "imagePreviewText": "Aperçu image", + "pdfPreviewText": "Aperçu PDF", + "spreadsheetViewerText": "Visualisateur de feuille de calcul", + "textPreviewText": "Aperçu texte", + "videoPreviewText": "Aperçu vidéo", + "prev": "Précédent", + "next": "Suivant", + "pageText": "Page:", + "versionText": "version", + "descriptionText": "Description: ", + "footer": "Le prévisualisateur a été développé par QDR et est accessible au https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers. Vos commentaires et contributions sont les bienvenues.", + "errorText" : "Veuillez réessayer. Le problème le plus commun est que votre session a expiré. Si le problème persiste, veuillez communiquer avec l'équipe de soutien pour ce dépôt de données. Veuillez fournir le code indiqué à la fin du présent message : " +} diff --git a/previewers/js/audio.js b/previewers/js/audio.js index 3b7027e..315a2c8 100644 --- a/previewers/js/audio.js +++ b/previewers/js/audio.js @@ -2,6 +2,11 @@ $(document).ready(function() { startPreview(false); }); +function translateBaseHtmlPage() { + var audioPreviewText = $.i18n( "audioPreviewText" ); + $( '.audioPreviewText' ).text( audioPreviewText ); +} + function writeContent(fileUrl, file, title, authors) { addStandardPreviewHeader(file, title, authors); $('.preview').append($("