-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #59: Refactor roles from inline blocks to files
A lot of the configuration was inline blocks that were dumped directly into LocalSettings.php. This change separates those configurations out into their own files for easier maintenance and documentation. Issue #59: Change MediaWiki configurations to have multiple files
- Loading branch information
Frank Duncan
committed
Oct 29, 2020
1 parent
ebaa71a
commit f60d50a
Showing
16 changed files
with
445 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
wfLoadExtension('ActivityLog'); | ||
$wgMessagesDirs['ActivityLogConfiguration'] = 'ActivityLogConfiguration/i18n'; | ||
$wgActivityLogHooksToWatch["ArticleViewHeader"] = function ($article) { | ||
$referrer = $_SERVER['HTTP_REFERER']; | ||
$ourServer = "http://torque.leverforchange.org"; | ||
|
||
if($referrer && $ourServer == substr($referrer, 0, strlen($ourServer))) { | ||
return array($article->getContext()->getUser(), | ||
$article->getTitle(), | ||
"activitylog-articleviewheader-with-referrer", | ||
$_SERVER['HTTP_REFERER'] | ||
); | ||
} else { | ||
return array($article->getContext()->getUser(), | ||
$article->getTitle(), | ||
"activitylog-articleviewheader" | ||
); | ||
} | ||
}; | ||
|
||
$wgActivityLogHooksToWatch["UserLoginComplete"] = function(&$user, &$inject_html, $direct) { | ||
global $wgTitle; | ||
return array($user, $wgTitle, "activitylog-userlogin"); | ||
}; | ||
|
||
$wgActivityLogHooksToWatch["PageContentSave"] = function($wikiPage, $user, $content, &$summary, $isMinor, $isWatch, $section, $flags, $status) { | ||
return array($user, $wikiPage->getTitle(), "activitylog-articlesavepage"); | ||
}; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
require_once "$IP/extensions/Collection/Collection.php"; | ||
$wgCollectionMWServeURL = "http://127.0.0.1:8899"; | ||
$wgCollectionMaxArticles = 250; | ||
$wgEnableApi = true; | ||
$wgCollectionFormats = array( 'rl' => 'PDF',); | ||
$wgCollectionPortletFormats = []; | ||
$wgCollectionDisableDownloadSection = false; | ||
$wgHooks['ApiBeforeMain'][] = function($main) { | ||
global $wgTorqueDataConnectGroup, $wgTorqueDataConnectRenderToHTML, $wgTorqueDataConnectView; | ||
if($main->getUser() && strtolower($main->getUser()->getName()) == "{{ mediawiki_mwlib_username }}") { | ||
$wgTorqueDataConnectRenderToHTML = false; | ||
$tdcinfo = $main->getRequest()->getText("tdcinfo", false); | ||
list($wgTorqueDataConnectGroup, $wgTorqueDataConnectView) = explode("|", $tdcinfo); | ||
} | ||
}; | ||
$wgHooks['BeforeInitialize'][] = function(&$title, &$article = null, &$output, &$user, $request, $mediaWiki) { | ||
global $wgCollectionMWServeCredentials; | ||
$group = TorqueDataConnectConfig::getValidGroup($user); | ||
$view = TorqueDataConnectConfig::getCurrentView(); | ||
$wgCollectionMWServeCredentials = "{{ mediawiki_mwlib_username }}:${group}|${view}:{{ mediawiki_mwlib_password }}"; | ||
}; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
$wgHooks['SkinTemplateNavigation'][] = function ( $template, &$links ) { | ||
$currentTitle = $template->getTitle()->getFullText(); | ||
$lfc_prepend = "LFC Analysis of "; | ||
$eval_prepend = "Evaluations of "; | ||
|
||
$isAnalysisPage = (strlen($currentTitle) > strlen($lfc_prepend) && substr($currentTitle, 0, strlen($lfc_prepend)) === $lfc_prepend); | ||
$isEvalPage = (strlen($currentTitle) > strlen($eval_prepend) && substr($currentTitle, 0, strlen($eval_prepend)) === $eval_prepend); | ||
|
||
$originalPageTitle = $currentTitle; | ||
if($isAnalysisPage) { | ||
$originalPageTitle = substr($currentTitle, strlen($lfc_prepend)); | ||
$links['namespaces']['main']['class'] = ''; | ||
$links['namespaces']['main']['href'] = Title::newFromText($originalPageTitle)->getLocalUrl(); | ||
} else if($isEvalPage) { | ||
$originalPageTitle = substr($currentTitle, strlen($eval_prepend)); | ||
$links['namespaces']['main']['class'] = ''; | ||
$links['namespaces']['main']['href'] = Title::newFromText($originalPageTitle)->getLocalUrl(); | ||
} | ||
$lfcAnalysisTitle = Title::newFromText($lfc_prepend . $originalPageTitle); | ||
$evalTitle = Title::newFromText($eval_prepend . $originalPageTitle); | ||
if($isAnalysisPage || $lfcAnalysisTitle->exists()) { | ||
$links['namespaces']['main']['text'] = 'Proposal'; | ||
$links['namespaces']['lfcanalysis'] = [ | ||
'class' => ($isAnalysisPage ? 'selected' : ''), | ||
'href' => ($isAnalysisPage ? $template->getTitle()->getLocalUrl() : $lfcAnalysisTitle->getLocalUrl()), | ||
'text' => 'LFC Analysis', | ||
]; | ||
} | ||
if($isEvalPage || $evalTitle->exists()) { | ||
$links['namespaces']['main']['text'] = 'Proposal'; | ||
$links['namespaces']['evaluations'] = [ | ||
'class' => ($isEvalPage ? 'selected' : ''), | ||
'href' => ($isEvalPage ? $template->getTitle()->getLocalUrl() : $evalTitle->getLocalUrl()), | ||
'text' => 'Evaluations', | ||
]; | ||
} | ||
|
||
unset($links['namespaces']['talk']); | ||
}; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
# Make it so names of log types are more amenable to LFC users | ||
$logTitlesOverrideMessages = [ | ||
"picksomelogpage" => "Selection", | ||
"activitylogpage" => "Misc. Activity (page views, login, logout, etc)", | ||
"simplefavoriteslog" => "Favorites", | ||
"log-name-create" => "Page Creation", | ||
"movelogpage" => "Page Rename", | ||
"uploadlogpage" => "File Upload", | ||
"dellogpage" => "Page Deletion", | ||
"newuserlogpage" => "User Creation", | ||
"log-name-teamcomments" => "Comments", | ||
"torquedataconnect-apiaccesslog" => "API Accesses", | ||
"torquedataconnect-datachangeslog" => "Data Changes", | ||
"rightslog" => "Changes to Access Control / Permissions" | ||
]; | ||
|
||
$wgHooks['MessagesPreLoad'][] = function($title, &$message, $code) { | ||
global $logTitlesOverrideMessages; | ||
if(array_key_exists(strtolower($title), $logTitlesOverrideMessages)) { | ||
$message = $logTitlesOverrideMessages[strtolower($title)]; | ||
} | ||
}; | ||
|
||
|
||
# Remove log types that we don't want | ||
$logTypesBlacklist = ["block", "contentmodel", "import", "managetags", "merge", "patrol", "protect", "rights", "tag"]; | ||
|
||
$wgHooks['SetupAfterCache'][] = function () { | ||
global $wgLogTypes, $logTypesBlacklist; | ||
foreach($logTypesBlacklist as $logType) { | ||
unset($wgLogTypes[array_search($logType, $wgLogTypes)]); | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
# Change the log format a little | ||
# | ||
# This is a little brittle, based on how the lines are rendered by the skin currently used | ||
# but should work for the foreseeable future. | ||
$wgHooks['LogEventsListLineEnding'][] = function ($page, &$line, &$entry, &$classes, &$attribs){ | ||
$line = preg_replace('/(\d\d\d\d)/', '\1 —', $line, 1); | ||
}; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
$wgEnableUploads = true; | ||
$wgFileExtensions = array_merge($wgFileExtensions, array('doc', 'docx', 'html', 'pdf', 'xlsx')); | ||
$wgFileBlacklist = array(); | ||
$wgMimeTypeBlacklist = array(); | ||
$wgStrictFileExtensions = false; | ||
$wgTrustedMediaFormats = array('application/zip', 'text/html'); | ||
$wgVerifyMimeType = false; | ||
$wgAllowJavaUploads = true; | ||
$wgCheckFileExtensions = false; | ||
$wgGroupPermissions['bot']['edit'] = true; | ||
$wgGroupPermissions['bot']['upload'] = true; | ||
$wgGroupPermissions['bot']['torquedataconnect-admin'] = true; | ||
$wgGroupPermissions['autoconfirmed']['reupload'] = true; | ||
?> |
Oops, something went wrong.