Extensions

De Wiki de Jordan LE NUFF
Sauter à la navigation Sauter à la recherche
(Page créée avec « == Présentation == Cette page a pour objet de décrire les extensions supplémentaires du MediaWiki qui ont dû être installées et/ou paramétrées pour pouvoir le pers... »)
 
 
(2 révisions intermédiaires par le même utilisateur non affichées)
Ligne 335 : Ligne 335 :
  
 
# End of VisualEditor configuration
 
# End of VisualEditor configuration
 +
</syntaxhighlight>
 +
 +
== Multi-Category Search ==
 +
=== Description ===
 +
L'extension Multi-Category Search permet aux utilisateurs de rechercher des pages incluses simultanément dans plusieurs catégories spécifiées.
 +
 +
Plus d'informations sur https://www.mediawiki.org/wiki/Extension:Multi-Category_Search.
 +
=== Téléchargement ===
 +
Téléchargement de l'extension via la commande :
 +
 +
wget -O ~/downloads/MultiCategorySearch_1.69.zip https://iweb.dl.sourceforge.net/project/mwext/MultiCategorySearch/MultiCategorySearch_1.69.zip
 +
 +
===Implémention===
 +
Décompression du paquet de l'extension via dans le dossier des extension du MediaWiki :
 +
unzip ~/downloads/MultiCategorySearch_1.69.zip -d /data/www/mediawiki/current/extensions/MultiCategorySearch
 +
 +
Appliquer les droits d'accès :
 +
chown -R www:www /data/www/mediawiki/current/extensions/MultiCategorySearch
 +
 +
===Configuration===
 +
# Dans le fichier <code>/data/www/mediawiki/LocalSettings.php</code>, ajouter la ligne suivante :
 +
#:<syntaxhighlight lang="php">
 +
require_once "$IP/extensions/MultiCategorySearch/MultiCategorySearch.php";
 +
</syntaxhighlight>
 +
# Dans le fichier <code>/data/www/mediawiki/current/extensions/MultiCategorySearch/MultiCategorySearch_body.php</code>, commenter les lignes suivantes :
 +
#:<syntaxhighlight lang="php" line start="144">
 +
wfProfileIn( 'MultiCategorySearch::showResults' ); ==> //wfProfileIn( 'MultiCategorySearch::showResults' );
 +
</syntaxhighlight>
 +
#:<syntaxhighlight lang="php" line start="311">
 +
wfProfileOut( 'MultiCategorySearch::showResults' ); ==> //wfProfileOut( 'MultiCategorySearch::showResults' );
 +
</syntaxhighlight>
 +
# De nouveau dans le fichier <code>/data/www/mediawiki/current/extensions/MultiCategorySearch/MultiCategorySearch_body.php</code>, ajouter la variable <syntaxhighlight lang="php" inline>$dropDownListCount</syntaxhighlight> en début de fichier comme ceci :
 +
#:<syntaxhighlight lang="php" line highlight="4-5" start="34">
 +
...
 +
/** Method of passing parameters. Change it to 'get', if you need that method for some reason. */
 +
var $paramsPassMethod = 'post';
 +
/** Number of categories that can be selected for search */
 +
var $dropDownListCount = 3;
 +
 +
// End of configuration settings
 +
...
 +
</syntaxhighlight>
 +
# Toujours dans le fichier <code>/data/www/mediawiki/current/extensions/MultiCategorySearch/MultiCategorySearch_body.php</code>, modifier la fonction <syntaxhighlight lang="php" inline>function showDropdownLists()</syntaxhighlight> afin d'adapter la variable <syntaxhighlight lang="php" inline>$dropDownList</syntaxhighlight> comme ceci :
 +
#:<syntaxhighlight lang="php" line start="444" highlight="4-21">
 +
...
 +
$outputMarkup = '';
 +
 +
$dbr = wfGetDB( DB_SLAVE );
 +
$res = $dbr->select(
 +
'category',                                  // $table The table to query FROM (or array of tables)
 +
array( 'cat_title', 'cat_pages' ),            // $vars (columns of the table to SELECT)
 +
'cat_pages > 0',                              // $conds (The WHERE conditions)
 +
__METHOD__,                                  // $fname The current __METHOD__ (for performance tracking)
 +
array( 'ORDER BY' => 'cat_title ASC' )        // $options = array()
 +
);
 +
 +
for($i=1;$i<=$this->dropDownListCount ;$i++) {
 +
$dropDownList["$i"] = array(
 +
'*' => '',
 +
'ListCaption' => "Catégorie $i",
 +
'AutoFillFrom' => 'TYPE PARENT CATEGORY NAME HERE',
 +
);
 +
foreach($res as $cat)
 +
$dropDownList["$i"][str_replace("_"," ","$cat->cat_title")] = "$cat->cat_title";
 +
}
 +
 +
$listsNumber = count( $dropDownList );
 +
...
 +
</syntaxhighlight>
 +
 +
L'extension est accessible à l'URL [[Spécial:MultiCategorySearch]].
 +
 +
Elle peut également être utilisée sur une page via une [https://www.mediawiki.org/wiki/Transclusion/fr transclusion]. Exemple :
 +
<pre>{{Special:MultiCategorySearch/include=Category 1/include=Category 2/exclude=Category 3}}</pre>
 +
 +
== Intersection/DynamicPageList ==
 +
=== Description ===
 +
L'extension Intersection/DynamicPageList permet aux utilisateurs du wiki de créer une liste de pages répertoriées dans un ensemble de catégories.
 +
 +
=== Téléchargement ===
 +
Téléchargement de l'extension via la commande :
 +
 +
wget -O ~/downloads/intersection-REL1_33-05edc37.tar.gz https://extdist.wmflabs.org/dist/extensions/intersection-REL1_33-05edc37.tar.gz
 +
 +
===Implémention===
 +
Décompression du paquet de l'extension via dans le dossier des extension du MediaWiki :
 +
mkdir /data/www/mediawiki/current/extensions/intersection
 +
tar -xzf ~/downloads/intersection-REL1_33-05edc37.tar.gz -C /data/www/mediawiki/current/extensions/intersection
 +
 +
Appliquer les droits d'accès :
 +
chown -R www:www /data/www/mediawiki/current/extensions/intersection
 +
 +
===Configuration===
 +
Dans le fichier <code>/data/www/mediawiki/LocalSettings.php</code>, ajouter la ligne suivante :
 +
<syntaxhighlight lang="php">
 +
wfLoadExtension( 'intersection' );
 
</syntaxhighlight>
 
</syntaxhighlight>

Version actuelle datée du 13 août 2019 à 13:08

Présentation

Cette page a pour objet de décrire les extensions supplémentaires du MediaWiki qui ont dû être installées et/ou paramétrées pour pouvoir le personnaliser.

La liste des extensions installées est disponible sur la page Spécial:Version

LDAP Authentication Plugin

Description

Cette extension permet d'authentifier un utilisateur via son compte Active Directory. Il permet également un filtrage de connexion en fonction des groupes d'appartenance dans l'AD.

La page officielle de cette extension se trouve à LDAP Authentication Plugin

Implémentation

Téléchargement de l'extension via la commande :

wget https://extdist.wmflabs.org/dist/extensions/LdapAuthentication-REL1_31-b19888c.tar.gz

Décompression du paquet de l'extension via dans le dossier des extension du MediaWiki :

tar -xzf LdapAuthentication-REL1_31-b19888c.tar.gz -C /dossier/installation/du/mediawiki/extensions

Paramétrage

Ajout des lignes suivantes dans le fichier LocalSettings.php :

## Beginning of LDAP Authentication/AD Configuration
require_once ("$IP/extensions/LdapAuthentication/LdapAuthentication.php");
$wgAuth = new LdapAuthenticationPlugin();

$wgLDAPDomainNames = array(
  'undomaine'
);

$wgLDAPServerNames = array(
  'undomaine' => 'AdServer.undomaine.com'
);

$wgLDAPSearchStrings = array(
 'undomaine' => 'USER-NAME@undomaine.com'
);

$wgLDAPEncryptionType = array(
  'undomaine' => 'clear'
);

$wgLDAPUseLocal = false;
$wgMinimalPasswordLength = 1;

$wgLDAPBaseDNs = array(
  'undomaine' => 'DC=undomaine,DC=com'
);

$wgLDAPSearchAttributes = array(
  'undomaine' => 'sAMAccountName'
);

$wgLDAPRetrievePrefs = array(
  'undomaine' => true
);

$wgLDAPPreferences = array(
  'undomaine' => array(
    'email' => 'mail',
    'realname' => 'displayName',
    'nickname' => 'samaccountname'
  )
);

$wgLDAPProxyAgent =  array(
  'undomaine' => 'CN=queryAdUser,OU=serviceAccounts,OU=Users,DC=undomaine,DC=com'
);

$wgLDAPProxyAgentPassword = array(
  'undomaine' => 'xxxxxxxxx' // <== à récupérer dans un gestionnaire de mots de passe
);

$wgLDAPDisableAutoCreate = array(
  'undomaine' => true
);

$wgLDAPGroupUseFullDN = array(
  'undomaine' => true
);

$wgLDAPLowerCaseUsername = array(
  'undomaine' => true
);

$wgLDAPGroupObjectclass = array(
  'undomaine' => 'group',
);

$wgLDAPGroupAttribute = array(
  'undomaine' => 'member',
);

$wgLDAPGroupNameAttribute = array(
  'undomaine' => 'cn',
);

$wgLDAPGroupsUseMemberOf = array(
  'undomaine' => false,
);

$wgLDAPUseLDAPGroups = array(
  'undomaine' => true,
);

$wgLDAPRequiredGroups = array(
  'undomaine' => array(
    'CN=MyGroup,OU=Utilisateurs,OU=Departement,OU=Habilitation,DC=undomaine,DC=com',
	)
);

$wgLDAPGroupsPrevail = array(
  'undomaine' => true,
);

$wgLDAPGroupSearchNestedGroups = array(
  'undomaine' => true,
);

$wgLDAPActiveDirectory = array(
  'undomaine' => true,
);

$wgLDAPAuthAttribute = array(
  'undomaine' => '!(userAccountControl:1.2.840.113556.1.4.803:=2)',
);

$wgHooks['SetUsernameAttributeFromLDAP'][] = 'SetUsernameAttribute';

function SetUsernameAttribute(&$LDAPUsername, $info) {
        $LDAPUsername = $info[0]['samaccountname'][0];
        return true;
}

//$wgLDAPDebug = 1; # <== à commenter une fois l'installation définitivement terminée
//$wgDebugLogGroups['ldap'] = '../logs/debug_ldap_wiki.log'; # <== à commenter une fois l'installation définitivement terminée
## End of LDAP Authentication/AD Configuration

Configuration des groupes dans l'Active Directory :

LabeledSectionTransclusion

Description

Cette extension permet d'étendre les fonctionnalités de l'extension native transclusion du mediawiki. Plus particulièrement, elle permet d'inclure dans des pages des sections d'autres pages.

Implémentation

Téléchargement de l'extension via la commande :

wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_31-d6f59f5.tar.gz

Décompression du paquet de l'extension via dans le dossier des extension du MediaWiki :

tar -xzf LabeledSectionTransclusion-REL1_31-d6f59f5.tar.gz -C /dossier/installation/du/mediawiki/extensions

Utilisation

Définition des marques

Utilisez les marques <section> de la façon suivante :

<section begin=chapter1 />Ceci est une section à inclure<section end=chapter1 />

Inclusion des marques

Inclure la section précédemment définie comme ceci :

{{#lst:articleX|chapter1}}

Inclusion avec exclusion

Il est possible d'inclure toute la page en excluant uniquement ce qui a été précédemment défini comme ceci :

{{#lstx:articleX|chapter1}}

Plus d'informations sur Labeled Section Transclusion.

SubPageList

Présentation

Cette extension permet d'afficher de façon simple les sous-pages d'une page

Implémentation

Depuis la console serveur, faire :

cd /dossier/installation/du/mediawiki/
composer require mediawiki/sub-page-list "~1.5"

Vérifier dans le fichier LocalSettings.php que la variable suivante est définit comme ceci :

$GLOBALS['wgNamespacesWithSubpages'][NS_MAIN] = 1;

Dans le fichier de configuration de l'extension, modifier la variable suivante comme ceci :

vi extensions/SubPageList/SubPageList.settings.php
$GLOBALS['egSPLAutorefresh'] = true;

Plus d'informations sur la page officielle de l'extension SubPageList

Lockdown

Présentation

L'extension Lockdown permet de limiter l'accès à des espaces de noms (namespace) spécifiques et à des pages spéciales à un ensemble donné de groupes d'utilisateurs.

Implémentation

Se connecter au serveur et télécharger l'extension via la commande :

wget https://extdist.wmflabs.org/dist/extensions/Lockdown-REL1_31-7db0221.tar.gz

Puis, la déployer via :

tar -xzf Lockdown-REL1_31-7db0221.tar.gz -C /dossier/installation/du/mediawiki/extensions

Ensuite, l'activer en ajoutant la ligne suivante dans le fichier LocalSettings.php :

wfLoadExtension( 'Lockdown' );

Configuration

La configuration se fait dans le fichier LocalSettings.php au niveau de la gestion des droits d'accès.

VisualEditor

Présentation

L'extension VisualEditor permet de modifier des pages en tant que contenu riche. Il existe également un projet du même nom visant à créer un éditeur de texte enrichi fiable pour le Web et MediaWiki.

L’extension VisualEditor s’appuie sur un service d’analyseur Parsoid déporté basé sur nodeJS qui doit être installé et activé pour pouvoir en modifier les pages.

Plus d'information sur https://www.mediawiki.org/wiki/Extension:VisualEditor .

Implémentation

Installation de npm

yum install npm

Installation de l'extension parsoid

wget -O downloads/VisualEditor-REL1_32-e82e120.tar.gz https://extdist.wmflabs.org/dist/extensions/VisualEditor-REL1_32-e82e120.tar.gz
tar -xzf downloads/VisualEditor-REL1_32-e82e120.tar.gz -C /dossier/installation/du/mediawiki/extensions

Installation du service parsoid

  • Téléchargement et installation des sources
mkdir -p /local
cd /local/
git clone --recursive https://gerrit.wikimedia.org/r/mediawiki/services/parsoid/deploy
git clone https://gerrit.wikimedia.org/r/mediawiki/services/parsoid
cd parsoid
npm install
  • Dupliquer le fichier config.example.yaml
cp /local/parsoid/config.example.yaml /local/parsoid/config.yaml
  • Editer le fichier /local/parsoid/config.yaml afin que la variable uri soit la suivante :
uri: 'https://wiki.jordan-lenuff.com/api.php'
  • Editer le fichier /usr/lib/systemd/system/parsoid.service et y renseigner le contenu suivant :
[Unit]
Description=Mediawiki Parsoid web service on node.js
Documentation=http://www.mediawiki.org/wiki/Parsoid
Wants=local-fs.target network.target
After=local-fs.target network.target httpd.service

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=parsoid
Group=parsoid
WorkingDirectory=/local/parsoid
ExecStart=/usr/bin/node /local/parsoid/bin/server.js
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog
  • Création du user parsoid
groupadd -g 499 parsoid
useradd -u 499 -g 499 -c "Parsoid service user" -m -r parsoid
chown -R parsoid:parsoid /local/parsoid
  • Activation du service parsoid
systemctl daemon-reload
systemctl enable parsoid
systemctl start parsoid

Configuration

  • Configuration de l'extension VisualEditor dans le fichier LocalSettings.php
## VisualEditor configuration
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;

// Add non-default namespaces
$wgVisualEditorAvailableNamespaces = [
    NS_ANAMESPACE => true,
    NS_OTHERNAMESPACE => true,
    NS_ANOTHERNAMESPACEAGAIN => true,
];

# Disable popup message
$wgVisualEditorShowBetaWelcome = false;

// Optional: Set VisualEditor as the default for anonymous users
// otherwise they will have to switch to VE
// $wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";

// Don't allow users to disable it
#$wgHiddenPrefs[] = 'visualeditor-enable';

// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

$wgVirtualRestConfig['modules']['parsoid'] = array(
    // URL to the Parsoid instance
    // Use port 8142 if you use the Debian package
    'url' => 'http://localhost:8000',
    // Parsoid "domain", see below (optional)
    'domain' => 'localhost',
    // Parsoid "prefix", see below (optional)
    'prefix' => 'localhost'
);

// This feature requires a non-locking session store. The default session store will not work and
// will cause deadlocks (connection timeouts from Parsoid) when trying to use this feature. Only required for MediaWiki 1.26.x and earlier!
$wgSessionsInObjectCache = true;

// Forward users' Cookie: headers to Parsoid. Required for private wikis (login required to read).
// If the wiki is not private (i.e. $wgGroupPermissions['*']['read'] is true) this configuration
// variable will be ignored.
//
// WARNING: ONLY enable this on private wikis and ONLY IF you understand the SECURITY IMPLICATIONS
// of sending Cookie headers to Parsoid over HTTP. For security reasons, it is strongly recommended
// that $wgVirtualRestConfig['modules']['parsoid']['url'] be pointed to localhost if this setting is enabled.
$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;

# End of VisualEditor configuration

Multi-Category Search

Description

L'extension Multi-Category Search permet aux utilisateurs de rechercher des pages incluses simultanément dans plusieurs catégories spécifiées.

Plus d'informations sur https://www.mediawiki.org/wiki/Extension:Multi-Category_Search.

Téléchargement

Téléchargement de l'extension via la commande :

wget -O ~/downloads/MultiCategorySearch_1.69.zip https://iweb.dl.sourceforge.net/project/mwext/MultiCategorySearch/MultiCategorySearch_1.69.zip

Implémention

Décompression du paquet de l'extension via dans le dossier des extension du MediaWiki :

unzip ~/downloads/MultiCategorySearch_1.69.zip -d /data/www/mediawiki/current/extensions/MultiCategorySearch

Appliquer les droits d'accès :

chown -R www:www /data/www/mediawiki/current/extensions/MultiCategorySearch

Configuration

  1. Dans le fichier /data/www/mediawiki/LocalSettings.php, ajouter la ligne suivante :
    require_once "$IP/extensions/MultiCategorySearch/MultiCategorySearch.php";
    
  2. Dans le fichier /data/www/mediawiki/current/extensions/MultiCategorySearch/MultiCategorySearch_body.php, commenter les lignes suivantes :
    144 wfProfileIn( 'MultiCategorySearch::showResults' ); ==> //wfProfileIn( 'MultiCategorySearch::showResults' );
    
    311 wfProfileOut( 'MultiCategorySearch::showResults' ); ==> //wfProfileOut( 'MultiCategorySearch::showResults' );
    
  3. De nouveau dans le fichier /data/www/mediawiki/current/extensions/MultiCategorySearch/MultiCategorySearch_body.php, ajouter la variable $dropDownListCount en début de fichier comme ceci :
    34 ...
    35 	/** Method of passing parameters. Change it to 'get', if you need that method for some reason. */
    36 	var $paramsPassMethod = 'post';
    37 	/** Number of categories that can be selected for search */
    38 	var $dropDownListCount = 3;
    39 
    40 	// End of configuration settings
    41 ...
    
  4. Toujours dans le fichier /data/www/mediawiki/current/extensions/MultiCategorySearch/MultiCategorySearch_body.php, modifier la fonction function showDropdownLists() afin d'adapter la variable $dropDownList comme ceci :
    444 ...
    445 		$outputMarkup = '';
    446 
    447 		$dbr = wfGetDB( DB_SLAVE );
    448 		$res = $dbr->select(
    449 			'category',                                   // $table The table to query FROM (or array of tables)
    450 			array( 'cat_title', 'cat_pages' ),            // $vars (columns of the table to SELECT)
    451 			'cat_pages > 0',                              // $conds (The WHERE conditions)
    452 			__METHOD__,                                   // $fname The current __METHOD__ (for performance tracking)
    453 			array( 'ORDER BY' => 'cat_title ASC' )        // $options = array()
    454 		);
    455 
    456 		for($i=1;$i<=$this->dropDownListCount ;$i++) {
    457 			$dropDownList["$i"] = array(
    458 				'*' => '',
    459 				'ListCaption' => "Catégorie $i",
    460 				'AutoFillFrom' => 'TYPE PARENT CATEGORY NAME HERE',
    461 			);
    462 			foreach($res as $cat)
    463 				$dropDownList["$i"][str_replace("_"," ","$cat->cat_title")] = "$cat->cat_title";
    464 		}
    465 
    466 		$listsNumber = count( $dropDownList );
    467 ...
    

L'extension est accessible à l'URL Spécial:MultiCategorySearch.

Elle peut également être utilisée sur une page via une transclusion. Exemple :

{{Special:MultiCategorySearch/include=Category 1/include=Category 2/exclude=Category 3}}

Intersection/DynamicPageList

Description

L'extension Intersection/DynamicPageList permet aux utilisateurs du wiki de créer une liste de pages répertoriées dans un ensemble de catégories.

Téléchargement

Téléchargement de l'extension via la commande :

wget -O ~/downloads/intersection-REL1_33-05edc37.tar.gz https://extdist.wmflabs.org/dist/extensions/intersection-REL1_33-05edc37.tar.gz

Implémention

Décompression du paquet de l'extension via dans le dossier des extension du MediaWiki :

mkdir /data/www/mediawiki/current/extensions/intersection
tar -xzf ~/downloads/intersection-REL1_33-05edc37.tar.gz -C /data/www/mediawiki/current/extensions/intersection

Appliquer les droits d'accès :

chown -R www:www /data/www/mediawiki/current/extensions/intersection

Configuration

Dans le fichier /data/www/mediawiki/LocalSettings.php, ajouter la ligne suivante :

wfLoadExtension( 'intersection' );