mediawiki: Use drop-in config component for /etc files

- Don't ship /etc/mediawiki/FreedomBoxSettings.php anymore. Create the file on
first setup. Keep old file on update.

- Simplify and unify how the configuration settings are read and written.

Tests:

- Run unit and functional tests.

- All the drop-in config files in /etc/ are symlinks.

- Shipped configuration is effective.

- Upgrade from older version keeps old configuration.

- Config files are all symlinks in /etc/

- When upgrading from older version FreedomBoxSettings.php does not change.
  FreedomBoxStaticSettings.php becomes a symlink.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2023-06-05 20:29:16 -04:00
1 parent c326b35238
commit cd512bd24c
8 files changed
+106 -174

No files matched your search

@@ -0,0 +1,21 @@
<Directory /var/lib/mediawiki/>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/index.php/(.*)$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
</Directory>
<Directory /var/lib/mediawiki/images>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
<Directory /var/lib/mediawiki/uploads>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
@@ -0,0 +1,66 @@
<?php
/*
This file is shipped by FreedomBox to manage static settings. Newer versions of
this file are shipped by FreedomBox and are expected to override this file
without any user prompts. It should not be modified by the system
administrator. Additional setting modified by FreedomBox are placed in
FreedomBoxSettings.php.
*/
# Default logo
$wgLogos = [ '1x' => "$wgResourceBasePath/resources/assets/mediawiki.png" ];
# Enable file uploads
$wgEnableUploads = true;
# Public registrations
$wgGroupPermissions['*']['createaccount'] = false;
# Read/write permissions for anonymous users
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = true;
# Short urls
$wgArticlePath = "/mediawiki/$1";
$wgUsePathInfo = true;
# Instant Commons
$wgUseInstantCommons = true;
# SVG Enablement
$wgFileExtensions[] = 'svg';
$wgAllowTitlesInSVG = true;
$wgSVGConverter = 'ImageMagick';
# Fix issue with session cache preventing logins, #1736
$wgSessionCacheType = CACHE_DB;
# Use the mobile-friendly skin Timeless by default
$wgDefaultSkin = "timeless";
# Domain Name
$wgServer = "https://freedombox.local";
# Site Name
$wgSitename = "Wiki";
# Default language
$wgLanguageCode = "en";
# Enable default extensions
wfLoadExtension( 'Cite' );
wfLoadExtension( 'Interwiki' );
wfLoadExtension( 'MultimediaViewer' );
wfLoadExtension( 'Renameuser' );
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'WikiEditor' );
# Add a "Powered by FreedomBox" footer icon
$wgExtensionFunctions[] = function () {
global $wgFooterIcons, $wgResourceBasePath;
$wgFooterIcons['poweredby']['freedombox'] = [
'src' => "$wgResourceBasePath/resources/assets/freedombox/poweredby_freedombox.svg",
'url' => 'https://freedombox.org/',
'alt' => 'Powered by FreedomBox',
];
};