Re-work welcome configuration.

Change-Id: Ia99eb5b587a849d32d7d4f392c15f84db2423e95
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
pull/4455/head
Michael Meeks 2022-03-21 16:20:35 +00:00 committed by Andras Timar
parent 32b85273d7
commit 16386b9aaf
5 changed files with 33 additions and 21 deletions

View File

@ -292,7 +292,7 @@ AC_ARG_WITH([feedback-location],
AC_ARG_ENABLE(welcome-message,
AS_HELP_STRING([--enable-welcome-message],
[Enables welcome message on version update. Can be changed later in coolwsd.xml.])
[Ensures welcome message is enabled on version update.])
)
AC_ARG_ENABLE(feedback,
@ -783,15 +783,12 @@ AS_IF([test "$MAX_DOCUMENTS" -lt "2"],
AC_DEFINE_UNQUOTED([MAX_DOCUMENTS],[$MAX_DOCUMENTS],[Limit the maximum number of open documents])
AC_SUBST(MAX_DOCUMENTS)
ENABLE_WELCOME_MESSAGE=false
AS_IF([test "$enable_welcome_message" = "yes"],
[ENABLE_WELCOME_MESSAGE="true"])
AC_DEFINE_UNQUOTED([ENABLE_WELCOME_MESSAGE],["$ENABLE_WELCOME_MESSAGE"],[Should the Release notes message on startup be enabled by default?])
AC_SUBST(ENABLE_WELCOME_MESSAGE)
ENABLE_FEEDBACK=
FEEDBACK_LOCATION=
WELCOME_CONFIG_FRAGMENT=/dev/null
ENABLE_WELCOME_MESSAGE=0
if test "$enable_feedback" = "yes"; then
ENABLE_FEEDBACK="true"
@ -800,6 +797,12 @@ if test "$enable_feedback" = "yes"; then
else
FEEDBACK_LOCATION="http://127.0.0.1:8000/Rate/feedback.html"
fi
if test "$enable_welcome_message" = "yes"; then # allow configuration
ENABLE_WELCOME_MESSAGE=1
else
WELCOME_CONFIG_FRAGMENT=$srcdir/coolwsd-welcome.xml
fi
fi
AC_DEFINE_UNQUOTED([ENABLE_FEEDBACK],["$ENABLE_FEEDBACK"],[User feedback rating])
@ -807,11 +810,9 @@ AC_DEFINE_UNQUOTED([FEEDBACK_LOCATION],["$FEEDBACK_LOCATION"],[User feedback URL
AC_SUBST(ENABLE_FEEDBACK)
AM_CONDITIONAL([ENABLE_FEEDBACK], [test "$ENABLE_FEEDBACK" = "true"])
ENABLE_WELCOME_MESSAGE_BUTTON=false
AS_IF([test "$enable_welcome_message_button" = "yes"],
[ENABLE_WELCOME_MESSAGE_BUTTON="true"])
AC_DEFINE_UNQUOTED([ENABLE_WELCOME_MESSAGE_BUTTON],["$ENABLE_WELCOME_MESSAGE_BUTTON"],[Should the Release notes message on startup should have a dismiss button instead of an x button to close by default?])
AC_SUBST(ENABLE_WELCOME_MESSAGE_BUTTON)
AC_SUBST_FILE([WELCOME_CONFIG_FRAGMENT])
AC_DEFINE_UNQUOTED([ENABLE_WELCOME_MESSAGE],$ENABLE_WELCOME_MESSAGE,[Should the Release notes message be shown on upgrade])
AC_SUBST(ENABLE_WELCOME)
VEREIGN_URL=
if test "$enable_vereign" = "yes"; then

View File

@ -0,0 +1,5 @@
<welcome>
<enable type="bool" desc="Controls whether the welcome screen should be shown to the users on new install and updates." default="false">false</enable>
<enable_button type="bool" desc="Controls whether the welcome screen should have an explanatory button instead of an X button to close the dialog." default="true">true</enable_button>
<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="browser/welcome"></path>
</welcome>

View File

@ -180,11 +180,7 @@
<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="@ENABLE_WELCOME_MESSAGE@">@ENABLE_WELCOME_MESSAGE@</enable>
<enable_button type="bool" desc="Controls whether the welcome screen should have an explanatory button instead of an X button to close the dialog." default="@ENABLE_WELCOME_MESSAGE_BUTTON@">@ENABLE_WELCOME_MESSAGE_BUTTON@</enable_button>
<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="browser/welcome"></path>
</welcome>
@WELCOME_CONFIG_FRAGMENT@
<user_interface>
<mode type="string" desc="Controls the user interface style. The 'default' means: Take the value from ui_defaults, or decide for one of classic or notebookbar (default|classic|notebookbar)" default="default">default</mode>

View File

@ -1484,8 +1484,8 @@ void COOLWSD::innerInitialize(Application& self)
{ "trace.path[@compress]", "true" },
{ "trace.path[@snapshot]", "false" },
{ "trace[@enable]", "false" },
{ "welcome.enable", ENABLE_WELCOME_MESSAGE },
{ "welcome.enable_button", ENABLE_WELCOME_MESSAGE_BUTTON },
{ "welcome.enable", "false" },
{ "welcome.enable_button", "true" },
{ "welcome.path", "browser/welcome" },
#ifdef ENABLE_FEATURE_LOCK
{ "feature_lock.locked_hosts[@allow]", "false"},
@ -1860,6 +1860,11 @@ void COOLWSD::innerInitialize(Application& self)
Quarantine::createQuarantineMap();
}
#if ENABLE_WELCOME_MESSAGE
conf.setString("welcome.enable", "true");
conf.setString("welcome.enable_Button", "false");
conf.setString("welcome.path", "browser/welcome");
#endif
WelcomeFilesRoot = getPathFromConfig("welcome.path");
if (!getConfigValue<bool>(conf, "welcome.enable", true))
WelcomeFilesRoot = "";

View File

@ -1036,10 +1036,15 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request,
const unsigned int idleTimeoutSecs = config.getUInt("per_view.idle_timeout_secs", 900);
Poco::replaceInPlace(preprocess, std::string("%IDLE_TIMEOUT_SECS%"), std::to_string(idleTimeoutSecs));
#if ENABLE_WELCOME_MESSAGE
std::string enableWelcomeMessage = "true";
std::string enableWelcomeMessageButton = "false";
#else // configurable
std::string enableWelcomeMessage = stringifyBoolFromConfig(config, "welcome.enable", false);
Poco::replaceInPlace(preprocess, std::string("%ENABLE_WELCOME_MSG%"), enableWelcomeMessage);
std::string enableWelcomeMessageButton = stringifyBoolFromConfig(config, "welcome.enable_button", false);
#endif
Poco::replaceInPlace(preprocess, std::string("%ENABLE_WELCOME_MSG%"), enableWelcomeMessage);
Poco::replaceInPlace(preprocess, std::string("%ENABLE_WELCOME_MSG_BTN%"), enableWelcomeMessageButton);
// the config value of 'notebookbar' or 'classic' overrides the UIMode