[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-2' - 2 commits - loleaflet/src loleaflet/welcome wsd/FileServer.cpp

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 16 12:30:00 UTC 2020


 loleaflet/src/control/Control.Menubar.js |   10 ------
 wsd/FileServer.cpp                       |   46 ++++++++++++++++++++++++++++---
 2 files changed, 43 insertions(+), 13 deletions(-)

New commits:
commit c1c9ff3cf2c4ead7236564329eb3c812c2297f07
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Apr 15 16:02:45 2020 +0200
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Apr 16 14:29:56 2020 +0200

    Welcome: Kill the Latest Updates from the menu.
    
    For the moment, we are missing a way to disable it when the feature is
    switched off in loolwsd.xml; so let's just avoid it for the moment.
    
    Change-Id: Ic0cde3ef3c415c9ac7009e4db285b04560018b74
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92276
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92354
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 67b8b0d01..919a4ab3f 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -240,7 +240,6 @@ L.Control.Menubar = L.Control.extend({
 				{name: _('Online Help'), id: 'online-help', type: 'action', iosapp: false},
 				{name: _('Keyboard shortcuts'), id: 'keyboard-shortcuts', type: 'action', iosapp: false},
 				{name: _('Report an issue'), id: 'report-an-issue', type: 'action', iosapp: false},
-				{name: _('Latest Updates'), id: 'latest-updates', type: 'action'},
 				{name: _('About'), id: 'about', type: 'action'}]
 			},
 			{name: _('Last modification'), id: 'last-mod', type: 'action', tablet: false}
@@ -342,7 +341,6 @@ L.Control.Menubar = L.Control.extend({
 				{name: _('Online Help'), id: 'online-help', type: 'action', iosapp: false},
 				{name: _('Keyboard shortcuts'), id: 'keyboard-shortcuts', type: 'action', iosapp: false},
 				{name: _('Report an issue'), id: 'report-an-issue', type: 'action', iosapp: false},
-				{name: _('Latest Updates'), id: 'latest-updates', type: 'action'},
 				{name: _('About'), id: 'about', type: 'action'}]
 			},
 			{name: _('Last modification'), id: 'last-mod', type: 'action', tablet: false}
@@ -459,7 +457,6 @@ L.Control.Menubar = L.Control.extend({
 				{name: _('Online Help'), id: 'online-help', type: 'action', iosapp: false},
 				{name: _('Keyboard shortcuts'), id: 'keyboard-shortcuts', type: 'action', iosapp: false},
 				{name: _('Report an issue'), id: 'report-an-issue', type: 'action', iosapp: false},
-				{name: _('Latest Updates'), id: 'latest-updates', type: 'action'},
 				{name: _('About'), id: 'about', type: 'action'}]
 			},
 			{name: _('Last modification'), id: 'last-mod', type: 'action', tablet: false}
@@ -512,7 +509,6 @@ L.Control.Menubar = L.Control.extend({
 				{name: _UNO('.uno:ShowResolvedAnnotations', 'text'), id: 'showresolved', type: 'action'},
 			]
 			},
-			{name: _('Latest Updates'), id: 'latest-updates', type: 'action'},
 			{name: _('About'), id: 'about', type: 'action'},
 		],
 
@@ -559,7 +555,6 @@ L.Control.Menubar = L.Control.extend({
 			{name: _UNO('.uno:FullScreen', 'presentation'), id: 'fullscreen', type: 'action', mobileapp: false},
 			{uno: '.uno:SpellOnline'},
 			{name: _('Fullscreen presentation'), id: 'fullscreen-presentation', type: 'action'},
-			{name: _('Latest Updates'), id: 'latest-updates', type: 'action'},
 			{name: _('About'), id: 'about', type: 'action'},
 		],
 
@@ -623,7 +618,6 @@ L.Control.Menubar = L.Control.extend({
 			]},
 			{uno: '.uno:SpellOnline'},
 			{name: _UNO('.uno:FullScreen', 'spreadsheet'), id: 'fullscreen', type: 'action', mobileapp: false},
-			{name: _('Latest Updates'), id: 'latest-updates', type: 'action'},
 			{name: _('About'), id: 'about', type: 'action'},
 		],
 
@@ -711,7 +705,7 @@ L.Control.Menubar = L.Control.extend({
 			'downloadas-odp', 'downloadas-ppt', 'downloadas-pptx', 'print', // file menu
 			'downloadas-ods', 'downloadas-xls', 'downloadas-xlsx', 'closedocument', // file menu
 			'fullscreen', 'zoomin', 'zoomout', 'zoomreset', 'showresolved', // view menu
-			'about', 'keyboard-shortcuts', 'latest-updates', 'online-help', 'report-an-issue' // help menu
+			'about', 'keyboard-shortcuts', 'online-help', 'report-an-issue' // help menu
 		]
 	},
 
@@ -1180,8 +1174,6 @@ L.Control.Menubar = L.Control.extend({
 			});
 		} else if (id === 'about') {
 			this._map.showLOAboutDialog();
-		} else if (id === 'latest-updates') {
-			this._map.showWelcomeDialog(/*calledFromMenu=*/true);
 		} else if (id === 'report-an-issue') {
 			window.open('https://bugs.documentfoundation.org/enter_bug.cgi?product=LibreOffice%20Online', '_blank');
 		} else if (id === 'inserthyperlink') {
commit 640a4d26ec4afeaf0b2860665742b8e1fb3f1847
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Apr 15 15:37:49 2020 +0200
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Apr 16 14:29:42 2020 +0200

    Welcome: Handle language versions of the welcome files.
    
    If eg. welcome-cs-CZ.html is not available, try welcome-cs.html and
    fallback to welcome.html (which should be the en-US version).
    
    Change-Id: I5df6a6d6da97fb3c111a709a63a54ee86248f73d
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92274
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92353
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/welcome/welcome-en-US.html b/loleaflet/welcome/welcome.html
similarity index 100%
rename from loleaflet/welcome/welcome-en-US.html
rename to loleaflet/welcome/welcome.html
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index d019957c0..9c4bd8ba4 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -56,6 +56,10 @@ using Poco::Util::Application;
 
 std::map<std::string, std::pair<std::string, std::string>> FileServerRequestHandler::FileHash;
 
+/// Place from where we serve the welcome-<lang>.html; defaults to
+/// welcome.html if no lang matches.
+#define WELCOME_ENDPOINT "/loleaflet/dist/welcome"
+
 namespace {
 
 int functionConversation(int /*num_msg*/, const struct pam_message** /*msg*/,
@@ -283,8 +287,11 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
 
         std::vector<std::string> requestSegments;
         requestUri.getPathSegments(requestSegments);
-        const std::string relPath = getRequestPathname(request);
-        const std::string endPoint = requestSegments[requestSegments.size() - 1];
+        if (requestSegments.size() < 1)
+            throw Poco::FileNotFoundException("Invalid URI request: [" + requestUri.toString() + "].");
+
+        std::string relPath = getRequestPathname(request);
+        std::string endPoint = requestSegments[requestSegments.size() - 1];
         const auto& config = Application::instance().config();
 
         if (request.getMethod() == HTTPRequest::HTTP_POST && endPoint == "logging.html")
@@ -301,8 +308,39 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M
             }
         }
 
+        // handling of the language in welcome-*.html - shorten the langtag as
+        // necessary, if we don't have the particular language version
+        if (Util::startsWith(relPath, WELCOME_ENDPOINT "/"))
+        {
+            bool found = true;
+            while (FileHash.find(relPath) == FileHash.end())
+            {
+                size_t dot = relPath.find_last_of('.');
+                if (dot == std::string::npos)
+                {
+                    found = false;
+                    break;
+                }
+
+                size_t dash = relPath.find_last_of("-_", dot);
+                if (dash == std::string::npos)
+                {
+                    found = false;
+                    break;
+                }
+
+                relPath = relPath.substr(0, dash) + relPath.substr(dot);
+                LOG_TRC("Shortening welcome file request to: " << relPath);
+            }
+
+            if (!found)
+                throw Poco::FileNotFoundException("Invalid URI welcome file request: [" + requestUri.toString() + "].");
+
+            endPoint = relPath.substr(sizeof(WELCOME_ENDPOINT));
+        }
+
         // Is this a file we read at startup - if not; its not for serving.
-        if (requestSegments.size() < 1 || FileHash.find(relPath) == FileHash.end())
+        if (FileHash.find(relPath) == FileHash.end())
             throw Poco::FileNotFoundException("Invalid URI request: [" + requestUri.toString() + "].");
 
         const std::string loleafletHtml = config.getString("loleaflet_html", "loleaflet.html");
@@ -562,7 +600,7 @@ void FileServerRequestHandler::initialize()
     if (!LOOLWSD::WelcomeFilesRoot.empty())
     {
         try {
-            readDirToHash(LOOLWSD::WelcomeFilesRoot, "", "/loleaflet/dist/welcome");
+            readDirToHash(LOOLWSD::WelcomeFilesRoot, "", WELCOME_ENDPOINT);
         } catch (...) {
             LOG_ERR("Failed to read from directory " << LOOLWSD::WelcomeFilesRoot);
         }


More information about the Libreoffice-commits mailing list