Extension:Silva

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Silva
Release status: stable
Silva-logo.png
Implementation Tag
Description Draw a 2D tree out of a list of skills
Author(s) Loic Dachary (Dacharytalk)
Latest version 1.2.0 (2008-02-27)
MediaWiki 1.11+
License GPLv2+
Download Download
README
ChangeLog
Example Editable example
Translate the Silva extension if it is available at translatewiki.net
Check usage and version matrix.

Silva reads a skill list from a CSV list and draws a 2D tree from it. Each skill is represented exactly once. The order of skills is preserved, from the trunk up. The color of each tree section goes from green to red depending on the frequency of the skill.

Usage[edit]

If two persons, P1 and P2 acquired skills over time, each line between the <silva> tags should list them in chronological order. One line starts with the name of the person and the skill after a semi-colon, as follows:

<silva>
P1;S1
P1;S2
P2;S2
P2;S3


</silva>

will be rendered as:

Silva-example.png

Although it is not in action on the above image, when the mouse is placed over a section of the tree, the name of the corresponding skill is displayed as a tooltip. And each tree section is also a relative link to the article with the name of the skill.

Attributes[edit]

  • alt (default alt="Silva Tree") - defines the alt attribute of the img element of the 2D tree image.
  • title (default alt="Silva Tree Title") - defines the title attribute of the img element of the 2D tree image.
  • wfactor (default wfactor="1.0") a factor > 0.0 and <= 1.0 controlling the weight of a branch, imposing the condition: NO_SKILLS_IN_BRANCH <= sfactor * NO_SKILLS_IN_TREE_LEVEL; other values than specified, leads to unexpected behaviour.
  • ffactor (default ffactor="0.8") a factor >= 0.0 and < 1.0 controlling the position of a skill in the tree, imposing the condition: SKILL_CUMULATIVE_FREQUENCY < rfactor * SKILL_TOTAL_FREQUENCY; other values than specified, leads to unexpected behaviour.
  • strings (no default) if set, the sorted list of unique occurences of the first field of the CSV is displayed after the h3 header containing the value of the strings attribute. Example: strings="People".
  • letters (no default) if set, the sorted list of unique occurences of the second field of the CSV is displayed after the h3 header containing the value of the letters attribute. Example: letters="Skills".

Example:

<silva alt="Silva Tree" title="Silva Tree Title" wfactor="1.0" ffactor="0.8" strings="People" letters="Skills">

CSS[edit]

The <silva> element is replaced with

<div class="silva" id="01234567890123456">
 ...
</div>

where id is unique for a given set of attributes and content. For instance

<silva alt="A">P</silva>

and

<silva alt="B">P</silva>

will lead to a different id although the content is the same, because the alt attribute is different.

If the strings attribute is set, the list is enclosed in:

<div class="silva silva_strings">
  ...
</div>

If the letters attribute is set, the list is enclosed in:

<div class="silva silva_letters">
  ...
</div>

Debian package[edit]

In /etc/apt/sources.list add the following lines

deb http://silva.dachary.org/silva ./
deb-src http://silva.dachary.org/silva ./

and then, from the command line type

apt-get update
apt-get install mediawiki-silva

Manual installation[edit]

Download instructions[edit]

Please cut and paste the code and place it in $IP/extensions/silva/silva.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation[edit]

To install this extension, add the following to LocalSettings.php:

  class silvaBase {
    //
    // Absolute path to the silva command line program
    //
    const PATH = '/usr/bin/silva';
    //
    // Directory where the images generated with silva are cached.
    // Each input has a corresponding image. The images are expired
    // when they are more than week old. It must be writeable to the
    // user running the web server.
    // On Debian, it is a subdirectory of /var/lib/mediawiki/images
    // In general it is a subdirectory of $wgUploadDirectory
    //
    const CACHE = 'silva';
    //
    // The default alt attribute of the tree image
    //
    const ALT = 'Silva Tree';
    //
    // The default locale for reading csv files
    // Note: Locale setting is taken into account by this function. If
    // LANG is e.g. en_US.UTF-8, files in one-byte encoding are read
    // wrong by this function.
    // http://fr2.php.net/manual/en/function.fgetcsv.php
    //
    const LOCALE = 'en_US.UTF-8';
  };

  require_once( "extensions/silva/silva.php" );

Note that the extension depends on the silva program to create the images. It must be installed for the extension to work.