allow to set collabora dictionaries

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-06-27 15:29:17 +02:00
parent a26d36c084
commit 97f053228c
8 changed files with 74 additions and 0 deletions

View file

@ -59,6 +59,7 @@ done
sed -i 's|_ENABLED=|_ENABLED=no # Setting this to "yes" enables the option in Nextcloud automatically.|' sample.conf
sed -i 's|TALK_ENABLED=no|TALK_ENABLED=yes|' sample.conf
sed -i 's|COLLABORA_ENABLED=no|COLLABORA_ENABLED=yes|' sample.conf
sed -i 's|COLLABORA_DICTIONARIES=|COLLABORA_DICTIONARIES=de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru # You can change this in order to enable other dictionaries for collabora|' sample.conf
sed -i 's|NEXTCLOUD_DATADIR=|NEXTCLOUD_DATADIR=nextcloud_aio_nextcloud_data # You can change this to e.g. "/mnt/ncdata" to map it to a location on your host. It needs to be adjusted before the first startup and never afterwards!|' sample.conf
sed -i 's|NEXTCLOUD_MOUNT=|NEXTCLOUD_MOUNT=/mnt/ # This allows the Nextcloud container to access directories on the host. It must never be equal to the value of NEXTCLOUD_DATADIR!|' sample.conf
sed -i 's|DAILY_BACKUP_RUNNING=|DAILY_BACKUP_RUNNING=no # When setting to yes, it will automatically update all installed Nextcloud apps upon container startup.|' sample.conf

View file

@ -178,6 +178,7 @@
"environmentVariables": [
"aliasgroup1=https://%NC_DOMAIN%:443",
"extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:logging.level=warning",
"dictionaries=%COLLABORA_DICTIONARIES%",
"TZ=%TIMEZONE%"
],
"volumes": [],

View file

@ -99,6 +99,7 @@ $app->get('/containers', function ($request, $response, $args) use ($container)
'timezone' => $configurationManager->GetTimezone(),
'skip_domain_validation' => $configurationManager->shouldDomainValidationBeSkipped(),
'talk_port' => $configurationManager->GetTalkPort(),
'collabora_dictionaries' => $configurationManager->GetCollaboraDictionaries(),
]);
})->setName('profile');
$app->get('/login', function ($request, $response, $args) use ($container) {

View file

@ -87,6 +87,15 @@ class ConfigurationController
}
}
if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) {
$this->configurationManager->DeleteCollaboraDictionaries();
}
if (isset($request->getParsedBody()['collabora_dictionaries'])) {
$collaboraDictionaries = $request->getParsedBody()['collabora_dictionaries'] ?? '';
$this->configurationManager->SetCollaboraDictionaries($collaboraDictionaries);
}
return $response->withStatus(201)->withHeader('Location', '/');
} catch (InvalidSettingConfigurationException $ex) {
$response->getBody()->write($ex->getMessage());

View file

@ -568,4 +568,36 @@ class ConfigurationManager
}
return false;
}
public function GetCollaboraDictionaries() : string {
$config = $this->GetConfig();
if(!isset($config['collabora_dictionaries'])) {
$config['collabora_dictionaries'] = '';
}
return $config['collabora_dictionaries'];
}
/**
* @throws InvalidSettingConfigurationException
*/
public function SetCollaboraDictionaries(string $CollaboraDictionaries) : void {
if ($CollaboraDictionaries === "") {
throw new InvalidSettingConfigurationException("The dictionaries must not be empty!");
}
if (!preg_match("#^[a-zA-Z_ ]+$#", $CollaboraDictionaries)) {
throw new InvalidSettingConfigurationException("The entered dictionaries do not seem to be a valid!");
}
$config = $this->GetConfig();
$config['collabora_dictionaries'] = $CollaboraDictionaries;
$this->WriteConfig($config);
}
public function DeleteCollaboraDictionaries() : void {
$config = $this->GetConfig();
$config['collabora_dictionaries'] = '';
$this->WriteConfig($config);
}
}

View file

@ -292,6 +292,12 @@ class DockerActionManager
} else {
$replacements[1] = $this->configurationManager->GetTimezone();
}
} elseif ($out[1] === 'COLLABORA_DICTIONARIES') {
if ($this->configurationManager->GetCollaboraDictionaries() === '') {
$replacements[1] = 'de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru';
} else {
$replacements[1] = $this->configurationManager->GetCollaboraDictionaries();
}
} else {
$replacements[1] = $this->configurationManager->GetSecret($out[1]);
}

View file

@ -459,6 +459,29 @@
<script type="text/javascript" src="disable-collabora.js"></script>
{% endif %}
{% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %}
<h3>Collabora dictionaries</h3>
{% if collabora_dictionaries == "" %}
In order to get the correct dictionaries in Collabora, you may configure the dictionaries below:<br><br>
<form method="POST" action="/api/configuration" class="xhr">
<input type="text" name="collabora_dictionaries" placeholder="de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru" />
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
<input class="button" type="submit" value="Submit" />
</form>
You need to make sure that the dictionaries that you enter are valid. An example is <b>de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru</b>.<br><br>
{% else %}
The dictionaries for Collabora are currently set to <b>{{ collabora_dictionaries }}</b>. You can reset them again by clicking on the button below.<br><br/>
<form method="POST" action="/api/configuration" class="xhr">
<input type="hidden" name="delete_collabora_dictionaries" value="yes"/>
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
<input class="button" type="submit" value="Reset collabora dictionaries" />
</form>
{% endif %}
{% endif %}
<h2>Timezone change</h2>
{% if isAnyRunning == true %}
{% if timezone != "" %}

View file

@ -8,5 +8,6 @@
- [ ] Collabora by trying to open a .docx or .odt file in Nextcloud
- [ ] Nextcloud Talk by opening the Talk app in Nextcloud, creating a new chat and trying to join a call in this chat. Also verifying in the settings that the HPB and turn server work.
- [ ] Onlyoffice by trying to open a .docx file in Nextcloud
- [ ] When Collabora is enabled, it should show below the Optional Addons section a section where you can change the dictionaries for collabora. `de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru` should be a valid setting. E.g. `de.De` not. If already set, it should show a button that allows to remove the setting again.
You can now continue with [060-environmental-variables.md](./060-environmental-variables.md)