Collections tips

From

Jump to: navigation, search

Contents

Collections

The Collection extension facilitates grouping pages for export to PDF or other format. (See Wikieducator for an example). This is the system Wikipedia uses to create eBooks. It can be used with MediaWiki 1.14 or later. See this extensive tutorial. Also see instructions for using this extension as a Book tool.

  • Install cURL for Php5:
sudo apt-get install php5-curl
  • Download the Collection extension and install:
wget http://upload.wikimedia.org/ext-dist/Collection-MW1.16-r66255.tar.gz
sudo tar -xzf Collection-MW1.16-r66255.tar.gz -C /var/lib/mediawiki/extensions
sudo rm Collection-MW1.16-r66255.tar.gz
  • Edit LocalSettings.php and add the lines (for details on settings see this README):
#
# Add the Collections modules and settings:
#
require_once("$IP/extensions/Collection/Collection.php");
#
#$wgCollectionMWServeURL = "(string)";  // URL of a render server (default "http://tools.pediapress.com/mw-serve/")
#$wgCollectionMWServeCert = "(string)";  // (string) = SSL certificate filename, PEM format, for mw-serve render server.
# Needed for self-signed certificates, otherwise cURL will throw an error. The default is null, i.e. no certificate.
#$wgCollectionMWServeCredentials = "(string)";  // "USERNAME:PASSWORD" (or "USERNAME:PASSWORD:DOMAIN" if you're using LDAP)
# Needed only if the MediaWiki requires to be logged in to view articles
#$wgCollectionFormats = array('rl' => 'PDF',) // Array of supported formats. Example: $wgCollectionFormats = array('rl' => 'PDF', 'odf' => 'ODT',);
#$wgCollectionArticleNamespaces = (array);
# 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,);
#$wgCommunityCollectionNamespace = (integer); // Namespace for community (non-personal) collections (Default = ``NS_PROJECT``)
# Needed only if the system message Coll-community_book_prefix has not been set.
#$wgCollectionMaxArticles = (integer);  // Maximum number of articles allowed in a collection (Default 500)
#$wgCollectionLicenseName = "(string)"; // License name for articles in this MediaWiki (Default null)
# If set to ``null`` the localized version of the word "License" is used.
#$wgCollectionLicenseURL = "(string)"; // URL of an article containing the full license (Default null)
#$wgEnableWriteAPI = true; // Enables saving a collection as a wiki (Default = true)
#$wgGroupPermissions['user']['collectionsaveasuserpage'] = true;
#$wgGroupPermissions['autoconfirmed']['collectionsaveascommunitypage'] = true;
  • Edit the Template:Saved_book page and copy lines similar to those found here.

mwlib

The default for the Collections extension is to use the online renderer found at Pediapress. However, a local Python-based rendering server can be installed (mwlib) using these instructions.

Easy installation

  • Install pre-requisites:
sudo apt-get install g++ perl python python-dev python-setuptools python-imaging

Note: python-setuptools >= 0.6c11 is required, but is not included in (K)Ubuntu Lucid or earlier. Download and install (using sudo dpkg -i) a newer python-setuptools .deb package from the Debian (unstable) repositories. Also required is a newer python-pkg-resources .deb package.

  • Download and install program files:
sudo easy_install mwlib
  • Download and install the rendering library for PDF (ReportLab):
sudo easy_install mwlib.rl

Building latest version from source

  • Install pre-requisites:
sudo apt-get install make g++ perl python python-dev python-setuptools python-imaging re2c
  • Download the code:
sudo git clone git://code.pediapress.com/mwlib
  • Build from the downloaded source:
cd mwlib
sudo make
  • Install:
sudo python setup.py build install

Test mwlib

  • Check installed renderers:
mw-render --list-writers
  • Check help:
mw-render --help
  • Render a test page, first from Wikipedia then from your own wiki:
mw-render -w rl -o test.pdf -c http://en.wikipedia.org/w 'World Economic Forum'
and
mw-render -w rl -o test.pdf -c http://mywiki.mydomain.org ' Sample Article '

Start the mw server

For detailed usage instructions see here.

  • Start the server.
sudo mw-serve --protocol=http --port=8899 --interface=127.0.0.1 -d
or, simply
sudo mw-serve -d

These settings are the default, except for -d. The -d switch indicates to run as a daemon. Although the default port is 8899, this can be changed. (Don't forget to open necessary firewalls and to forward ports on your router if the rendering server is to be publicly accessible.)

This command can be added as a startup command. For example, copy the command to a startup script (use the gedit text editor instead of kate if using Ubuntu instead of Kubuntu):

sudo kate ~/.kde/Autostart/mwserver.sh

The command can also be added as a menu item.

The script or the menu item (as a Program) can also be added to the Autostart menu:

K menu -> System -> System Settings -> Advanced -> Autostart -> Add Script... (or Add program...)
  • Edit the LocalSettings.php file so that the variable now reads:
$wgCollectionMWServeURL = "http://127.0.0.1:8899";

Book Templates

Personal tools
Sponsor
  System76