Arbores MediaWiki installation: Difference between revisions

Jump to navigation Jump to search
Line 271: Line 271:
  wfLoadExtension ('CodeEditor');
  wfLoadExtension ('CodeEditor');
=== InputBox ===
=== InputBox ===
(to test/do)
 
  wfLoadExtension ('InputBox');
Can be used to create HTML forms, e.g. to help creating pages with somewhat structure input.  Not installed
* https://www.mediawiki.org/wiki/Extension:InputBox
 
  // wfLoadExtension ('InputBox');
 
=== MultimediaViewer ===
=== MultimediaViewer ===
(to test/do)
(to test/do)

Revision as of 16:08, 12 April 2021

Introduction

This page includes installation notes for this wiki.

Most wiki configuration is done in a LocalSettings.php file

  • You could edit a file locally and transfer it via SFTP or edit it using ssh and the nano editor.

Some configurations are done through wiki pages, e.g. messages, end-user style. the menu-bar, etc.

Important help pages for mediawiki

MediaWiki Tutorials

Working with extensions

Extensions can greatly expand the functionality of your wiki. However, they may break it or may break other extensions. In addition, they may not be maintained, i.e. must be either fixed or uninstalled after upgrades.

Some extensions are already distributed with a standard installation. You still have to follow instructions to get them working.

Downloading the extension

Warnng: you may have to install and extension with the composer (read the instructions below)

In general, we recommend to use git for composer-less installations, since it allows for quick updates and also for switching between versions Most extensions are available from the official repository. Its location is often undocumented on the extension page, but you can easily guess it. As of 2021, the location is

https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ExtensionName.git

e.g.

https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CategoryTree.git

The just cd in to the extension directoy and type:

git pull https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ExtensionName.git

You also should update the whole system. From the root directory, type:

php maintenance/update.php 

Installing extensions with the composer

Composer is run from the base directory (and not the extensions directory) !! It should be installed with a good hosting program like Infomaniak. Otherwise, you will have to install it.

See the documentation for each extension. Examples:

composer require mediawiki/semantic-media-wiki "1.9.*,>=1.9.0.1"
composer require mediawiki/semantic-media-wiki "~2.0"
Update all extensions using composer.
If the dependencies are right, this should work without worrying about versions.
composer update
- or, for stable versions -
composer update --no-dev
Trouble
If composer updates, but maintenance/update.php balks with "Error: your composer.lock file is not up to date. Run "composer update --no-dev" to install newer dependencies", try
php maintenance/update.php --skip-external-dependencies

Basic configuration work

URL configuration

Edit Localsettings.php and verify the URL (this can change later, e.g. if you move to a subdomain

$wgServer = "http://w.arbores.tech";

Enable File upload and add file types

Also read Manual:thumb_handler.php

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads  = true;
$wgGenerateThumbnailOnParse = true;

Wikis can accept most types of files that are not executable, so you should add some more, zip seems to be special case

$wgFileExtensions = array_merge ( $wgFileExtensions,
   array( 'docx', 'pptx', 'xlsx', tiff', 'odt', 'odg', 'ods', 'odp', 'svg', 'pdf')
);

To enable zip extension (tested in MediaWiki v1.19.23) the following will be necessary in the LocalSettings.php file:

$wgFileExtensions[] = 'zip';
$wgTrustedMediaFormats[] = 'application/zip';

Change permission

By default, anyone can create an account and contribute. To change:

$wgGroupPermissions['*']['createaccount']   = false;
$wgGroupPermissions['*']['read']            = true;
$wgGroupPermissions['*']['edit']            = false;
$wgGroupPermissions['*']['createpage']      = false;
$wgGroupPermissions['*']['move']            = false;
$wgGroupPermissions['*']['createtalk']      = false;
$wgGroupPermissions['*']['upload']          = false;
$wgGroupPermissions['*']['reupload']        = false;
$wgGroupPermissions['*']['reupload-shared'] = false;
$wgGroupPermissions['*']['minoredit']       = false;

$wgGroupPermissions['sysop' ]['move']            = true;
$wgGroupPermissions['sysop' ]['read']            = true;
$wgGroupPermissions['sysop' ]['edit']            = true;
$wgGroupPermissions['sysop' ]['createpage']      = true;
$wgGroupPermissions['sysop' ]['createtalk']      = true;
$wgGroupPermissions['sysop' ]['upload']          = true;
$wgGroupPermissions['sysop' ]['reupload']        = true;
$wgGroupPermissions['sysop' ]['reupload-shared'] = true;
$wgGroupPermissions['sysop' ]['minoredit']       = true;
$wgGroupPermissions['sysop' ]['userrights']  = true;
$wgGroupPermissions['sysop' ]['noratelimit'] = true;

Remove table prefixes

Since they conflict with some heavy maintenance scripts

In phpmyadmin select all tables of your database.
   From the dropdown 'With selected:' choose 'Replace table prefix'
   Set from->to replacement.
   DONE

Short URL

On the hosting side, you will need a subdomain if possible (not necessary though)

Step 1: Add a subdomain

For Infomaniak hosting: Read

Step 2: Fix the site URL (if it was installed with the provider's "manager")

Step 3: Add rewrite rules for the subdomain

In the .htaccess root file, add:

RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com [NC]
RewriteCond %{DOCUMENT_ROOT}/%1/ -d
RewriteCond %1::%{REQUEST_URI} !^(.*?)::/\1/?
RewriteRule "^(.*)$" "%{DOCUMENT_ROOT}/%1/$1" [L]

On the wiki side you will have to do two things, add a rewrite rule and change Localsettings.php

Step 4: Add rewrite Rules

  • Read: Short URL
  • Use the MediaWiki ShortURL Builder and follow its instructions. However it won't work if the wiki sits in a subdirectory since it will redirect all URLs containing a w to the wiki :(

There was one major mistake in the generated list, fixed on lines 1 and 2

RewriteRule ^/wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/w %{DOCUMENT_ROOT}/w/index.php [L]

# RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
# RewriteRule ^/w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B]

# RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
# RewriteRule ^/w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

Rights

Rights and icons I suggest creating a subdirectory of the main directory where you can put picture files for icon that are read in via PHP. I used arbores, pick your own, e.g. call it local

// Rights
$wgEnableCreativeCommonsRdf = true;
$wgRightsPage = "Arbores_Wiki:Copyrights"; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "http://creativecommons.org/licenses/by-nc-sa/4.0/";
$wgRightsText = "CC BY-NC-SA Licence";
$wgRightsIcon = "$wgScriptPath/arbores/somerights.png";

Privacy policity

You should add at the least the following in order to be GDPR compliant as well as the Swiss law:

cd extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning

In LocalSettings.php, add

$wfLoadExtension( 'CookieWarning' );
$wgCookieWarningEnabled = true; 

This creates a short popup at the bottom with an OK button. In addition should fill in the privacy page. If you do track users, you need some extra agreements. Read the extension documentation.

Icon and fabicon

You do not need to set this if you upload your favicon.ico to the root of your site. To create a favicon, there are free online websites. Some paint programs also can do it.

To use a favicon located other than in your site root, in LocalSettings.php add

$wgFavicon = "$wgScriptPath/path/to/your/favicon.ico"; 

e.g.

$wgFavicon = "$wgScriptPath/arbores/favicon.ico"; 

Register with WikiApiari

Help the MediaWiki community by registring your wiki.

  • Copy the icon locally (here: to the "arbores" directory)

https://wikiapiary.com/w/images/wikiapiary/b/b4/Monitored_by_WikiApiary.png

  • Insert the following to LocalSettings.php
$wgFooterIcons['monitoredby']['wikiapiary'] = array(
   "src" => "$wgScriptPath/arbores/Monitored_by_WikiApiary.png",
   "url" => "http://wikiapiary.com/wiki/ArboresTechWiki",
   "alt" => "Monitored by WikiApiary"
);

Mobile friendliness

To do, read:

Enabling some builtin extensions

Prequisites - server requirements

An installed wiki comes with preinstalled extensions that you can enable. However, some of these do not work on shared hosting, e.g.

  • Visual editor requires a node.js server

Others require a change in server configuration.

SyntaxHighlight requires shell access. To enable this on Infomaniak, enable it (but evaluate the risks, if a portal is hacked the others will be too).

  • open the Manager (manager.infomaniak.com)
  • go to Hosting
  • click on the hosting/domain name concerned
  • under Sites, click on the domain name of the site concerned
  • click on Advanced parameters
  • click on the PHP Tab
  • put exec, shell_exec, etc. on.

CategoryTree

The CategoryTree extension provides a dynamic view of the wiki's category structure as a tree. It uses AJAX to load parts of the tree on demand. CategoryTree was originally written by Daniel Kinzler as an external tool, but was later integrated into the MediaWiki software with the help of Tim Starling.

wfLoadExtension ('CategoryTree');

Cite

https://www.mediawiki.org/wiki/Extension:Cite

Makes <ref> </ref> for citations available.

Read Help:Cite

wfLoadExtension ('Cite');

CiteThisPage

wfLoadExtension ('CiteThisPage');

CodeEditor

(to test/do)

wfLoadExtension ('CodeEditor');

InputBox

Can be used to create HTML forms, e.g. to help creating pages with somewhat structure input. Not installed

// wfLoadExtension ('InputBox');

MultimediaViewer

(to test/do)

wfLoadExtension ('MultimediaViewer');

ParserFunctions

Adds some extra language elements to the parser. Needed for some templates.

wfLoadExtension ('ParserFunctions');

ConfirmEdit

(to test/do) wfLoadExtension ('ConfirmEdit');

Gadgets

wfLoadExtension ('Gadgets');

ImageMap

wfLoadExtension ('ImageMap');

Lockdown

wfLoadExtension ('Lockdown');

PageImages

wfLoadExtension ('PageImages');

Interwiki

The The Interwiki extension adds the "Special:Interwiki" page toMediaWiki

 to view and edit the

interwiki

table, and a log of any actions made with it.

  wfLoadExtension ('Interwiki');

LocalisationUpdate

wfLoadExtension ('LocalisationUpdate');

Nuke

wfLoadExtension ('Nuke');

OATHAuth

wfLoadExtension ('OATHAuth');

Poem

wfLoadExtension ('Poem');

Scribunto

wfLoadExtension ('Scribunto');

TemplateData

wfLoadExtension ('TemplateData');

PdfHandler

provides an API which allows retrieval of plain-text or limited HTML (HTML with content for some CSS classes removed) extracts of page content. Not used here:

wfLoadExtension ('PdfHandler');

Renameuser

wfLoadExtension ('Renameuser');

ReplaceText

Replace Text is an extension to MediaWiki that provides a special page, as well as a command-line script, to allow administrators to do a global string find-and-replace on both the text and titles of the wiki's content pages. Only sysops can use this, but you can add more, e.g. bureaucrats as below.

As of April 2021, the distributed extension is broken and the new master version is not included, so do this

cd extensions
mv ReplaceText ReplaceText.old
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ReplaceText
wfLoadExtension ('ReplaceText');
$wgGroupPermissions['bureaucrat']['replacetext'] = true;
$wgReplaceTextResultsLimit = 1000;

Good to know:

  • ReplaceText only processes 250 pages at a time by default. To change this, you can set $wgReplaceTextResultsLimit to a larger value in your LocalSettings.php. However, you may be limited by PHP's max_input_vars; if the extension reports such a warning, you may need to change it.
  • All of the replacements are placed in the job queue. So if you have to process a large number of pages, you will need to run Replace Text and then run "runJobs.php" (potentially multiple times).

SecureLinkFixer

wfLoadExtension ('SecureLinkFixer');

SpamBlacklist

wfLoadExtension ('SpamBlacklist');

TitleBlacklist

wfLoadExtension ('TitleBlacklist');

Syntaxhighlight

https://www.mediawiki.org/wiki/Extension:SyntaxHighlight

In Linux, set execute permissions for the pygmentize binary. You can use an FTP client or the following shell command to do so:

chmod a+x /path/to/extensions/SyntaxHighlight_GeSHi/pygments/pygmentize

In Local Settings, add:

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

TextExtracts

wfLoadExtension ('TextExtracts');

VisualEditor

wfLoadExtension ('VisualEditor');

WikiEditor

Adds some useful extras to the standard built-in wiki code editor. Priority installation.

wfLoadExtension ('WikiEditor');

Other extensions

Some other crucial extensions are not included with the distribution we found with our provider

TinyMCE Visual Editor

The standard Wysiwyg editor cannot be installed on a hosted service since it requires node.js (a JavaScript server)

Install with git:

cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/TinyMCE
php maintenance/update.php 

In LocalSettings.php, add:

require_once "$IP/extensions/TinyMCE/TinyMCE.php";
$wgTinyMCEEnabled = true;

Patch to disable the WikiEditor from adding its bar on top (read this and this small patch

Edit file extensions/WikiEditor/includes/WikiEditorHooks.save.php At line 75 add:

// Give other extensions a chance to disable WikiEditor for this page.
if ( !Hooks::run( 'WikiEditorDisable', [ $editPage ] ) ) {
    return true;
 }

In case the code from Wikipedia does not run, there are newer development versions, like this:

cd extensions
mv tinyMCE tinyMCE.old
git clone https://github.com/duncan-crane/TinyMCE.git
cd ..
php maintenance/update.php

PageForms

Page Forms (known before 2016 as Semantic Forms) is an extension to MediaWiki that allows users to add, edit and query data using forms.

Download

cd extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PageForms.git

In LocalSettings.php:

wfLoadExtension( 'PageForms' );

Transfer files from another wiki

There exist several methods. For a fresh wiki clone, Grabbers tools seems to be the most simple, although they do not seem to be much maintained.

To transfer some files, e.g. a full category, you could use the standard export and import tool to transfer articles. In addition, you will have to export and import the images.

Dumping and importing pages

Dump and retrieve Wikipages. This will not include files. As explained in Help:Export and Help:Import, there are several methods in the Wikipedia galaxy. Manual:Importing XML dumps explains generic exporting and importing.

We will use Special:Export and Special:Import, available for users with sysop permissions.

Step 1:

  • On the first wiki (from which to export), create a list of files to export using a text editor. E.g. grab all the files in a category in the export form. You also could use the API to create lists, for example start with categories.
https://edutechwiki.unige.ch/fmediawiki/api.php?action=query&list=categorymembers&cmlimit=500&cmprop=title&format=json&cmtitle=Category:Manuel_de_recherche_en_technologie_éducative

Step 2:

  • Go to Special:Export and paste all your page names into the textbox, making sure there are no empty lines.
  • Click 'Submit query'
  • Save the resulting XML to a file using your browser's save facility.

Step 3:

  • Open the XML file and add a template at the end that you will use to give credits to the original wiki
Replace </text> by something like {{edutechwiki}}
  • Note: if you forgot you also can use a global replace function to do that. E.g. Replace $ (End of file) by {{your template}}

Step 4:

Another method are the grabbing tools

This only would work on a fresh wiki if it does not already have users. Copying the images directory and dumping / restoring the db also would work.,

Grabbing images with grabFile

grabFile is a grabbers tool. It grabs all files and import to the wiki, including the users. So this requires an empty wiki database and may be subject to privacy concerns

To use this script you will have to remove database table prefixes. This is not a problem if your shared hosting gives you several databases.

Use grabFiles.php like this:

php grabFiles.php --url your.wiki/path/api.php --username your name --password XXX

Finally, we decided to use the simple grabImages.php

Grabbing images with grabImage.php

grabImage, grab all the files and put them into a directory. To use this script you will have to remove database table prefixes. This is not a problem if your shared hosting gives you several databases.

Use it like this:

php grabImages.php --url your.wiki/path/api.php
  • As of April 2021, the function is broken, you can replace 'default' by [100,100] near lines 91 and 184

You then can mass import these images

Mass import images

Read:

In LocalSettings.php, make sure that file upload is enabled (it already should)

$wgEnableUploads = true; # Enable uploads

Then, use the ImportImages.php script that sits in the maintenance directory

Will show the possible arguments:

cd maintenance
php importImages.php

Then upload

 php importImages.php ../../../edutechwiki/images-en --comment="Image imported from [http://edutechwiki.unige.ch/en EduTechWiki EN]" --user="Daniel K. Schneider"
 php importImages.php ../../../edutechwiki/images-fr --comment="Image imported from [http://edutechwiki.unige.ch/fr EduTechWiki FR]" --user="Daniel K. Schneider"

Various

Data management

Install Semantic MediaWiki or Cargo ?

config parameters

We will publish most of our config file once we are done....

 to do