SimilarNamedArticles

Aus Free Software
Wechseln zu: Navigation, Suche
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
SimilarNamedArticles

Release status: stable

Implementation Special page
Description Display a list of pages matching a given prefix together with additional information
Author(s) Mathias Ertl (Mati talk)
Version 2.1.5 (2010-10-27)
MediaWiki 1.13.0 or later
License GPL v3 or any later version.
Download see Download
Documentation
Changelog
Parameters $wgSimilarNamedArticlesEnable, $wgSimilarNamedArticlesNamespaces, $wgSimilarNamedArticlesIncludeSubpages, $wgSimilarNamedArticlesAddInfoNamespaces, $wgSimilarNamedArticlesAddInfoCategories, $wgSimilarNamedArticlesAddInfoResources, $wgNamespaceHomes
Example example in this wiki
Hooks used

LoadAllMessages
LanguageGetSpecialPageAliases

This extension is somewhat similar to Special:Prefixindex and in fact the algorithm used to find pages is copied from there. The difference is that this special page is able to display additional information such as categories, the namespace and how many resources a page has. The selection of pages displayed can also be finer tuned, either finding all pages in an explicitly given namespace or pages in a predefined set of namespaces. Additionally, you can choose not to display subpages.


This extension was written specially for the VorlesungsWiki and a lot of its functionality geared towards use in that Wiki. It is used to make "general" links to a course that is held by different professors, if only the course (and not who holds it) is relevant.

Download

The source code of this extension is managed on GitHub. You can find the repository at mathiasertl/SimilarNamedArticles. To get the most recent version of this extension, fetch the current HEAD:

git clone https://github.com/mathiasertl/SimilarNamedArticles.git SimilarNamedArticles

Older versions are marked as tags, you can view available tags with git tag -l and move back to the current HEAD with git checkout <tag-name>. Versions for older versions of MediaWiki, if available, are managed as branches, use git branch and git checkout <branch> to move to a specific branch. To move back to the newest version, use git checkout master.

Note that GitHub allows you to download older different commits as tarball if you do not want to install git.

Installation

The installation is as simple as it could be: Simply download the extension into your extensions-directory, require_once and enable it in LocalSettings.php:

require_once("$IP/extensions/SimilarNamedArticles/SimilarNamedArticles.php");
$wgSimilarNamedArticlesEnable = true;

In its default configuration the extension finds, if no explicit prefix is given, all pages with the given prefix in the namespaces defined by $wgNamespacesToBeSearchedDefault (which is, in turn, only the main namespace per default). If you want to explicitly search in the main namespace only, prefix your search with ':'.

Configuration

The extension is highly configurable. The names of the variables are (hopefully) self-explanatory, an example with a few comments is given here:

# if no explicit prefix is given, search in these namespaces:
$wgSimilarNamedArticlesNamespaces = array( 100 => 1, 102 => 1 );

# do not include subpages in the result:
$wgSimilarNamedArticlesIncludeSubpages = false;

# Usually, the namespaces is not displayed, but you can add it
$wgSimilarNamedArticlesAddInfoNamespaces = true;

# it may be interesting if an article is in certain categories:
$wgSimilarNamedArticlesAddInfoCategories = array('Stub', 'Veraltet');

# if you have enabled PerPageResources for this wiki, it is also 
# possible to display the number of resources for this wiki.
$wgSimilarNamedArticlesAddInfoResources = true;

# if you chose to set  $wgSimilarNamedArticlesAddInfoNamespaces = true,
# you may want to display the namespaces as links to other pages:
$wgNamespaceHomes = array(
       100                     => "Alle LVAs (TU Wien)",
       102                     => "Alle LVAs (Uni Wien)"
);

Examples

Given here are some examples of the usage of this special page. This also servers as a test-suite for this extension. All pages can be found here.

  • Search for articles starting with "Fundamentals". This will only include pages in one of the namespaces defined by $wgSimilarNamedArticlesNamespaces (100, 102) and exclude subpages, since $wgSimilarNamedArticlesIncludeSubpages=false:
Special:SimilarNamedArticles/Fundamentals
  • Search for pages in the TU Wien namespace where the name starts with "Fundamentals":
Special:SimilarNamedArticles/TU Wien:Fundamentals
  • The parameter is always a prefix, the rest of the article-name is discarded. Thats why this search finds more pages than the previous searches:
Special:SimilarNamedArticles/Fund
  • Search for pages in the main namespace where the name starts with "Fundamentals":
Special:SimilarNamedArticles/:Fundamentals

Changelog

2.1.5
  • Compatibility update for PHP 5.3
  • Minimum software requirement is now MediaWiki-1.13.0, because of the MWNamespace class.
2.1.4
  • Special:CreatePage is now in group "VoWi-Extensions" on Special:Specialpages
2.1.3
  • Updated translation to work with all wiki/user language combinations.
2.1.2
  • Updated to work with MediaWiki 1.11.1 and later by fixing LanguageGetSpecialPageAliases (This was a typo in 1.11.0, see Bug 11462)
  • Updated link to this page (This wiki now uses Very short URLs)
2.1.1
  • Subpage-handling is now way better. A page is only classified as subpage if the basepage exists.
2.1
  • It is now possible to also display the number of resources by setting $wgSimilarNamedArticlesAddInfoResources to true ($wgResources must also be set to true)
2.0
  • complete rewrite with an Algorithm that imitates that used in Special:Prefixindex. The code should be way faster.
  • The extension is now split in two parts:
    • This extension implements the basic functionality
    • SimilarNamedArticlesHeader implements the display of SimilarNamedArticles on top of each page
  • lots of new configuration variables
1.0
  • Old version still using the search engine. I'm not aware of where this code can still be found.
0.5
  • First version that didn't consider namespaces

See also

Licence

GPL v3 or any later version.

History

The functionality of this extension (and SimilarNamedArticlesHeader) was originally one of the very first hacks that where written for the VorlesungsWiki.

ToDo

  • Make $wgSimilarNamedArticlesNamespaces a simple array instead of a dictionary
  • we could add http-parameters to allow runtime-modifications of the inclusion of subpages etc. (i.e. ?subpages=true)