mediawiki: Add action to set domain name

- Set domain name during app setup

- Improve tests for settings. Prefer to call functions in plinth which invoke
actions than test actions directly.

- Also, '$wgServer' is not a domain name since it also includes the protocol.

- Add domain selection form. Make server url a text input field.

- Added a functional test to set the value of server url to the value provided
by FREEDOMBOX_URL before doing running any other tests.

- Make server url setting a pre-requisite.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Squash commits as they were fixing themselves]
[sunil: Simplify configuration reading]
[sunil: Use 'server_url' terminology consistently]
[sunil: cosmetic: Minor styling]
[sunil: Update test_settings.py to use fixture pattern]
[sunil: Remove seemingly incorrectly used aria-describedby attribute]
[sunil: Don't rely solely on env variable value in functional tests]
[sunil: Fix issue with http/https mismatch when checking site availability]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati authored and Sunil Mohan Adapa committed 2020-10-31 22:04:10 -07:00
1 parent 04617cbf7f
commit 658e260d23
10 files changed
+227 -35

No files matched your search

+21 -8
View File
@@ -48,6 +48,10 @@ def parse_arguments():
help='Set the default skin')
default_skin.add_argument('skin', help='name of the skin')
server_url = subparsers.add_parser(
'set-server-url', help='Set the value of $wgServer for this server')
server_url.add_argument('server_url', help='value of $wgServer')
subparsers.required = True
return parser.parse_args()
@@ -218,28 +222,37 @@ def subcommand_private_mode(arguments):
conf_value + '\n')
def subcommand_set_default_skin(arguments):
"""Set a default skin"""
skin = arguments.skin
skin_setting = f'$wgDefaultSkin = "{skin}";\n'
def _update_setting(setting_name, setting_line):
"""Update the value of one setting in the config file."""
with open(CONF_FILE, 'r') as conf_file:
lines = conf_file.readlines()
inserted = False
for i, line in enumerate(lines):
if line.strip().startswith('$wgDefaultSkin'):
lines[i] = skin_setting
if line.strip().startswith(setting_name):
lines[i] = setting_line
inserted = True
break
if not inserted:
lines.append(skin_setting)
lines.append(setting_line)
with open(CONF_FILE, 'w') as conf_file:
conf_file.writelines(lines)
def subcommand_set_default_skin(arguments):
"""Set a default skin."""
skin = arguments.skin
_update_setting('$wgDefaultSkin ', f'$wgDefaultSkin = "{skin}";\n')
def subcommand_set_server_url(arguments):
"""Set the value of $wgServer for this MediaWiki server."""
# This is a required setting from MediaWiki 1.34
_update_setting('$wgServer', f'$wgServer = "{arguments.server_url}";\n')
def main():
"""Parse arguments and perform all duties."""
arguments = parse_arguments()