chore: update to mediawiki 1.37

- Bump dependencies
- Remove deprecated dependencies
- Use Semantic Media Wiki 4
- Add helper scripts for local testing
- Add S3 capabilities
- Add RemoteUser capabilities

This makes it almost possible to use this image stateless.
SMW adds a config file on installation, this is tracked in Issue 

Co-authored-by: Paul <paul@zom.bi>
Reviewed-on: 
This commit is contained in:
paul 2022-03-19 12:49:52 +01:00
parent 53348c6c8e
commit 5cfd3c1641
4 changed files with 160 additions and 59 deletions

View file

@ -14,6 +14,8 @@ $wgSitename = getenv("WG_SITENAME");
$wgMetaNamespace = "Meta";
$wgScriptPath = getenv("WG_SCRIPT_PATH");
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
$wgServer = getenv("WG_SERVER");
@ -23,19 +25,17 @@ $wgUploadPath = getenv("WG_UPLOAD_PATH");
$wgArticlePath = "/wiki/$1";
$wgUploadDirectory = "/var/www/localstore/images";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
## UPO means: this is also a user preference option
$wgEnableEmail = getenv("WG_ENABLE_EMAIL");
$wgEnableEmail = !!getenv("WG_ENABLE_EMAIL");
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = getenv("WG_EMERGENCY_CONTACT");
$wgPasswordSender = getenv("WG_PASSWORD_SENDER");
$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEnotifUserTalk = !!getenv("WG_ENABLE_EMAIL"); # UPO
$wgEnotifWatchlist = !!getenv("WG_ENABLE_EMAIL"); # UPO
$wgEmailAuthentication = true;
## Database settings
@ -62,11 +62,11 @@ if(php_sapi_name() == "cli") {
}
$wgMemCachedServers = [];
$wgEnableUploads = getenv("WG_ENABLE_UPLOADS");
$wgEnableUploads = !!getenv("WG_ENABLE_UPLOADS");
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgUseInstantCommons = false;
$wgUseInstantCommons = !!getenv("WG_USE_INSTANT_COMMONS");
# telemetry
$wgPingback = false;
@ -76,6 +76,12 @@ $wgPingback = false;
## available UTF-8 locale
$wgShellLocale = "C.UTF-8";
# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = "en";
# Time zone
$wgLocaltimezone = "UTC";
## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
@ -91,7 +97,7 @@ $wgAuthenticationTokenVersion = "1";
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "15ae97f94f551121";
$wgUpgradeKey = "f6490612e52548f9";
## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
@ -105,17 +111,38 @@ $wgRightsIcon = "";
$wgDiff3 = "/usr/bin/diff3";
$wgGroupPermissions['*']['createaccount'] = !!getenv("ALLOW_PUBLIC_REGISTRATION");
$wgGroupPermissions['*']['autocreateaccount'] = !!getenv("ALLOW_AUTO_REGISTRATION");
$wgGroupPermissions['*']['edit'] = !!getenv("ALLOW_PUBLIC_EDIT");
$wgGroupPermissions['*']['read'] = !!getenv("ALLOW_PUBLIC_READ");
if (!!getenv("USE_REMOTE_AUTH")) {
# Use remote authentication.
# When using the VisualEditor extension create a specific parsoid user for
# locked down wikis (no anonymous read permission), when Parsoid is running
# on localhost.
$wgAuthRemoteuserUserName = [
$_SERVER[ 'REMOTE_USER' ],
$_SERVER[ 'REDIRECT_REMOTE_USER' ],
$_SERVER[ 'REMOTE_ADDR' ] == '127.0.0.1' ? 'parsoid' : ''
];
$wgAuthRemoteuserUserPrefs = [
'realname' => $_SERVER[ 'AUTHENTICATE_DISPLAYNAME' ],
'language' => 'en',
'disablemail' => 0
];
// Users email address should not be changed inside MediaWiki.
$wgAuthRemoteuserUserPrefsForced = [
'email' => $_SERVER[ 'AUTHENTICATE_MAIL' ]
];
}
## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";
# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
#wfLoadSkin( 'MonoBook' );
#wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );
# Enabled extensions. Most of the extensions are enabled by adding
@ -124,35 +151,88 @@ wfLoadSkin( 'Vector' );
# The following extensions were automatically enabled:
wfLoadExtension( 'CategoryTree' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'CiteThisPage' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'Graph' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'InputBox' );
#wfLoadExtension( 'OATHAuth' );
wfLoadExtension( 'Interwiki' );
wfLoadExtension( 'JsonConfig' ); # Configuration via Special Wiki Pages containing JSON
wfLoadExtension( 'LocalisationUpdate' );
wfLoadExtension( 'Maps' ); # OSM Maps
wfLoadExtension( 'Mermaid' ); # Diagrams and flowcharts
wfLoadExtension( 'MsUpload' ); # Better upload formulars
wfLoadExtension( 'MultimediaViewer' );
wfLoadExtension( 'Nuke' ); # Mass delete pages
wfLoadExtension( 'PageImages' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'Poem' ); # Formatting of poems
wfLoadExtension( 'Renameuser' );
wfLoadExtension( 'ReplaceText' );
wfLoadExtension( 'Scribunto' ); # Lua Scripting
wfLoadExtension( 'SecureLinkFixer' );
wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'SubPageList3' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'TemplateData' ); # Template schema information
wfLoadExtension( 'TemplateStyles' ); # Embedd Styles from Wiki Pages containing CSS
wfLoadExtension( 'TextExtracts' );
wfLoadExtension( 'TitleBlacklist' );
require_once "$IP/extensions/Validator/Validator.php";
wfLoadExtension( 'VisualEditor' ); # WYSIWYG editor
wfLoadExtension( 'WikiEditor' );
# End of automatically generated settings.
# Add more configuration options below.
# Load our extensions
wfLoadExtension( 'JsonConfig' ); # Configuration via Special Wiki Pages containing JSON
wfLoadExtension( 'TemplateStyles' ); # Embedd Styles from Wiki Pages containing CSS
wfLoadExtension( 'Scribunto' ); # Lua scripting
wfLoadExtension( 'SemanticScribunto' ); # Lua scripting using semantic information
#wfLoadExtension( 'Mermaid' ); # Diagrams and flowcharts, AUTOMATICALLY ENABLED as part of semanticBundle!
wfLoadExtension( 'VisualEditor' ); # WYSIWYG editor, already installed in 1.35+
wfLoadExtension( 'TemplateData' ); # Template schema information, already installed in 1.35+
# scribunto configuration
$wgScribuntoDefaultEngine = 'luastandalone';
require_once '/var/www/html/extensions/SemanticBundle/SemanticBundle.php';
# Load SMW Extensions
wfLoadExtension( 'PageForms' ); # SMW Dependency
wfLoadExtension( 'SemanticCompoundQueries' ); # Allow combined queries in SMW
wfLoadExtension( 'SemanticExtraSpecialProperties' );
wfLoadExtension( 'SemanticResultFormats' );
wfLoadExtension( 'SemanticScribunto' ); # Lua scripting using semantic information
# Turn on SemanticMediaWiki
$smwgUpgradeKey = 'smw:2020-04-18';
wfLoadExtension( 'SemanticMediaWiki' );
enableSemantics( getenv("SEMANTIC_URL") );
# Configure S3 Storage
if (getenv("S3_SECRET")) {
wfLoadExtension( 'AWS' );
$wgAWSCredentials = [
'key' => getenv("S3_KEY"),
'secret' => getenv("S3_SECRET"),
'token' => false
];
$wgAWSRegion = getenv("S3_REGION");
$wgAWSBucketName = getenv("S3_BUCKET_NAME");
# If you are using minio, you need to set a public policy like this:
# mc policy set public instance/bucket/
# mc admin config set instance/bucket/ api cors_allow_origin=https://wiki.example.com
$wgAWSBucketTopSubdirectory = getenv("S3_SUBDIRECTORY");
$wgAWSRepoHashLevels = '2'; # Default 0; But 2 means that S3 objects
# will be named a/ab/Filename.png (same
# as when MediaWiki stores files in local
# directories)
# ---
$wgAWSRepoDeletedHashLevels = '3'; # Default 0; But 3 for naming
# a/ab/abc/Filename.png (same as
# when MediaWiki stores deleted
# files in local directories)
//The url used for the API (PutObject, etc.)
$wgFileBackends['s3']['endpoint'] = getenv("S3_ENDPOINT");
//The url used for showing images. $1 is translated to the bucket name.
$wgAWSBucketDomain = getenv("S3_BUCKET_DOMAIN_NAME");
}
# Set Subpages on
$wgNamespacesWithSubpages[NS_MAIN] = 1;
@ -170,12 +250,12 @@ ini_set('memory_limit', '-1');
# Move the SMW config directory
$smwgConfigFileDir = '/var/www/localstore/smwconfig';
# Logo, 135x135px
$wgLogo = "/wiki/Special:Redirect/file/Logo.png";
# Logos
$wgLogos = [ '1x' => "/wiki/Special:Redirect/file/Logo.png" ];
# Footer icons
if (getenv("DISABLE_ICONS")) {
$wgFooterIcons['poweredby']['semanticmediawiki'] = false;
unset( $wgFooterIcons['poweredby'] );
}