Line 143: Line 143:
 
##### FlexForm (formerly: WSForm)
 
##### FlexForm (formerly: WSForm)
 
wfLoadExtension( 'FlexForm' );
 
wfLoadExtension( 'FlexForm' );
$wgFlexFormConfig['secure'] = true;
 
 
$wgFlexFormConfig['sec_key'] = getenv( 'GITLAB_ENVIRONMENT_URL' ) . "salt";
 
$wgFlexFormConfig['sec_key'] = getenv( 'GITLAB_ENVIRONMENT_URL' ) . "salt";
$wgFlexFormConfig['auto_save_interval'] = 30000;
 
$wgFlexFormConfig['auto_save_after_change'] = 3000;
 
 
$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on';
 
$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on';
 
$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';
 
$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';
 
$wgFlexFormConfig['FlexFormDefaultTheme'] = "plain";
 
$wgFlexFormConfig['FlexFormDefaultTheme'] = "plain";
$wgFlexFormConfig['rc_site_key'] = "";
 
$wgFlexFormConfig['rc_secret_key'] = "";
 
$wgFlexFormConfig['file_temp_path'] = "";
 
 
$wgFlexFormConfig['CreateAndEditForms']['allowedGroups'] = ["sysop","moderator"];
 
$wgFlexFormConfig['CreateAndEditForms']['allowedGroups'] = ["sysop","moderator"];
$wgFlexFormConfig['CreateAndEditForms']['hideEdit'] = true;
 
$wgFlexFormConfig['can_create_user'] = false;
 
$wgFlexFormConfig['create-seo-titles'] = true;
 
 
$wgFlexFormConfig['form_timeout_limit'] = 7200;
 
$wgFlexFormConfig['form_timeout_limit'] = 7200;
  

Revision as of 13:52, 1 September 2022

At this moment there is one way to install Open CSP yourself.

Install MediaWiki

The first step is to install MediaWiki. If you have done this, go to the next step.

Install Elasticsearch

In Open CSP Elasticsearch is used as Elasticstore for Semantic MediaWiki. Having the data in Elasticsearch is a prerequisite for the use of WikiSearch.

How to install Elasticsearch is described here: https://www.mediawiki.org/wiki/Extension:CirrusSearch#Elasticsearch.

Download the Open CSP extensions

Go to Extensions in Open CSP and download all the extensions that are not included with MediaWiki.

Configuration of settings

Our approach is to have LocalSettings.php as it is and put settings in different files. This promotes clarity and upgradability.

Change LocalSettings.php

Add this to the end of LocalSettings.php and create a 'settings' folder in the public_html with these files.

require_once( 'settings/ServerSettings.php' );
require_once( 'settings/AdditionalSettings.php' );
require_once( 'settings/ExtensionSettings.php' );
require_once( 'settings/SkinSettings.php' );

Configure server settings

<?php
// Project namespace (choose your project namespace)
// $wgMetaNamespace = "Wiki";

// Short URL (optional)
// $wgArticlePath = "/$1";
// $wgUsePathInfo = true;

// Elasticsearch (configure according your ES installation)
$GLOBALS['smwgElasticsearchEndpoints'] = [ 'elasticsearch-master.helm.svc.cluster.local:9200', ];
$GLOBALS['smwgElasticsearchConfig']['settings']['data'] = [ 'number_of_shards' => 2,
	'number_of_replicas' => 0 ];

// Disable jobqueue on webrequest (optional, if set to 0 create cronjob to run runJobs.php)
// $wgJobRunRate = 0;

Configure additional settings

<?php
// Uncomment to see Exception Details
//	$wgShowExceptionDetails = true;

// Please fill in your page name here:
$wgSitename = "CSP Wiki";

// Allow uploads
$wgEnableUploads = true;
// Under evaluation: Might no longer be required for FlexForm
$wgAllowCopyUploads = true;
$wgCopyUploadsFromSpecialUpload = true;

// Use img_auth.php for all files served. (optional)
// $wgUploadPath = "/img_auth.php";

// Switch off cache (optional)
// $wgCachePages = false;
// $wgMainCacheType = CACHE_NONE;
// $wgCacheDirectory = false;
// $wgParserCacheType = CACHE_NONE;

// Enable ElasticSearch as the standard backend
$smwgDefaultStore = 'SMWElasticStore';

// Explicitly set wgRawHtml to false, since it is unsafe.
$wgRawHtml = false;

// Below are settings for a private wiki that all users can edit
// No need to patrol pages
$wgUseRCPatrol = false;
$wgUseNPPatrol = false;

// Private wiki
$wgGroupPermissions['*']['read'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createaccount'] = false;

// Give read and write rights to all registered users.
$wgGroupPermissions['user']['read'] = true;
$wgGroupPermissions['user']['edit'] = true;
// Give a faux permission to 'moderator' so it will show up as a role.
$wgGroupPermissions['moderator']['read'] = true;

// Allow moderators edit access to the Wiki namespace.
$wgNamespaceProtection[NS_PROJECT] = [ 'edit project' ];
$wgGroupPermissions['sysop']['edit project'] = true;
$wgGroupPermissions['moderator']['edit project'] = true;

Configure extension settings

<?php
##### Admin Links
wfLoadExtension( 'AdminLinks' );

##### CodeMirror (optional
// Required for source editing with CodeMirror.
// wfLoadExtension( 'WikiEditor' );
// wfLoadExtension( 'CodeMirror' );
// $wgDefaultUserOptions['usecodemirror'] = 1;

##### CSPResources
wfLoadExtension( 'CSPResources' );
$wgCSPShowSmwIndicator = false;

##### DataTransfer
wfLoadExtension( 'DataTransfer' );

##### DeleteBatch
wfLoadExtension( 'DeleteBatch' );

##### DisplayTitle
wfLoadExtension( 'DisplayTitle' );
// defaults to true
$wgAllowDisplayTitle = true;
// defaults to true
$wgRestrictDisplayTitle = false;

##### Echo
wfLoadExtension( 'Echo' );
$wgEchoWatchlistNotifications = true;

$wgExtensionFunctions[] = static function () {
	global $wgEchoNotifications;
	unset( $wgEchoNotifications["thank-you-edit"] );

	global $wgEchoNotificationCategories;
	unset( $wgEchoNotificationCategories["edit-user-talk"] );
	unset( $wgEchoNotificationCategories["mention"] );
	unset( $wgEchoNotificationCategories["emailuser"] );
	unset( $wgEchoNotificationCategories["thank-you-edit"] );
};

##### FlexForm (formerly: WSForm)
wfLoadExtension( 'FlexForm' );
$wgFlexFormConfig['sec_key'] = getenv( 'GITLAB_ENVIRONMENT_URL' ) . "salt";
$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on';
$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';
$wgFlexFormConfig['FlexFormDefaultTheme'] = "plain";
$wgFlexFormConfig['CreateAndEditForms']['allowedGroups'] = ["sysop","moderator"];
$wgFlexFormConfig['form_timeout_limit'] = 7200;

##### Lockdown
wfLoadExtension( 'Lockdown' );

##### MultimediaViewer
wfLoadExtension( 'MultimediaViewer' );
$wgMediaViewerIsInBeta = true;

##### MyVariables
wfLoadExtension( 'MyVariables' );

##### NumberFormat
require_once "$IP/extensions/NumberFormat/NumberFormat.php";

##### ParserFunctions
wfLoadExtension( 'ParserFunctions' );
$wgPFEnableStringFunctions = true;
$wgPFStringLengthLimit = 80000;

##### Realnames
wfLoadExtension( 'Realnames' );
$wgRealnamesLinkStyle = "replace";

##### RegexFun
require_once $IP . '/extensions/RegexFun/RegexFun.php';

##### ReplaceText
wfLoadExtension( 'ReplaceText' );

##### SSO Stack
###		PluggableAuth
###		WSAzureAuth
###		WSOAuth
$wgGroupPermissions['*']['autocreateaccount'] = true;
wfLoadExtension( 'PluggableAuth' );
wfLoadExtension( 'WSAzureAuth' );
wfLoadExtension( 'WSOAuth' );
$wgPluggableAuth_EnableLocalLogin = true;
$wgPluggableAuth_Config['WikibaseSolutionsAAD'] = [
	'plugin' => 'WSOAuth',
	'data' => [
		'type' => 'azure',
		'clientId' => getenv( 'AAD_CLIENT_ID' ),
		'clientSecret' => getenv( 'AAD_CLIENT_SECRET' ),
		'redirectUri' => str_replace( "http",
				"https",
				getenv( 'GITLAB_ENVIRONMENT_URL' ) ) . '/Special:PluggableAuthLogin'
	],
	'buttonLabelMessage' => 'wikibase-solutions-oauth-button-label'
];
$wgOAuthAzureTenant = getenv( 'AAD_TENANT_ID' );
$wgOAuthAutoPopulateGroups = [ 'sysop',
	'interface-admin' ];

##### SemanticMediaWiki
enableSemantics( 'wikibase.nl' );
$smwgConfigFileDir = $IP . '/cache';
# Default disabled (CSP Basis#13)
$smwgCheckForConstraintErrors = SMW_CONSTRAINT_ERR_CHECK_NONE;
const NS_WIDGET = 274;
const NS_WIDGET_TALK = 275;
$smwgNamespacesWithSemanticLinks[NS_TEMPLATE] = true;
$smwgNamespacesWithSemanticLinks[SMW_NS_PROPERTY] = true;
$smwgNamespacesWithSemanticLinks[SMW_NS_CONCEPT] = true;
$smwgNamespacesWithSemanticLinks[NS_WIDGET] = true;
$smwgNamespacesWithSemanticLinks[SMW_NS_PROPERTY_TALK] = false;
$smwgNamespacesWithSemanticLinks[SMW_NS_CONCEPT_TALK] = false;
$smwgNamespacesWithSemanticLinks[NS_WIDGET_TALK] = false;
$smwgPageSpecialProperties = [ '_MDAT',
	'_CDAT' ];

##### SemanticExtraSpecialProperties
wfLoadExtension( 'SemanticExtraSpecialProperties' );
$sespgEnabledPropertyList = [ '_EUSER',
	'_CUSER',
	'_PAGEID', ];

##### SemanticResultFormats
wfLoadExtension( 'SemanticResultFormats' );

##### SyntaxHighlight_GeSHi
wfLoadExtension( 'SyntaxHighlight_GeSHi' );

##### TemplateData
wfLoadExtension( 'TemplateData' );

##### UrlGetParameters
require_once $IP . '/extensions/UrlGetParameters/UrlGetParameters.php';

##### UserFunctions
require_once "$IP/extensions/UserFunctions/UserFunctions.php";
$wgUFAllowedNamespaces = array_fill( 0,
	4000,
	true );
$wgUFAllowedNamespaces += array_fill( 50000,
	5000,
	true );

##### UserMerge
wfLoadExtension( 'UserMerge' );
$wgGroupPermissions['bureaucrat']['usermerge'] = true;

##### Variables
wfLoadExtension( 'Variables' );

##### VisualEditor
wfLoadExtension( 'VisualEditor' );
$wgTmpDirectory = $IP . '/images/temp/';
$wgExtraSignatureNamespaces = [ NS_MAIN ];
$wgVisualEditorEnableWikitext = true;
$wgVisualEditorEnableDiffPage = true;
for ( $i = 50000; $i < 55000; $i += 2 ) {
	$wgContentNamespaces[] = $i;
}
$wgVisualEditorNamespaces = array_merge( $wgContentNamespaces,
	[ NS_USER ] );

##### Widgets
wfLoadExtension( 'Widgets' );

##### WSArrays
wfLoadExtension( 'WSArrays' );
$wfEnableResultPrinter = true;

##### WSImageVersion
wfLoadExtension( 'WSImageVersion' );
$wgWSImageVersionVersionDescriptions = [ [ "product" => "CSP",
	"file" => $IP . "/.version" ], ];

##### WSPageSync
wfLoadExtension( 'WSPageSync' );
$wgWSPageSync['filePath'] = $IP . '/wsps';

##### WikiSearch (and WikiSearchFront)
wfLoadExtension( 'WikiSearch' );
wfLoadExtension( 'WikiSearchFront' );

##### WSSemanticParsedText
wfLoadExtension( 'WSSemanticParsedText' );
$smwgElasticsearchConfig["indexer"]["raw.text"] = true;

##### WSSlots
# Note: We still define and append the 'ws-page-props' slot, because it is used on some wikis.
wfLoadExtension( 'WSSlots' );
$wgWSSlotsDefaultSlotRoleLayout = [ "display" => "none",
	"region" => "center",
	"placement" => "append", ];
$wgWSSlotsDefaultContentModel = "wikitext";
$wgWSSlotsDefinedSlots = [ "ws-base-props", "ws-class-props" ];
$wgWSSlotsSemanticSlots = [ "ws-base-props", "ws-class-props" ];
$wgWSSlotsDoPurge = true;

##### WSSpaces
wfLoadExtension( 'WSSpaces' );
for ( $i = 50000; $i < 55000; $i++ ) {
	$smwgNamespacesWithSemanticLinks[$i] = true;
}

##### WSTools
wfLoadExtension( 'WSTools' );

Configure skin settings

<?php
wfLoadExtension( 'Bootstrap' );
wfLoadSkin( 'chameleon' );
$wgDefaultSkin = "chameleon";

// Define the location of the css and the layout xml
$egChameleonLayoutFile = "$IP/skin/wikibaseLayout.xml";
$egChameleonExternalStyleModules = glob( $IP . '/skin/scss/[^_]*.scss' );
$wgAllowSiteCSSOnRestrictedPages = true;

// Replace "Powered by SMW" by "Powered by Wikibase"
$wgFooterIcons = [ "copyright" => [ "copyright" => [], ],
	"poweredby" => [ "wikibase" => [ "src" => "/skin/PoweredByWikibase.png",
		"url" => "https://www.wikibase-solutions.com/",
		"alt" => "Powered by Wikibase", ], ], ];
$wgRightsIcon = null;

// Logo and favicon
$wgFavicon = "/skin/favicon.png";

// Common message files
$wgMessagesDirs['WikibaseSolutions'] = __DIR__ . '/../skin/i18n';

// Style settings
// If you want to use container-max-widths, take this step or it won't respond:
// -> Go to skin/wikibaseLayout.xml and from <grid>, remove: 'class="flex-fill" mode="fluid"'
// Add this to the following array: 'container-max-widths'	=> '(sm: 100%, md: 100%, lg: 70vw, xl:
// 70vw)'
$egChameleonExternalStyleVariables = [ 'primary' => '#0576a8' ];