[Libreoffice-commits] online.git: loleaflet/welcome loolwsd.xml.in wsd/FileServer.cpp wsd/FileServer.hpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Jan Holesovsky (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 16 09:30:20 UTC 2020
loleaflet/welcome/welcome-en-US.html | 5 +++++
loolwsd.xml.in | 5 +++++
wsd/FileServer.cpp | 19 +++++++++++++------
wsd/FileServer.hpp | 2 +-
wsd/LOOLWSD.cpp | 12 +++++++++++-
wsd/LOOLWSD.hpp | 1 +
6 files changed, 36 insertions(+), 8 deletions(-)
New commits:
commit 7f96586922471457938ba1138ca7a8f7f384c4cc
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Tue Apr 14 19:50:04 2020 +0200
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Apr 16 11:30:00 2020 +0200
Welcome: Serve the release notes files from a given (configured) directory.
Change-Id: Iae36c1c48fee963659662436d594be659908a3e3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92216
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/welcome/welcome-en-US.html b/loleaflet/welcome/welcome-en-US.html
new file mode 100644
index 000000000..637bd3375
--- /dev/null
+++ b/loleaflet/welcome/welcome-en-US.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+ <p>test</p>
+</body>
+</html>
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index a8442c91e..1739a661f 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -114,6 +114,11 @@
<text desc="Watermark text to be displayed on the document if entered" type="string"></text>
</watermark>
+ <welcome>
+ <enable type="bool" desc="Controls whether the welcome screen should be shown to the users on new install and updates." default="true">true</enable>
+ <path desc="Path to 'welcome-$lang.html' files served on first start or when the version changes. When empty, defaults to the Release notes." type="path" relative="true" default="loleaflet/welcome"></path>
+ </welcome>
+
<storage desc="Backend storage">
<filesystem allow="false" />
<wopi desc="Allow/deny wopi storage. Mutually exclusive with webdav." allow="true">
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index ce9e12756..e5e08e92a 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -469,7 +469,7 @@ void FileServerRequestHandler::sendError(int errorCode, const Poco::Net::HTTPReq
socket->send(oss.str());
}
-void FileServerRequestHandler::readDirToHash(const std::string &basePath, const std::string &path)
+void FileServerRequestHandler::readDirToHash(const std::string &basePath, const std::string &path, const std::string &prefix)
{
struct dirent *currentFile;
struct stat fileStat;
@@ -539,7 +539,7 @@ void FileServerRequestHandler::readDirToHash(const std::string &basePath, const
} while(true);
- FileHash.emplace(relPath, std::make_pair(uncompressedFile, compressedFile));
+ FileHash.emplace(prefix + relPath, std::make_pair(uncompressedFile, compressedFile));
deflateEnd(&strm);
}
}
@@ -551,13 +551,20 @@ void FileServerRequestHandler::readDirToHash(const std::string &basePath, const
void FileServerRequestHandler::initialize()
{
- static const std::vector<std::string> subdirs = { "/loleaflet/dist" };
- for(const auto& subdir: subdirs)
+ // loleaflet files
+ try {
+ readDirToHash(LOOLWSD::FileServerRoot, "/loleaflet/dist");
+ } catch (...) {
+ LOG_ERR("Failed to read from directory " << LOOLWSD::FileServerRoot);
+ }
+
+ // welcome / release notes files
+ if (!LOOLWSD::WelcomeFilesRoot.empty())
{
try {
- readDirToHash(LOOLWSD::FileServerRoot, subdir);
+ readDirToHash(LOOLWSD::WelcomeFilesRoot, "", "/loleaflet/dist/welcome");
} catch (...) {
- LOG_ERR("Failed to read from directory " << subdir);
+ LOG_ERR("Failed to read from directory " << LOOLWSD::WelcomeFilesRoot);
}
}
}
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index 097208e21..365da309c 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -35,7 +35,7 @@ public:
/// Clean cached files.
static void uninitialize() { FileHash.clear(); }
- static void readDirToHash(const std::string &basePath, const std::string &path);
+ static void readDirToHash(const std::string &basePath, const std::string &path, const std::string &prefix = std::string());
static const std::string *getCompressedFile(const std::string &path);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7f67f2b10..a8bfd4ad1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -717,6 +717,7 @@ std::string LOOLWSD::LoTemplate;
std::string LOOLWSD::ChildRoot;
std::string LOOLWSD::ServerName;
std::string LOOLWSD::FileServerRoot;
+std::string LOOLWSD::WelcomeFilesRoot;
std::string LOOLWSD::ServiceRoot;
std::string LOOLWSD::LOKitVersion;
std::string LOOLWSD::HostIdentifier;
@@ -935,7 +936,9 @@ void LOOLWSD::initialize(Application& self)
{ "sys_template_path", "systemplate" },
{ "trace.path[@compress]", "true" },
{ "trace.path[@snapshot]", "false" },
- { "trace[@enable]", "false" }
+ { "trace[@enable]", "false" },
+ { "welcome.enable", "true" },
+ { "welcome.path", "loleaflet/welcome" }
};
// Set default values, in case they are missing from the config file.
@@ -1138,7 +1141,14 @@ void LOOLWSD::initialize(Application& self)
ChildRoot = getPathFromConfig("child_root_path");
ServerName = config().getString("server_name");
+ LOG_DBG("FileServerRoot before config: " << FileServerRoot);
FileServerRoot = getPathFromConfig("file_server_root_path");
+ LOG_DBG("FileServerRoot after config: " << FileServerRoot);
+
+ WelcomeFilesRoot = getPathFromConfig("welcome.path");
+ if (!getConfigValue<bool>(conf, "welcome.enable", true))
+ WelcomeFilesRoot = "";
+
NumPreSpawnedChildren = getConfigValue<int>(conf, "num_prespawn_children", 1);
if (NumPreSpawnedChildren < 1)
{
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index ec36fe26f..4470e8871 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -235,6 +235,7 @@ public:
static std::string ChildRoot;
static std::string ServerName;
static std::string FileServerRoot;
+ static std::string WelcomeFilesRoot; ///< From where we should serve the release notes (or otherwise useful content) that is shown on first install or version update.
static std::string ServiceRoot; ///< There are installations that need prefixing every page with some path.
static std::string LOKitVersion;
static std::string HostIdentifier; ///< A unique random hash that identifies this server
More information about the Libreoffice-commits
mailing list