From 102471273adc013b5d5857ee4b3cfd85729e70d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFs=20Poujade?= <lois.poujade@tetras-libre.fr>
Date: Wed, 8 Jun 2022 16:32:09 +0200
Subject: [PATCH] Try to include mirador-annotations plugin

---
 Dockerfile.dev                           |  6 +++
 __tests__/integration/mirador/index.html | 65 +++++++++++-------------
 docker-compose.yml                       | 12 +++++
 package.json                             |  3 +-
 src/init.js                              |  9 ++--
 5 files changed, 57 insertions(+), 38 deletions(-)
 create mode 100644 Dockerfile.dev
 create mode 100644 docker-compose.yml

diff --git a/Dockerfile.dev b/Dockerfile.dev
new file mode 100644
index 000000000..55cdff298
--- /dev/null
+++ b/Dockerfile.dev
@@ -0,0 +1,6 @@
+FROM alpine:latest
+RUN apk add npm
+COPY . /opt
+WORKDIR /opt
+RUN npm install
+CMD npm start
diff --git a/__tests__/integration/mirador/index.html b/__tests__/integration/mirador/index.html
index 43113f007..54ef7cabf 100644
--- a/__tests__/integration/mirador/index.html
+++ b/__tests__/integration/mirador/index.html
@@ -1,46 +1,43 @@
 <!DOCTYPE html>
 <html lang="en">
   <head>
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
-    <meta name="theme-color" content="#000000">
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
+    <meta name="theme-color" content="#000000" />
     <title>Mirador</title>
-    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
+    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
   </head>
   <body>
     <div id="mirador" style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;"></div>
     <script>document.write("<script type='text/javascript' src='../../../dist/mirador.min.js?v=" + Date.now() + "'><\/script>");</script>
     <script type="text/javascript">
-     var miradorInstance = Mirador.viewer({
-       id: 'mirador',
-       theme: {
-         transitions: window.location.port === '4488' ?  { create: () => 'none' } : {},
-       },
-       windows: [{
-         manifestId: 'https://iiif.harvardartmuseums.org/manifests/object/299843',
-         canvasId: 'https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174892',
-         thumbnailNavigationPosition: 'far-bottom',
-       },
-       {
-         manifestId: 'https://iiif.bodleian.ox.ac.uk/iiif/manifest/e32a277e-91e2-4a6d-8ba6-cc4bad230410.json',
-       }],
-       catalog: [
-         { manifestId: 'https://iiif.bodleian.ox.ac.uk/iiif/manifest/e32a277e-91e2-4a6d-8ba6-cc4bad230410.json' },
-         { manifestId: 'https://iiif.harvardartmuseums.org/manifests/object/299843' },
-         { manifestId: "https://media.nga.gov/public/manifests/nga_highlights.json", provider: "National Gallery of Art"},
-         { manifestId: "https://data.ucd.ie/api/img/manifests/ucdlib:33064", provider: "Irish Architectural Archive"},
-         { manifestId: "https://wellcomelibrary.org/iiif/b18035723/manifest", provider: "Wellcome Library"},
-         { manifestId: "https://demos.biblissima.fr/iiif/metadata/florus-dispersus/manifest.json", provider: "Biblissima"},
-         { manifestId: "https://www.e-codices.unifr.ch/metadata/iiif/gau-Fragment/manifest.json", provider: "e-codices - Virtual Manuscript Library of Switzerland"},
-         { manifestId: "https://wellcomelibrary.org/iiif/collection/b18031511", provider: "Wellcome Library"},
-         { manifestId: "https://gallica.bnf.fr/iiif/ark:/12148/btv1b10022508f/manifest.json", provider: "Bibliothèque nationale de France"},
-         { manifestId: "https://manifests.britishart.yale.edu/Osbornfa1", provider: "Beinecke Rare Book and Manuscript Library, Yale University"},
-         { manifestId: "https://iiif.biblissima.fr/chateauroux/B360446201_MS0005/manifest.json", provider: "Biblissima"},
-         { manifestId: "https://iiif.durham.ac.uk/manifests/trifle/32150/t1/m4/q7/t1m4q77fr328/manifest", provider: "Durham University Library"},
-         //{ manifestId: "https://iiif.vam.ac.uk/collections/O1023003/manifest.json", provider: "Ocean liners"},
-         { manifestId: "https://zavicajna.digitalna.rs/iiif/iiif/api/presentation/3/96571949-03d6-478e-ab44-a2d5ad68f935%252F00000001%252Fostalo01%252F00000071/manifest", provider: "Библиотека 'Милутин Бојић'"},
-       ]
-     });
+      var miradorInstance = Mirador.viewer({
+              id: 'mirador',
+              theme: { transitions: window.location.port === '4488' ?  { create: () => 'none' } : {}, },
+              annotation: {
+                      adapter: (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`),
+                      exportLocalStorageAnnotations: false,
+                    },
+              catalog: [
+                      { manifestid: 'http://localhost:8000/dzkimgs_annotated_video.json' },
+                      { manifestid: 'http://localhost:8000/video_split_annopage.json' },
+                      { manifestid: 'http://localhost:8000/fediverse.json' },
+                      { manifestid: 'https://iiif.bodleian.ox.ac.uk/iiif/manifest/e32a277e-91e2-4a6d-8ba6-cc4bad230410.json' },
+                      { manifestid: 'https://iiif.harvardartmuseums.org/manifests/object/299843' },
+                      { manifestid: "https://media.nga.gov/public/manifests/nga_highlights.json", provider: "national gallery of art"},
+                      { manifestid: "https://data.ucd.ie/api/img/manifests/ucdlib:33064", provider: "irish architectural archive"},
+                      { manifestid: "https://wellcomelibrary.org/iiif/b18035723/manifest", provider: "wellcome library"},
+                      { manifestid: "https://demos.biblissima.fr/iiif/metadata/florus-dispersus/manifest.json", provider: "biblissima"},
+                      { manifestid: "https://www.e-codices.unifr.ch/metadata/iiif/gau-fragment/manifest.json", provider: "e-codices - virtual manuscript library of switzerland"},
+                      { manifestid: "https://wellcomelibrary.org/iiif/collection/b18031511", provider: "wellcome library"},
+                      { manifestid: "https://gallica.bnf.fr/iiif/ark:/12148/btv1b10022508f/manifest.json", provider: "bibliothèque nationale de france"},
+                      { manifestid: "https://manifests.britishart.yale.edu/osbornfa1", provider: "beinecke rare book and manuscript library, yale university"},
+                      { manifestid: "https://iiif.biblissima.fr/chateauroux/b360446201_ms0005/manifest.json", provider: "biblissima"},
+                      { manifestid: "https://iiif.durham.ac.uk/manifests/trifle/32150/t1/m4/q7/t1m4q77fr328/manifest", provider: "durham university library"},
+                      //{ manifestid: "https://iiif.vam.ac.uk/collections/o1023003/manifest.json", provider: "ocean liners"},
+                      { manifestid: "https://zavicajna.digitalna.rs/iiif/iiif/api/presentation/3/96571949-03d6-478e-ab44-a2d5ad68f935%252f00000001%252fostalo01%252f00000071/manifest", provider: "библиотека 'милутин бојић'"},
+                    ]
+            });
     </script>
   </body>
 </html>
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 000000000..c1f5f92c4
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,12 @@
+version: "3.9"
+services:
+  mirador:
+    image: mirador_local
+    build:
+      dockerfile: Dockerfile.dev
+      context: .
+    volumes:
+      - ./:/opt
+    ports:
+      - 4444:4444
+    command: "sh -c 'npm install --force && npm start'"
diff --git a/package.json b/package.json
index cb2499faf..fd1127ea0 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
     "build:watch": "webpack --watch --mode=development",
     "prepublishOnly": "npm run clean && npm run build:es && npm run build:cjs && npm run build",
     "size": "bundlewatch --config bundlewatch.config.json",
-    "start": "NODE_ENV=development webpack serve --open"
+    "start": "NODE_ENV=development webpack serve --open --host=0.0.0.0"
   },
   "license": "Apache-2.0",
   "contributors": [
@@ -33,6 +33,7 @@
   ],
   "repository": "https://github.com/ProjectMirador/mirador",
   "dependencies": {
+    "mirador-annotations": "^0.5.0",
     "@material-ui/core": "^4.12.3",
     "@material-ui/icons": "^4.9.1",
     "@material-ui/lab": "^4.0.0-alpha.53",
diff --git a/src/init.js b/src/init.js
index 160437532..f347bb667 100644
--- a/src/init.js
+++ b/src/init.js
@@ -1,9 +1,12 @@
+import miradorAnnotationPlugins from 'mirador-annotations/es/index';
+import LocalStorageAdapter from 'mirador-annotations/es/LocalStorageAdapter';
 import MiradorViewer from './lib/MiradorViewer';
 
 /**
  * Default Mirador instantiation
  */
-function viewer(config, pluginsOrStruct) {
+function viewer(config) {
+  /*
   let struct;
 
   if (Array.isArray(pluginsOrStruct)) {
@@ -11,8 +14,8 @@ function viewer(config, pluginsOrStruct) {
   } else {
     struct = pluginsOrStruct;
   }
-
-  return new MiradorViewer(config, struct);
+*/
+  return new MiradorViewer(config, [...miradorAnnotationPlugins]);
 }
 
 export default {
-- 
GitLab