Jump to content

Extension:DownloadBook

From mediawiki.org
MediaWiki extensions manual
DownloadBook
Release status: experimental
Implementation Special page
Description Allows extension Collection to convert books/pages into PDF, etc. locally
Author(s) Edward Chernenkotalk
Latest version 0.0.1
Compatibility policy Master maintains backward compatibility.
MediaWiki 1.34+
Database changes Yes
Tables bookrenderingtask
License GNU General Public License 2.0 or later
Download
  • $wgDownloadBookConvertCommand
  • $wgDownloadBookFileExtension
  • $wgDownloadBookMetadataFromRegex
  • $wgDownloadBookDefaultMetadata

The DownloadBook extension allows extension Collection to generate PDF files without a local or external MWServe server.

It can use third-party utilities such as pandoc (for ePub, ODT, etc.) or WeasyPrint (for PDF). They exist as packages in many Linux distributions.

Installation

[edit]

The Collection extension needs to be installed for this extension to work. Moreover, depending on which output formats are chosen also pandoc (for ePub, ODT, etc.) and/or WeasyPrint (for PDF).

  • Download and move the extracted DownloadBook folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DownloadBook
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Collection' );
    $wgCollectionDisableDownloadSection = false;
    wfLoadExtension( 'DownloadBook' );
    $wgCollectionMWServeURL = '<URL_OF_YOUR_WIKI_HERE>/wiki/Special:DownloadBook';
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Further configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Advanced configuration

[edit]

You can modify the conversion commands in "LocalSettings.php", for example:

$wgDownloadBookConvertCommand['epub'] = "pandoc --from=html --to=epub {INPUT} -o {OUTPUT}";

Please see the file "extension.json" for other configuration options. Also note that keys in $wgDownloadBookConvertCommand array are the same formats as in Collection (i.e. $wgDownloadBookConvertCommand['rl'] is the command for PDF).

Installing third-party conversion tool is your own risk and responsibility. This extension simply calls that tool, and then provides the result to extension Collection.

Troubleshooting

[edit]

Add the following to your "LocalSettings.php":

$wgDebugLogGroups['DownloadBook'] = '/path/to/writable/logfile.txt';
IMPORTANT: 99,9% of issues are caused by incorrect installation of pandoc, permission errors, etc. You will see the cause in the log. Developer of this extension is NOT going to troubleshoot your server configuration for you.