Index: /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/etc/collectionConfig.xml
===================================================================
--- /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/etc/collectionConfig.xml	(revision 37104)
+++ /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/etc/collectionConfig.xml	(revision 37105)
@@ -52,19 +52,7 @@
 			  </xsl:template>
 			  
-			<xsl:template name="document-link-miradorORIG">
-				<a><xsl:attribute name="href"><xsl:value-of select="$library_name"/><xsl:text>/collection/</xsl:text><xsl:value-of select="/page/pageResponse/collection/@name"/><xsl:text>/document/</xsl:text><xsl:choose><xsl:when test="@OID"><xsl:value-of select="@OID"/></xsl:when><xsl:when test="@OIDmetadata"><xsl:variable name="OIDmeta" select="@OIDmetadata"/><xsl:value-of select="metadataList/metadata[@name='{$OIDmeta}']"/></xsl:when><xsl:otherwise><xsl:value-of select="@nodeID"/></xsl:otherwise></xsl:choose><xsl:text>?book=mirador&amp;ed=1</xsl:text></xsl:attribute><img src="interfaces/{$interface_name}/images/iannotate.png" style="vertical-align:middle;"/> (Annotate)<!--
-(<gsf:icon type="document" style="vertical-align:middle;"/> Mirador Annotate)
--->
-<!--
-<xsl:copy-of select="@value"/>
--->
-<!--
-<xsl:apply-templates selet="@*|node()"/>
--->
-</a>
-			</xsl:template>
-<!--
-modify the collection description template to output the "this collection contains X documents and was last built Y days ago" message
--->
+			  <!--
+			      modify the collection description template to output the "this collection contains X documents and was last built Y days ago" message
+			  -->
 			<xsl:template name="coll-description">
 				<p>
@@ -263,21 +251,34 @@
 		     <gsf:metadata name="GVDocumentOCRJSON"/>
 		     <gsf:metadata name="Image"/>
-		     
+
 		   </gsf:headMetaTags>
 
 			<gsf:option name="TOC" value="true"/>
-			<gsf:option name="allowUserComments" value="true"/>
+			<gsf:option name="allowUserComments"    value="true"/>
 			<gsf:option name="allowDocumentEditing" value="true"/>
-			<gsf:option name="allowMapGPSEditing" value="true"/>
-<!--
-Overwriting this template allows you to change the heading of the document.
--->
-<!--
-<gsf:template name="documentHeading">
+			<gsf:option name="allowMapGPSEditing"   value="true"/>
+
+
+			<gsf:option name="includeFileAssocOpenAnnotations" value="false"/>
+			
+			<gsf:option name="includeEditableOpenAnnotations"  value="true" endpointURL="/simpleAnnotationStore/annotation" />
+			<!--
+			<gsf:option name="includeEditableOpenAnnotations"  value="true" endpointURL="localStorage" />
+			-->
+
+			<!--
+			<gsf:variable name="openAnnotationEndpoint">https://intermuse.sowemustthink.space/simpleAnnotationStore/annotation</gsf:variable>
+			-->
+
+			<!--
+			    Overwriting this template allows you to change the heading of the document.
+			-->
+			<!--
+			    <gsf:template name="documentHeading">
 				<span style="font-weight:italic; font-size: 120%;">
 					<xsl:call-template name="choose-title"/>
 				</span>
 			</gsf:template>
--->
+			-->
 			<xsl:template name="documentHeadingOLD">
 			  <!--
Index: /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js
===================================================================
--- /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js	(revision 37104)
+++ /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js	(revision 37105)
@@ -218,79 +218,4 @@
 
 
-/*
-
-https://stackoverflow.com/questions/57071788/google-vision-api-text-detection-display-words-by-block
-
-
-https://gist.github.com/UBISOFT-1/f00e4d22790f4af378d70b237fa56ca9
-
-    response = client.text_detection(image=image)
-    # The actual response for the first page of the input file.
-    breaks = vision.enums.TextAnnotation.DetectedBreak.BreakType
-    paragraphs = []
-    lines = []
-    # extract text by block of detection
-    for page in response.full_text_annotation.pages:
-        for block in page.blocks:
-            for paragraph in block.paragraphs:
-                para = ""
-                line = ""
-                suppose = str(paragraph.bounding_box)
-                suppose = suppose.replace('vertices ','')
-                print(suppose)
-                for word in paragraph.words:
-                    for symbol in word.symbols:
-                        line += symbol.text
-                        if symbol.property.detected_break.type == breaks.SPACE:
-                            line += ' '
-                        if symbol.property.detected_break.type == breaks.EOL_SURE_SPACE:
-                            line += ' '
-                            lines.append(line)
-                            para += line
-                            line = ''
-                        if symbol.property.detected_break.type == breaks.LINE_BREAK:
-                            lines.append(line)
-                            para += line
-                            line = ''
-            paragraphs.append(para)
-
-
-    return "\n".join(paragraphs)
-
-
-
-
-https://blog.searce.com/tips-tricks-for-using-google-vision-api-for-text-detection-2d6d1e0c6361
-
-def draw_boxes(image, bounds, color,width=5):
-    draw = ImageDraw.Draw(image)
-    for bound in bounds:
-        draw.line([
-            bound.vertices[0].x, bound.vertices[0].y,
-            bound.vertices[1].x, bound.vertices[1].y,
-            bound.vertices[2].x, bound.vertices[2].y,
-            bound.vertices[3].x, bound.vertices[3].y,
-            bound.vertices[0].x, bound.vertices[0].y],fill=color, width=width)
-    return image
-def get_document_bounds(response, feature):
-    for i,page in enumerate(document.pages):
-        for block in page.blocks:
-            if feature==FeatureType.BLOCK:
-                bounds.append(block.bounding_box)
-            for paragraph in block.paragraphs:
-                if feature==FeatureType.PARA:
-                    bounds.append(paragraph.bounding_box)
-                for word in paragraph.words:
-                    for symbol in word.symbols:
-                        if (feature == FeatureType.SYMBOL):
-                            bounds.append(symbol.bounding_box)
-                    if (feature == FeatureType.WORD):
-                        bounds.append(word.bounding_box)
-    return bounds
-bounds=get_document_bounds(response, FeatureType.WORD)
-draw_boxes(image,bounds, 'yellow')
-
-*/
-
 
 
@@ -301,15 +226,18 @@
 
     var canvas_index = goto_page -1;
+
+    var httpDocument = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + gs.cgiParams.d;
+    var httpDocumentIIIFManifest = httpDocument + "?sa=iiif-manifest&ed=1&excerptid-text=iiif-manifest";
+
+    //const endpointUrl = 'https://intermuse.sowemustthink.space/simpleAnnotationStore/annotation';
+    //const endpointUrl = '/simpleAnnotationStore/annotation';
     
     var mirador3_config = {
 	"manifests": {
-	    "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json": {
+	    httpDocumentIIIFManifest: {
 		"provider": "InterMusE"
 	    }
 	},
-	"window" : { "panels": { "annotations": true, "attribution": true },
-		     "defaultSideBarPanel": "annotations",
-		     "sideBarOpenByDefault": true		     
-		   },
+	"window" : { "panels": { "attribution": true, "search": true } },
 
 	//"annotations": {
@@ -317,4 +245,5 @@
 	//  "filteredMotivations": ['oa:commenting', 'oa:tagging', 'sc:painting', 'commenting', 'tagging'],
 	//},
+	/*
 	"requests": {
 	    "postprocessors": [
@@ -330,9 +259,9 @@
 		}
 	    ]
-	},
+	},*/
     
 	"windows": [
 	    {
-		"loadedManifest": "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json",
+		"loadedManifest": httpDocumentIIIFManifest,
 		"canvasIndex": canvas_index,
 		"thumbnailNavigationPosition": 'far-bottom'
@@ -341,44 +270,43 @@
     };
 
+    var includeFileAssocOpenAnnotations = gs.variables.optionIncludeFileAssocOpenAnnotations;
+    var includeEditableOpenAnnotations  = gs.variables.optionIncludeEditableOpenAnnotations;
+
+    console.log("**** includeFileAssocOpenAnnotations = " + includeFileAssocOpenAnnotations);
+    console.log("**** includeEditableOpenAnnotations = " + includeEditableOpenAnnotations);
+    
+    if ((includeFileAssocOpenAnnotations == 'true') || (includeEditableOpenAnnotations == 'true')) {
+	// Activate the annotations plugin
+
+	mirador3_config.window.panels.annotations = true;
+	
+	mirador3_config.window.defaultSideBarPanel = "annotations";
+	mirador3_config.window.sideBarOpenByDefault = true;	  
+
+	if (includeEditableOpenAnnotations == 'true') {
+
+	    //console.log("**** gs.variables.endpointURL = '" + gs.variables.endpointURL + "'");
+	    //const endpointURL = gs.variables.endpointURL;
+
+	    var endpointURL  = gs.variables.optionIncludeEditableOpenAnnotationsEndpointURL;
+	    console.log("**** endpointURL = '" + endpointURL + "'");
+	    
+	    mirador3_config.annotation = {};
+	
+	    if ((endpointURL == "") || (endpointURL == "localStorage")) {
+		mirador3_config.annotation.adapter = (canvasId) => new mirador3WithAnnotations.LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`)
+	    }
+	    else {
+		mirador3_config.annotation.adapter = (canvasId) => new mirador3WithAnnotations.SimpleAnnotationServerV2Adapter(canvasId, endpointURL);
+	    }
+
+	    // **** add in a further options for this ????
+	
+	    mirador3_config.annotation.exportLocalStorageAnnotations = true;  // display annotation JSON export button
+	
+	}
+    }
     
     var mirador3_viewer = mirador3WithAnnotations.initMirador3Viewer('mirador3-viewer',mirador3_config);
-
-    /*
-    var mirador3_viewer = Mirador.viewer({
-	"id": "mirador3-viewer",
-	"manifests": {
-	    "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json": {
-		"provider": "IntermusE"
-	    }
-	},
-	"window" : { "panels" : { "annotations": true, "attribution": false } },
-	//"annotations": {
-	//  "htmlSanitizationRuleSet": 'iiif', // See src/lib/htmlRules.js for acceptable values
-	//  "filteredMotivations": ['oa:commenting', 'oa:tagging', 'sc:painting', 'commenting', 'tagging'],
-	//},
-	"requests": {
-	    "postprocessors": [
-		(url, action) => {
-		    if (action.type === "mirador/RECEIVE_MANIFEST") {
-			//console.log(action)
-			//console.log(iiif_manifest);
-			return {
-			    ...action ,
-			    "manifestJson": iiif_manifest
-			};
-		    }
-		}
-	    ]
-	},
-    
-	"windows": [
-	    {
-		"loadedManifest": "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json",
-		"canvasIndex": 0,
-		"thumbnailNavigationPosition": 'far-bottom'
-	    }
-	]
-    });
-    */
     
     return mirador3_viewer;
Index: /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/transform/pages/document.xsl
===================================================================
--- /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/transform/pages/document.xsl	(revision 37104)
+++ /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/transform/pages/document.xsl	(revision 37105)
@@ -84,5 +84,5 @@
 
 
-  <xsl:template name="googlevision-ocr-json">
+  <xsl:template name="opt-googlevision-ocr-json">
     <xsl:param name="assocfilepath"/>
     
@@ -90,19 +90,15 @@
     <gsf:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')"/></gsf:variable>
 
-    <!--
-    <div style="padding-top: 10px; padding-bottom: 10px;">
-      Google Vision OCR JSON:
-      <a>
-	<xsl:attribute name="href">
-	  <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
-	  <xsl:text>/index/assoc/</xsl:text><xsl:value-of disable-output-escaping="yes" select="$assocfilepath" /><xsl:text>/</xsl:text><xsl:value-of select="$GVDocumentOCRJSON"/>
-	</xsl:attribute>
-	<xsl:value-of select="$GVDocumentOCRJSON"/>
-      </a>
-    </div>
-    -->
-    <gsf:script>
-      load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);
-    </gsf:script>
+    <gsf:switch>
+      <gsf:metadata name="HasGoogleVisionDocumentOCRJSON"/>
+      <gsf:when test='equals' test-value="1">
+
+	<gsf:script>
+	  // Load in the Google Vision OCR JSON file and display bounding boxes for this document (docType=simple) or page (docType=paged)
+	  load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);
+	</gsf:script>
+      </gsf:when>
+    </gsf:switch>
+    
   </xsl:template>
 
@@ -117,5 +113,5 @@
 
     <!-- add in Google Vision OCR JSON link for section image -->
-    <xsl:call-template name="googlevision-ocr-json">
+    <xsl:call-template name="opt-googlevision-ocr-json">
       <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" select="root"/></xsl:with-param>
     </xsl:call-template>    
@@ -177,4 +173,16 @@
   <xsl:template name="documentPre">
     <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
+
+    <gsf:variable name="optionIncludeFileAssocOpenAnnotations">
+      <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeFileAssocOpenAnnotations']/@value"/>
+    </gsf:variable>
+    <gsf:variable name="optionIncludeEditableOpenAnnotations">
+      <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@value"/>
+    </gsf:variable>
+    <gsf:variable name="optionIncludeEditableOpenAnnotationsEndpointURL">
+      <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@endpointURL"/>
+    </gsf:variable>
+
+
     <gsf:variable name="chosenTitle"><xsl:call-template name="choose-title"/></gsf:variable>
     <!-- <gsf:variable name="toplevelTitle"><gsf:metadata name="Title" select="root"/></gsf:variable> -->
@@ -259,20 +267,7 @@
     
     <xsl:if test="@docType='simple'">
-
-      <!--
-      <gsf:switch>
-	<gsf:metadata name='HasGoogleVisionDocumentOCRJSON";'/>
-      <gsf:when test='equals' test-value="1">
-      -->
-
-	  <!-- add in Google Vision OCR JSON link for simple page image -->      
-	  <xsl:call-template name="googlevision-ocr-json">
-	    <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
-	  </xsl:call-template>
-	  <!--
-	</gsf:when>
-      </gsf:switch>
--->
-      
+      <xsl:call-template name="opt-googlevision-ocr-json">
+	<xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
+      </xsl:call-template>      
     </xsl:if>
   </xsl:template>
@@ -282,6 +277,24 @@
     <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->    
     <div style="position: relative; width: 100%; height: 800px;">
-      <div id="mirador3-viewer"> <xsl:comment>filler</xsl:comment></div>
-    </div>
+      <div id="mirador3-viewer"><xsl:comment>filler</xsl:comment></div>
+    </div>
+
+    <!--
+    <gsf:variable name="endpointURL">
+      <xsl:choose>
+	<xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@value='true'">
+	  <xsl:choose>
+	    <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@endpointURL">
+	      <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@endpointURL"/>
+	    </xsl:when>
+	    <xsl:otherwise>
+	      <xsl:text>localStorage</xsl:text> < ! - - default - - >
+	    </xsl:otherwise>
+	  </xsl:choose>
+        </xsl:when>
+	<xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
+    </gsf:variable>
+    -->
 
     <gsf:script>      
