[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - loleaflet/main.js loleaflet/src

Jan Holesovsky kendy at collabora.com
Fri Sep 8 19:06:04 UTC 2017


 loleaflet/main.js                             |    3 ++-
 loleaflet/src/core/Socket.js                  |    6 +++++-
 loleaflet/src/layer/tile/TileLayer.js         |    7 ++++++-
 loleaflet/src/map/Map.js                      |    3 ++-
 loleaflet/src/map/handler/Map.FileInserter.js |    6 +++++-
 5 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit 2742357ff37e7526fd072441ee85cbeda3230f7f
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Sep 8 16:42:28 2017 +0200

    HA: Pass WOPISrc= param in all the requests that need to...
    
    ...end up in the same loolwsd instance.
    
    Change-Id: I69c4f5be0c0a6f4ffdec6dd571a5d62f2df4b1fb
    Reviewed-on: https://gerrit.libreoffice.org/42112
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/loleaflet/main.js b/loleaflet/main.js
index 42660a13..ece21653 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -100,7 +100,7 @@ if (wopiSrc != '') {
 	docParams = wopiParams;
 	isWopi = true;
 } else {
-    docURL = filePath;
+	docURL = filePath;
 	docParams = {};
 }
 
@@ -114,6 +114,7 @@ var map = L.map('map', {
 	documentContainer: 'document-container',
 	debug: debugMode,
 	wopi: isWopi,
+	wopiSrc: wopiSrc,
 	alwaysActive: alwaysActive,
 	idleTimeoutSecs: idleTimeoutSecs,  // Dim when user is idle.
 	outOfFocusTimeoutSecs: outOfFocusTimeoutSecs // Dim after switching tabs.
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 163dfd5c..bd2cdd58 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -22,7 +22,11 @@ L.Socket = L.Class.extend({
 			if (map.options.permission) {
 				map.options.docParams['permission'] = map.options.permission;
 			}
-			this.socket = new WebSocket(map.options.server + '/lool/' + encodeURIComponent(map.options.doc + '?' + $.param(map.options.docParams)) + '/ws');
+			var wopiSrc = '';
+			if (map.options.wopiSrc != '') {
+				wopiSrc = '?WOPISrc=' + map.options.wopiSrc;
+			}
+			this.socket = new WebSocket(map.options.server + '/lool/' + encodeURIComponent(map.options.doc + '?' + $.param(map.options.docParams)) + '/ws' + wopiSrc);
 			this.socket.onerror = L.bind(this._onSocketError, this);
 			this.socket.onclose = L.bind(this._onSocketClose, this);
 			this.socket.onopen = L.bind(this._onSocketOpen, this);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 187d26d1..1069e38b 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -526,8 +526,13 @@ L.TileLayer = L.GridLayer.extend({
 		var command = this._map._socket.parseServerCmd(textMsg);
 		var parser = document.createElement('a');
 		parser.href = this._map.options.server;
+
+		var wopiSrc = '';
+		if (map.options.wopiSrc != '') {
+			wopiSrc = '?WOPISrc=' + map.options.wopiSrc;
+		}
 		var url = this._map.options.webserver + '/' + this._map.options.urlPrefix + '/' +
-		    encodeURIComponent(this._map.options.doc) + '/' + command.jail + '/' + command.dir + '/' + command.name;
+		    encodeURIComponent(this._map.options.doc) + '/' + command.jail + '/' + command.dir + '/' + command.name + wopiSrc;
 
 		this._map.hideBusy();
 		if (command.id === 'print') {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index d4869820..6027e26a 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -18,7 +18,8 @@ L.Map = L.Evented.extend({
 		defaultZoom: 10,
 		tileWidthTwips: 3840,
 		tileHeightTwips: 3840,
-		urlPrefix: 'lool'
+		urlPrefix: 'lool',
+		wopiSrc: ''
 	},
 
 	lastActiveTime: Date.now(),
diff --git a/loleaflet/src/map/handler/Map.FileInserter.js b/loleaflet/src/map/handler/Map.FileInserter.js
index f6388dbb..7b6811b0 100644
--- a/loleaflet/src/map/handler/Map.FileInserter.js
+++ b/loleaflet/src/map/handler/Map.FileInserter.js
@@ -14,8 +14,12 @@ L.Map.FileInserter = L.Handler.extend({
 		this._toInsert = {};
 		var parser = document.createElement('a');
 		parser.href = map.options.server;
+		var wopiSrc = '';
+		if (map.options.wopiSrc != '') {
+			wopiSrc = '?WOPISrc=' + map.options.wopiSrc;
+		}
 		this._url = map.options.webserver + '/' + map.options.urlPrefix +
-			'/' + encodeURIComponent(map.options.doc) + '/insertfile';
+			'/' + encodeURIComponent(map.options.doc) + '/insertfile' + wopiSrc;
 	},
 
 	addHooks: function () {


More information about the Libreoffice-commits mailing list