professional-wiki / network
MediaWiki extension for adding interactive network visualizations to your wiki pages
Fund package maintenance!
JeroenDeDauw
Installs: 181
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 4
Forks: 1
Open Issues: 6
Language:JavaScript
Type:mediawiki-extension
Requires
- php: >=7.3
- composer/installers: ^1.0.1
Requires (Dev)
- maglnet/composer-require-checker: ^2.1
- phpstan/phpstan: ^0.12.29
- vimeo/psalm: dev-master
README
The Network extension allows visualizing connections between wiki pages via an interactive network graph.
It was created by Professional.Wiki and funded by KDZ - Centre for Public Administration Research.
- Platform requirements
- Installation
- Usage
- Limitations
- Contribution and support
- Development
- License
- Release notes
Platform requirements
- PHP 7.3 or later
- MediaWiki 1.31.x up to 1.35.x
See the release notes for more information on the different versions of Network.
Installation
The recommended way to install Network is using Composer with MediaWiki's built-in support for Composer.
On the commandline, go to your wikis root directory. Then run these two commands:
COMPOSER=composer.local.json composer require --no-update professional-wiki/network:~1.3
composer update professional-wiki/network --no-dev -o
Then enable the extension by adding the following to the bottom of your wikis LocalSettings.php
file:
wfLoadExtension( 'Network' );
You can verify the extension was enabled successfully by opening your wikis Special:Version page in your browser.
Finally, please consider sponsoring the project.
Usage
Minimal example
{{#network:}}
Example with parameters
{{#network:Page1 | Page2 | Page3
| class = col-lg-3 mt-0
| exclude = Main Page ; Sitemap
}}
Parameters
Default | Example value | Description | |
---|---|---|---|
(page or pages) | The current page | MyPage | The name of the page to show connections for. Can be specified multiple times. The parameter name is optional. Templates are supported |
class | col-lg-3 mt-0 | Extra css class(es) to add to the network graph | |
exclude | Sitemap ; Main Page | Pages to exclude from the network graph, separated by semicolon | |
options | { "nodes": { "shape": "box" } } | vis.js options in JSON. Option names and text values both need to be surrounded with double quotes. Single quotes will not work. Tailing commas also do not work. Two curly brackets closes the parser function, so if you are putting the JSON directly in the parser function rather than using a template, put a tailing space or new line after each closing bracket. |
Layout CSS
The network graphs are located in a div with class network-visualization
. The default css for this class is
.network-visualization { width: 100%; height: 600px; }
You can add extra CSS in MediaWiki:Common.css. You can also add extra classes to the div via the class
parameter.
Configuration
The default value of all parameters can be changed by placing configuration in "LocalSettings.php". These configuration settings are available:
$wgPageNetworkOptions
– options passed directly to the graph visualization library$wgPageNetworkExcludeTalkPages
- indicates if talk pages should be excluded$wgPageNetworkExcludedNamespaces
- IDs of namespaces to exclude
Default values of these configuration settings can be found in "extension.json". Do not change "extension.json".
$wgPageNetworkOptions
Array of vis.js options. Can be (partially) overridden per network via the options
parameter
Example:
$wgPageNetworkOptions = [ 'clickToUse' => true, 'nodes' => [ 'borderWidth' => 1, 'borderWidthSelected' => 2, 'shape' => 'box', ], ];
private function registerEditApiModuleFallbacks() {
}
Note: to change the width or height, use CSS, not the network options.
$wgPageNetworkExcludeTalkPages
Possible values: true
, false
Default value: true
(talk pages get excluded)
$wgPageNetworkExcludedNamespaces
List of IDs of namespaces of which all pages should be excluded.
Default value: [ 2, 4, 8, 12 ]
(excluding User
, Project
, MediaWiki
and Help
)
Example: $wgPageNetworkExcludedNamespaces = [ NS_USER, NS_PROJECT ];
See also: https://www.mediawiki.org/wiki/Manual:Namespace#Built-in_namespaces
Examples
Options parameter
Array of vis.js options
{{#network:Page1 | Page2 | Page3
| options=
{
"autoResize": true,
"nodes": {
"color": "lightblue",
"shape": "box",
"borderWidth": 3,
"font": { "color": "red", "size": 17 }
}
}
}}
Wrong: "font.color": "red"
, right: "font": { "color": "red" }
, also right: "font": "14 px arial red"
Using templates
{{#network: {{NetworkPages}}
| class = col-lg-3 mt-0
| options= {{NetworkOptions}}
}}
Where NetworkPages
contains Page1 | Page2 | Page3
and NetworkOptions
contains { "nodes": { "shape": "box" } }
Performance / caching
This extension bypasses the MediaWiki page cache. This means that your network graphs will always be up to date, without needing to purge the page cache.
Limitations
- External links are not shown
- Node labels cannot be changed. They are always the full page name
- Styling or grouping per category or namespace is not supported
Pull requests to remove those limitations are welcome.
You can also contact Professional.Wiki for Professional MediaWiki development services.
Contribution and support
If you want to contribute work to the project please subscribe to the developers mailing list and have a look at the contribution guideline.
- File an issue
- Submit a pull request
- Ask a question on the mailing list
Professional MediaWiki support is available via Professional.Wiki.
Development
Tests, style checks and static analysis can be run via Make. You can execute these commands on the command line
in the extensions/Network
directory:
make ci
- run everythingmake cs
- run style checksmake test
- run the tests
For more details see the Makefile
.
The JavaScript tests can only be run by going to the Special:JavaScriptTest
page.
License
GNU General Public License v2.0 or later (GPL-2.0-or-later).
Professional Support and Development
Professional.Wiki provides commercial MediaWiki development, managed wiki hosting and MediaWiki support.
Release notes
Version 1.4.0
Released on January 9, 2021.
- Upgraded viz-network from 8.3.2 to 8.5.5
Version 1.3.0
Released on September 8, 2020.
- Added WAI compliance by adding an aria-label attribute to the network canvas
Version 1.2.1
Released on September 7, 2020.
- Added compatibility with MediaWiki 1.31
Version 1.2.0
Released on September 7, 2020.
- Upgraded viz-network from 7.6 to 8.3
Version 1.1.1
Released on September 7, 2020.
- Made code more robust against invalid titles
Version 1.1.0
Released on August 30, 2020.
- Added
$wgPageNetworkExcludeTalkPages
option - Added
$wgPageNetworkExcludedNamespaces
option - Improved node repulsion physics
Version 1.0.0
Released on August 11, 2020.
Initial release