Compare commits

...

12 commits

Author SHA1 Message Date
www-data
145bb43f8f Remove privacy extension
It is USELESS
2025-06-28 22:58:23 +02:00
www-data
6c1dbc8319 Configure secrets and email 2025-06-28 22:20:42 +02:00
www-data
7053bfecbd Add Privacy extension 2025-06-28 21:23:42 +02:00
www-data
23ddb3ba11 Improve read only mode comment 2025-02-20 00:20:13 +01:00
www-data
22cbd05db5 Remove talk pages 2025-02-20 00:19:50 +01:00
www-data
0ee284913e Don't skip vector-2022 skin 2025-02-20 00:19:26 +01:00
www-data
f016a6d3bb Use wgLogos instead of wgLogo 2025-02-20 00:19:00 +01:00
www-data
f98ef04d7b Use server side CSS based space state indicator 2025-02-17 15:24:42 +01:00
www-data
a0b7f10db5 Add spacestate CSS generator 2025-02-17 14:06:38 +01:00
www-data
15fd1195b2 Add own extensions to .gitignore 2025-02-14 17:15:17 +01:00
www-data
5cc55eb5aa Add some updating instructions in README 2025-02-14 17:14:40 +01:00
www-data
afa705be14 Add current LocalSettings and composer.local.json files 2025-02-14 17:04:49 +01:00
5 changed files with 476 additions and 0 deletions

10
.gitignore vendored
View file

@ -91,3 +91,13 @@ Thumbs.db
# Docker
docker-compose.override.yml
.env
# TechInc not public
secrets.php
# TechInc extensions
extensions/AdminLinks
extensions/Headscript
extensions/PageForms
extensions/SemanticMediaWiki
extensions/SemanticResultFormats

273
LocalSettings.php Normal file
View file

@ -0,0 +1,273 @@
<?php
# This is a template for the default config for the Technologia Incognita wiki.
#
# This is for Mediawiki version 1.43 LTS
# Please add correct credentials where needed
#
# Maintained by Piele, Thijs
# Version: 20250211
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Fix that ssl is always on
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
##################### CUSTOMIZE THESE SETTINGS TO YOUR NEED ###################
# Put some secrets outside the git repository
include 'secrets.php';
## Some site defaults
$wgSitename = "Technologia Incognita";
$wgMetaNamespace = "Technologia_Incognita";
$wgServer = "https://wiki.techinc.nl";
#$wgLogo = "https://wiki.techinc.nl/images/c/cd/Techinc_logo.png";
$wgLogos = [
'svg' => "https://wiki.techinc.nl/images/6/6a/TechInc-logo-no-text.svg", // path to svg version
'icon' => "https://wiki.techinc.nl/images/6/6a/TechInc-logo-no-text.svg", // path to svg version
];
$wgLocaltimezone = "Europe/Amsterdam";
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "127.0.0.1";
$wgDBname = "techinc_wiki";
$wgDBuser = "techinc_wiki";
$wgDBpassword = "gFCS8t19xNEvdg52Sx51asGpr4RESbSH";
$wgDBprefix = "";
# Email settings
$wgEmergencyContact = "wiki-noreply@techinc.nl";
$wgPasswordSender = "wiki-noreply@techinc.nl";
$wgSMTP = [
'host' => 'ssl://mail.techinc.nl',
'IDHost' => 'wiki.techinc.nl',
'localhost' => 'wiki.techinc.nl',
'port' => 465,
'auth' => true,
'username' => 'wiki',
'password' => $emailPassword # In secrets.php
];
# tr -c -d '0123456789abcdef' </dev/urandom | dd bs=64 count=1 2>/dev/null;echo
# $wgSecretKey = ""; # In secrets.php
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
# tr -c -d '0123456789abcdef' </dev/urandom | dd bs=64 count=1 2>/dev/null;echo
# $wgUpgradeKey = ""; # In secrets.php
# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";
$wgUsePrivateIPs = true;
$wgUseSquid = true;
$wgSquidServers = array();
$wgSquidServers[] = "127.0.0.1";
#$wgSquidServers = array( '127.0.0.1', '5.79.113.102' );
$wgUseCdn = true;
$wgCdnServers = array();
$wgCdnServers[] = "127.0.0.1";
## PART FOR DEBUGGING, ALSO SET $wgUseSquid = false; when enabling this ##
#$wgShowExceptionDetails = true;
#$wgShowSQLErrors = true;
#$wgDebugComments = true;
#$wgLogQueries = true;
#$wgDebugDumpSql = true;
#$wgDevelopmentWarnings = true;
#$wgDebugProfiling = true;
#$wgDebugTimestamps = true;
#$wgResourceLoaderDebug = true;
#$wgDebugToolbar = true;
$wgFileExtensions = array('png','gif','jpg','jpeg','doc','xls','mpp','ppt','tiff','bmp','docx', 'xlsx','pptx','ps','odt','ods','odp','odg','svg','svgz','tar','gz','bzip','bz2','7z','ogg','mp3','wav','md','css','html','dxf','txt','pdf','dia');
$wgSVGConverter = 'ImagickExt';
$wgSVGNativeRendering = true;
$wgDefaultSkin = "vector";
#$wgSkipSkins = array( "vector-2022" );
wfLoadSkin( 'Vector' );
######################## END OF CUSTOMIZABLE AREA #############################
#
################ THESE VALUES SHOULD NOT HAVE TO BE CHANGED ###################
$wgScriptPath = "";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;
$wgScriptExtension = ".php";
$wgResourceBasePath = $wgScriptPath;
## UPO means: this is also a user preference option
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=utf8";
# Experimental charset support for MySQL 5.0.
$wgDBmysql5 = false;
/////////////////////////////////// CACHING ///////////////////////////////////
$wgMainCacheType = 'redis';
$wgSessionCacheType = 'redis'; // same as WMF prod
// Not widely tested:
$wgMessageCacheType = 'redis';
$wgParserCacheType = 'redis';
$wgLanguageConverterCacheType = 'redis';
/** @see RedisBagOStuff for a full explanation of these options. **/
$wgObjectCaches['redis'] = array(
'class' => 'RedisBagOStuff',
'servers' => array( '127.0.0.1:6379' ),
// 'connectTimeout' => 1,
// 'persistent' => false,
// 'password' => 'secret',
// 'automaticFailOver' => true,
);
$wgJobTypeConf['default'] = [
'class' => 'JobQueueRedis',
'redisServer' => '127.0.0.1:6379',
'redisConfig' => [],
'claimTTL' => 3600,
'daemonized' => true
];
$smwgCacheType = 'redis';
$smwgQueryResultCacheType = 'redis';
//////////////////////////////// END OF CACHING ///////////////////////////////
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgShellLocale = "en_US.utf8";
$wgUseInstantCommons = false;
$wgPingback = false;
$wgCacheDirectory = "$IP/cache";
$wgLanguageCode = "en";
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
$wgDiff3 = "/usr/bin/diff3";
########################## SETTINGS FOR EXTENSIONS ############################
wfLoadExtension( 'AdminLinks' );
#require_once( "$IP/extensions/Arrays/Arrays.php" );
## ConfirmEdit / QuestyCaptcha settings
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'ConfirmEdit/QuestyCaptcha' );
## Start QuestyCaptcha block
$wgCaptchaClass = 'QuestyCaptcha';
/// CHANGE THIS TO SOMETHING REAL
#$wgCaptchaQuestions[] = array( 'question' => 'Which animal is displayed here? <img src="http://wiki.mysite.com/dog.jpg" alt="" title="" />', 'answer' => 'dog' );
$wgCaptchaQuestions[] = array( 'question' => 'Which city is the hackerspace located in?', 'answer' => 'Amsterdam' );
## End QuestyCaptcha block
$wgGroupPermissions['*' ]['skipcaptcha'] = false;
$wgGroupPermissions['user' ]['skipcaptcha'] = false;
$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = false;
$wgGroupPermissions['bot' ]['skipcaptcha'] = true; // registered bots
$wgGroupPermissions['sysop' ]['skipcaptcha'] = true;
$wgCaptchaTriggers['edit'] = false;
$wgCaptchaTriggers['create'] = false;
$wgCaptchaTriggers['addurl'] = false;
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin'] = true;
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'TextExtracts' );
wfLoadExtension( 'WikiEditor' );
wfLoadExtension( 'PageForms' );
wfLoadExtension( 'Headscript' );
wfLoadExtension( 'SemanticMediaWiki' );
wfLoadExtension( 'SemanticResultFormats' );
$wgPFEnableStringFunctions = true;
$wgGroupPermissions['*']['edit'] = false;
$wgEnableDnsBlacklist = false;
#$wgDnsBlacklistUrls = array( 'xbl.spamhaus.org', 'dnsbl.tornevall.org' );
// optional: default is array( 'sysop' )
//$wgUserMergeProtectedGroups = array( 'groupname' );
// Semantic Media Wiki
enableSemantics( 'techinc.nl' );
$smwgPageSpecialProperties = array( '_MDAT', '_CDAT', '_NEWP', '_LEDT');
$smwgCategoryFeatures = ( $smwgCategoryFeatures & ~SMW_CAT_REDIRECT );
$srfgFirstDayOfWeek = 'Monday';
#$smwgShowFactbox = SMW_FACTBOX_NONEMPTY;
$wgPageForms24HourTime = true;
$wgGroupPermissions['*']['viewedittab'] = false;
#$wgPopupsBetaFeature = true;
$wgPopupsOptInDefaultState = '1';
$wgDefaultUserOptions['usebetatoolbar'] = 1;
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
$wgDefaultUserOptions['wikieditor-preview'] = 1;
$wgDefaultUserOptions['wikieditor-publish'] = 1;
$wgMSU_showAutoCat = true; // Files uploaded while editing a category page will be added to that category
$wgMSU_checkAutoCat = true; // Whether the checkbox for adding a category to a page is checked by default
#Disable for everyone.
$wgGroupPermissions['*']['edit'] = false;
# Disable for users, too: by default 'user' is allowed to edit, even if '*' is not.
$wgGroupPermissions['user']['edit'] = false;
# Make it so users with confirmed email addresses are in the group.
$wgAutopromote['emailconfirmed'] = APCOND_EMAILCONFIRMED;
# Hide group from user list.
$wgImplicitGroups[] = 'emailconfirmed';
# Finally, set it to true for the desired group.
$wgGroupPermissions['emailconfirmed']['edit'] = true;
# This is uncommented whenever a backup is running
#$wgReadOnly = 'A backup of the TechInc wiki is currently being made. The site is therefore in read-only mode. Check back in a bit.';
#$wgMessageCacheType = $wgMainCacheType = $wgParserCacheType = $wgSessionCacheType = CACHE_NONE;
#$wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
#$wgIgnoreImageErrors = true;
$wgHeadScriptCode = <<<'START_END_MARKER'
<link href="spacestate.php" rel="stylesheet" />
START_END_MARKER;
// Remove all talk pages
$wgNamespaceProtection[NS_TALK] = ['everyone'];
$wgNamespaceProtection[NS_USER_TALK] = ['everyone'];
$wgNamespaceProtection[NS_PROJECT_TALK] = ['everyone'];
$wgNamespaceProtection[NS_FILE_TALK] = ['everyone'];
$wgNamespaceProtection[NS_MEDIAWIKI_TALK] = ['everyone'];
$wgNamespaceProtection[NS_TEMPLATE_TALK] = ['everyone'];
$wgNamespaceProtection[NS_HELP_TALK] = ['everyone'];
$wgNamespaceProtection[NS_CATEGORY_TALK] = ['everyone'];
$wgMemoryLimit = "64M";

View file

@ -1,3 +1,35 @@
# TechInc fork of MediaWiki
To add the upstream repo
```
git remote add upstream https://gerrit.wikimedia.org/r/mediawiki/core.git
```
Make sure you track the correct upstream branch for the current release (`REL1_43` at the time of writing, an LTS release).
To rebase our changes on top of the upstream codebase
```
git pull upstream --rebase --autostash
```
Make sure you update the submodules with
```
git submodule update --init --recursive
```
If you change any composer files, run
```
composer update
```
To update the MediaWiki database (*IMPORTANT*: do a backup beforehand!)
```
php maintenance/run.php update
```
# MediaWiki
MediaWiki is a free and open-source wiki software package written in PHP. It

59
composer.local.json Normal file
View file

@ -0,0 +1,59 @@
{
"config": {
"allow-plugins": {
"wikimedia/composer-merge-plugin": true
}
},
"require": {
"mediawiki/semantic-media-wiki": "dev-master#649b261378a419a1951e84b7d417b3e5f6cc027a",
"mediawiki/semantic-result-formats": "dev-master#616fd091cdce78d706d13e8b10bf70087615bcd4",
"mediawiki/admin-links": "dev-master#4cec145ad82dbea4e0155bf9abc0ae566547da7b",
"mediawiki/page-forms": "dev-master#d8109745866f0860f66aecd31e009b68e5bedaf1",
"x-mediawiki/confirm-edit": "^1.43",
"x-mediawiki/headscript": "^1.43"
},
"repositories": [
{
"type": "vcs",
"url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/AdminLinks.git"
},
{
"type": "vcs",
"url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/AdminLinks.git"
},
{
"type": "package",
"package": {
"name": "x-mediawiki/confirm-edit",
"type": "mediawiki-extension",
"version": "1.43.0",
"source": {
"type": "git",
"url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit.git",
"reference": "REL1_43"
}
}
},
{
"type": "package",
"package": {
"name": "x-mediawiki/headscript",
"type": "mediawiki-extension",
"version": "1.43.0",
"source": {
"type": "git",
"url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/HeadScript.git",
"reference": "REL1_43"
}
}
}
],
"extra": {
"merge-plugin": {
"include": [
"extensions/Nuke/composer.json",
"skins/*/composer.json"
]
}
}
}

102
spacestate.php Normal file
View file

@ -0,0 +1,102 @@
<?php
header("Cache-Control: max-age=10, must-revalidate");
header("Content-Type: text/css");
enum SpaceState {
case Open;
case Closed;
case Unknown;
}
const CACHE_KEY = "techinc_spacestate";
const CACHE_TTL = 10;
function getSpaceState() {
$in_cache = false;
$spacestate = apcu_fetch(CACHE_KEY, $in_cache);
if ($in_cache) {
return $spacestate;
}
$spacestate = SpaceState::Unknown;
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "https://techinc.nl/space/spacestate.json",
CURLOPT_TIMEOUT => 1,
CURLOPT_FORBID_REUSE => true,
CURLOPT_RETURNTRANSFER => true
));
$request = curl_exec($ch);
// Request failed either because the server is offline, or it took too long to respond.
// In that case, just return the default response of Unknown. Also cache this result
// to make sure we are not hammering the space state endpoint when it failed.
if ($request === false) {
apcu_store(CACHE_KEY, $spacestate, CACHE_TTL);
return $spacestate;
}
// The returned JSON failed to be parsed somehow.
// This should never happen if the spacestate outputs correct JSON.
$json = json_decode($request);
if (is_null($json)) {
apcu_store(CACHE_KEY, $spacestate, CACHE_TTL);
return $spacestate;
}
// Retrieve the state from the 'open' key in the JSON. If it does not exist,
// the space state JSON is incorrect and we don't actually know what the spacestate is.
$state = $json?->state ?? SpaceState::Unknown;
if ($state === SpaceState::Unknown) {
apcu_store(CACHE_KEY, $spacestate, CACHE_TTL);
return $spacestate;
}
$spacestate = $state?->open ?? SpaceState::Unknown;
if ($spacestate === SpaceState::Unknown) {
apcu_store(CACHE_KEY, $spacestate, CACHE_TTL);
return $spacestate;
}
if ($spacestate) {
$spacestate = SpaceState::Open;
} else {
$spacestate = SpaceState::Closed;
}
apcu_store(CACHE_KEY, $spacestate, CACHE_TTL);
return $spacestate;
}
$spaceState = getSpaceState();
if ($spaceState !== SpaceState::Unknown) {
?>
#p-navigation:before {
content: " ";
white-space: pre;
}
<?php if ($spaceState === SpaceState::Open) { ?>
#p-logo:after {
content: "OPEN" ;
border-radius: 3px;
background: green;
color: white;
margin-left: 51px;
padding: 3px 7px;
}
<?php } else if ($spaceState === SpaceState::Closed) { ?>
#p-logo:after {
content: "CLOSED" ;
border-radius: 3px;
background: red;
color: white;
margin-left: 43px;
padding: 3px 7px;
}
<?php } } ?>