The Collection extension for MediaWiki allows users to collect articles and generate downloadable version in different formats (PDF, OpenDocument Text etc.) for article collections and single articles.
The extension has been developed for and tested with MediaWiki version 1.14 and later. Some features may not be available with older MediaWikis that don’t have the MediaWiki API enabled.
The extension is being developed under the GNU General Public License by PediaPress GmbH in close collaboration with Wikimedia Foundation and the Commonwealth of Learning.
Copyright (C) 2008-2011, PediaPress GmbH
If you use a render server the MediaWiki API must be enabled (i.e. just don’t override the default value of true for $wgEnableApi in your LocalSettings.php).
Currently Collection extension needs PHP with cURL support, see http://php.net/curl
Download the Collection extension matching your mediawiki version from http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Collection and unpack it into your mediawiki extensions directory:
cd /srv/http/wiki/extensions
tar -vxzf ~/Downloads/Collection-MW1.17-r85033.tar.gz
Put this line in your LocalSettings.php:
require_once("$IP/extensions/Collection/Collection.php");
If you intend to use the public render server, you’re now ready to go.
Rendering and ZIP file generation is done by a server, which can run separately from the MediaWiki installation and can be shared by different MediaWikis.
If you have a low-traffic MediaWiki you can use the public render server running at http://tools.pediapress.com/mw-serve/. In this case, just keep the configuration variable $wgCollectionMWServeURL (see below) at its default value.
Your MediaWiki must be accessible from the render server, i.e. if your MediaWiki is behind a firewall you cannot use the public render server.
If you can’t use the public render server, you’ll have to install mwlib and run your own render server.
Finally you’ll have to set $wgCollectionMWServeURL in your LocalSetting.php:
$wgCollectionMWServeURL (string)
Set this to the URL of a render server (see above).
The default is "http://tools.pediapress.com/mw-serve/", the public render server hosted by PediaPress
Password protected wikis require some more information. You’ll have to set the $wgCollectionMWServeCredentials variable.
$wgCollectionMWServeCredentials (string)
Set this to a string of the form “USERNAME:PASSWORD” (or “USERNAME:PASSWORD:DOMAIN” if you’re using LDAP), if the MediaWiki requires to be logged in to view articles. The render server will then login with these credentials using MediaWiki API before doing other requests.
SECURITY NOTICE: If the MediaWiki and the render server communicate over an insecure channel (for example on an unencrypted channel over the internet), please DO NOT USE THIS SETTING, as the credentials will be exposed to eavesdropping!
The following variables can be set in LocalSetting.php. Most people do not have to change them:
An array mapping names of mwlib writers to the name of the produced format. The default value is:
array(
'rl' => 'PDF',
)
i.e. only PDF enabled. If you want to add OpenDocument Text in addition to PDF you can set $wgCollectionFormats to something like this:
$wgCollectionFormats = array(
'rl' => 'PDF',
'odf' => 'ODT',
);
On the public render server tools.pediapress.com, currently the following writers are available:
If you’re using your own render server, the list of available writers can be listed with the following mwlib command:
$ mw-render --list-writers
An array matching content types to filenames for downloaded documents. The default is:
$wgCollectionContentTypeToFilename = array(
'application/pdf' => 'collection.pdf',
'application/vnd.oasis.opendocument.text' => 'collection.odt',
);
An array containing formats (keys in $wgCollectionFormats) that shall be displayed as “Download as XYZ” links in the “Print/export” portlet. The default value is:
array( 'rl' );
i.e. there’s one link “Download as PDF”.
If not null, treat wiki pages whose title contains the configured delimiter as subpages.
For example, to treat article [[Foo/Bar]] as subpage of article [[Foo]] set this variable to “/”. This makes sense e.g. on wikibooks.org, but it’s questionable on wikipedia.org (cf. [[AC/DC]]).
The (only) effect is that the display title for subpages in collections is set to the title of the (deepest) subpage. For example, the title of article [[Foo/Bar]] will be displayed/rendered as “Bar”.
The defaul value is null, which means that no hierarchy is assumed.
List of namespace numbers for pages which can be added to a collection. Category pages (NS_CATEGORY) are always an exception (all articles in a category are added, not the category page itself). Default is:
array(
NS_MAIN,
NS_TALK,
NS_USER,
NS_USER_TALK,
NS_PROJECT,
NS_PROJECT_TALK,
NS_MEDIAWIKI,
NS_MEDIAWIKI_TALK,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
);
Namespace for “community collections”, i.e. the namespace where non-personal article collection pages are saved.
Note: This configuration setting is only used if the system message Coll-community_book_prefix has not been set (see below).
Default is NS_PROJECT.
Maximum number of articles allowed in a collection.
Default is 500.
License name for articles in this MediaWiki. If set to null the localized version of the word “License” is used.
Default is null.
HTTP URL of an article containing the full license text in wikitext format for articles in this MediaWiki. E.g.
$wgCollectionLicenseURL = ‘http://en.wikipedia.org/w/index.php?title=Wikipedia:Text_of_the_GNU_Free_Documentation_License&action=raw‘;
for the GFDL. If set to null, the standard MediaWiki variables $wgRightsPage, $wgRightsUrl and $wgRightsText are used for license information.
If your MediaWiki contains articles with different licenses, make sure that each article contains the name of the license and set $wgCollectionLicenseURL to an article that contains all needed licenses.
$wgEnableWriteAPI
If you want to let users save their collections as wiki pages, make sure $wgEnableWriteAPI is set to true, i.e. put this line in your LocalSettings.php:
$wgEnableWriteAPI = true;(This is the default.)
There are two MediaWiki rights that are checked, before users are allowed to save collections: To be able to save collection pages under the User namespace, users must have the right ‘collectionsaveasuserpage’; to be able to save collection pages under the community namespace (see $wgCommunityCollectionNamespace), users must have the right ‘collectionsaveascommunitypage’. For example, if all logged-in users shall be allowed to save collection pages under the User namespace, but only autoconfirmed users, shall be allowed to save collection pages under the community namespace, add this to your LocalSettings.php:
$wgGroupPermissions['user']['collectionsaveasuserpage'] = true; $wgGroupPermissions['autoconfirmed']['collectionsaveascommunitypage'] = true;
You may also want to configure some of the following:
As the current collection of articles is stored in the session, the session timeout should be set to some sensible value (at least a few hours, maybe one day). Adjust session.cookie_lifetime and session.gc_maxlifetime in your php.ini accordingly.
Add a help page (for example Help:Books for wikis in English language). A repository of help pages in different languages can be found on Meta-Wiki.
The name of the help page is stored in the system message Coll-helppage and can be adjusted by editing the wiki page [[MediaWiki:Coll-helppage]].
collection pages. An example for such a template can be found on the English Wikipedia: http://en.wikipedia.org/wiki/Template:Saved_book
The name of the template can be adjusted via the system message Coll-savedbook_template, i.e. by editing [[MediaWiki:Coll-savedbook_template]].
To enable ZENO and Okawix export, uncomment the corresponding lines in $wgCollectionFormats (file Collection.php). These exports are devoted to the Wikimedia projects and their mirrors. They cannot be used on other wikis since they get data and search engine indexes from the cache of wikiwix.com.
There are several system messages, which can be adjusted for a MediaWiki installation. They can be changed by editing the wiki page [[MediaWiki:SYSTEMMESSAGENAME]], where SYSTEMMESSAGENAME is the name of the system message.