[Libreoffice-commits] online.git: 2 commits - loleaflet/dist loleaflet/main.js loleaflet/src loolwsd/FileServer.cpp

Henry Castro hcastro at collabora.com
Tue Sep 27 21:26:44 UTC 2016


 loleaflet/dist/loleaflet.html                |    1 
 loleaflet/main.js                            |    2 
 loleaflet/src/control/Control.Attribution.js |   56 +--------------------------
 loleaflet/src/layer/Layer.js                 |    8 ---
 loleaflet/src/map/Map.js                     |   10 +++-
 loleaflet/src/map/handler/Map.Keyboard.js    |    3 +
 loolwsd/FileServer.cpp                       |   10 ++++
 7 files changed, 25 insertions(+), 65 deletions(-)

New commits:
commit 0ccbf8b2358a3fdfd939bb76d787de2d5e755594
Author: Henry Castro <hcastro at collabora.com>
Date:   Tue Sep 27 15:54:20 2016 -0400

    loolwsd: bccu#2022, User warning on hitting limit

diff --git a/loolwsd/FileServer.cpp b/loolwsd/FileServer.cpp
index d56824f..3337c04 100644
--- a/loolwsd/FileServer.cpp
+++ b/loolwsd/FileServer.cpp
@@ -39,6 +39,15 @@
 #include "FileServer.hpp"
 #include "LOOLWSD.hpp"
 
+/* CODE */
+#define LOOLWSD_CODE "This development build is limited to %d documents, and %d connections - to avoid the impression that it is suitable for deployment in large enterprises. To find out more about deploying and scaling %s checkout - <a href=\"%s\">%s</a>."
+
+/* PRODUCT */
+#define LOOLWSD_PRODUCT "LibreOffice Online"
+
+/* PRODUCT URL */
+#define LOOLWSD_URL "https://wiki.documentfoundation.org/Development/LibreOffice_Online"
+
 using Poco::FileInputStream;
 using Poco::Net::HTMLForm;
 using Poco::Net::HTTPRequest;
@@ -242,6 +251,7 @@ void FileServerRequestHandler::preprocessFile(HTTPServerRequest& request, HTTPSe
     Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN_TTL%"), accessTokenTtl);
     Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
     Poco::replaceInPlace(preprocess, std::string("%VERSION%"), std::string(LOOLWSD_VERSION_HASH));
+    Poco::replaceInPlace(preprocess, std::string("%CODE%"), Poco::format(LOOLWSD_CODE, MAX_SESSIONS, MAX_SESSIONS, std::string(LOOLWSD_PRODUCT), std::string(LOOLWSD_URL), std::string(LOOLWSD_URL)));
 
     response.setContentType("text/html");
     response.setContentLength(preprocess.length());
commit c3568a6a41ee4c1d03e258eaba9344c34e164b41
Author: Henry Castro <hcastro at collabora.com>
Date:   Tue Sep 27 17:21:43 2016 -0400

    loleaflet: refactor L.Control.Attribution.js

diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index ff3edca..bf1794b 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -56,6 +56,7 @@
     <script>
       window.host = '%HOST%';
       window.access_token = '%ACCESS_TOKEN%';
+      window.attribution = '%CODE%';
     </script>
     <script src="/loleaflet/%VERSION%/branding.js"></script> <!-- logo onclick handler -->
     <script src="/loleaflet/%VERSION%/bundle.js"></script>
diff --git a/loleaflet/main.js b/loleaflet/main.js
index cb53fb7..226a55b 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -93,7 +93,7 @@ var map = L.map('map', {
     timestamp: timestamp,
     documentContainer: 'document-container',
     debug: debugMode
-});
+}, attribution);
 // toolbar.js (loaded in <script> tag accesses map as global variable,
 // so expose it
 global.map = map;
diff --git a/loleaflet/src/control/Control.Attribution.js b/loleaflet/src/control/Control.Attribution.js
index b5130e5..17cc79e 100644
--- a/loleaflet/src/control/Control.Attribution.js
+++ b/loleaflet/src/control/Control.Attribution.js
@@ -10,23 +10,14 @@ L.Control.Attribution = L.Control.extend({
 
 	initialize: function (options) {
 		L.setOptions(this, options);
-
-		this._attributions = {};
 	},
 
 	onAdd: function (map) {
-		this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
-		if (L.DomEvent) {
+		if (!this._container) {
+			this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
 			L.DomEvent.disableClickPropagation(this._container);
 		}
 
-		// TODO ugly, refactor
-		for (var i in map._layers) {
-			if (map._layers[i].getAttribution) {
-				this.addAttribution(map._layers[i].getAttribution());
-			}
-		}
-
 		this._update();
 
 		return this._container;
@@ -38,51 +29,10 @@ L.Control.Attribution = L.Control.extend({
 		return this;
 	},
 
-	addAttribution: function (text) {
-		if (!text) { return this; }
-
-		if (!this._attributions[text]) {
-			this._attributions[text] = 0;
-		}
-		this._attributions[text]++;
-
-		this._update();
-
-		return this;
-	},
-
-	removeAttribution: function (text) {
-		if (!text) { return this; }
-
-		if (this._attributions[text]) {
-			this._attributions[text]--;
-			this._update();
-		}
-
-		return this;
-	},
-
 	_update: function () {
 		if (!this._map) { return; }
 
-		var attribs = [];
-
-		for (var i in this._attributions) {
-			if (this._attributions[i]) {
-				attribs.push(i);
-			}
-		}
-
-		var prefixAndAttribs = [];
-
-		if (this.options.prefix) {
-			prefixAndAttribs.push(this.options.prefix);
-		}
-		if (attribs.length) {
-			prefixAndAttribs.push(attribs.join(', '));
-		}
-
-		this._container.innerHTML = prefixAndAttribs.join(' | ');
+		this._container.innerHTML = this.options.prefix;
 	}
 });
 
diff --git a/loleaflet/src/layer/Layer.js b/loleaflet/src/layer/Layer.js
index 493bd04..65b4e2c 100644
--- a/loleaflet/src/layer/Layer.js
+++ b/loleaflet/src/layer/Layer.js
@@ -46,10 +46,6 @@ L.Layer = L.Evented.extend({
 
 		this.onAdd(map);
 
-		if (this.getAttribution && this._map.attributionControl) {
-			this._map.attributionControl.addAttribution(this.getAttribution());
-		}
-
 		if (this.getEvents) {
 			map.on(this.getEvents(), this);
 		}
@@ -86,10 +82,6 @@ L.Map.include({
 			layer.onRemove(this);
 		}
 
-		if (layer.getAttribution && this.attributionControl) {
-			this.attributionControl.removeAttribution(layer.getAttribution());
-		}
-
 		if (layer.getEvents) {
 			this.off(layer.getEvents(), layer);
 		}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index f456ce6..5fe8dd3 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -20,7 +20,7 @@ L.Map = L.Evented.extend({
 		urlPrefix: 'lool'
 	},
 
-	initialize: function (id, options) { // (HTMLElement or String, Object)
+	initialize: function (id, options, attribution) { // (HTMLElement or String, Object)
 		options = L.setOptions(this, options);
 
 		if (this.options.documentContainer) {
@@ -55,6 +55,10 @@ L.Map = L.Evented.extend({
 			options.webserver = options.server.replace(/^(ws|wss):/i, protocol);
 		}
 
+		if (attribution) {
+			this._attributionControl = L.control.attribution({prefix: attribution}).addTo(this);
+		}
+
 		// we are adding components like '/insertfile' at the end which would
 		// lead to URL's of the form <webserver>//insertfile/...
 		options.webserver = options.webserver.replace(/\/*$/, '');
@@ -1051,6 +1055,6 @@ L.Map = L.Evented.extend({
 	}
 });
 
-L.map = function (id, options) {
-	return new L.Map(id, options);
+L.map = function (id, options, attribution) {
+	return new L.Map(id, options, attribution);
 };
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 5872247..248fdc6 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -397,6 +397,9 @@ L.Map.Keyboard = L.Handler.extend({
 			} else if (e.originalEvent.altKey) {
 				switch (e.originalEvent.keyCode) {
 				case 68: // Ctrl + Shift + Alt + d for tile debugging mode
+					if (this._map._attributionControl) {
+						this._map.removeControl(this._map._attributionControl);
+					}
 					this._map._docLayer.toggleTileDebugMode();
 				}
 			}


More information about the Libreoffice-commits mailing list