Wikisource:WSexport

From Wikisource
Jump to: navigation, search

WSexport is a tool for exporting Wikisource's texts in EPUB, PDF and other file formats. It was created by user Tpt for French Wikisource, but it's also available for the other Wikisource subdomains. It can be used directly from its page on Wikimedia labs (for texts in all languages, use "www" for oldwikisource).

This page explains how to configure your Wikisource subdomain in order to get the best results from WSexport. For most of these operations you will need sysop access.

For books[edit]

Microformat[edit]

When exporting a page, WSexport looks for the page's metadata (title, author, year, etc.) using the Microformat specification. In order to see these informations in the exported EPUBs, you must implement Microformat on your subdomain, in the template that you're using as header for your texts. You can find an example at the bottom of fr:Modèle:Proofreadpage header template.

Hide unwanted elements[edit]

You may want to hide certain elements in your EPUBs, like the header box, or the page numbers generated by MediaWiki:Proofreadpage pagenum template. Assign class="ws-noexport" to each HTML element that you want to be excluded from the export.

For the wiki[edit]

WSexport uses a cache system, you must follow this URL when you change following files : https://tools.wmflabs.org/wsexport/tool/book.php?refresh=true&lang= YOUR LANG CODE

CSS[edit]

If you need to include some custom CSS style, you can create MediaWiki:Epub.css and put them there. No CSS from Mediawiki:Common.css or CSS provided by MediaWiki are injected in the generated ePub file.

Translation[edit]

To translate the interface's messages, create MediaWiki:Wsexport i18n.ini (follow this file as example).

About[edit]

You can provide your about file by creating MediaWiki:Wsexport about (follow fr:MediaWiki:Wsexport about as example). The list of contributors, bots excepted, is included by the "{CONTRIBUTORS}" tag. For the bots list, use "{BOT-CONTRIBUTORS}" tag.

Direct link from Wikisource pages[edit]

The following code, to be placed in your MediaWiki:Common.js, adds the command "Download as EPUB" in the menu bar, just after "Download as PDF", for every page in the main namespace. Replace "fr" in lang=fr with the language code for your subdomain.

// Link "Download as EPUB"
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
	$( function () {
		mw.util.addPortletLink(
			'p-coll-print_export',
			'//tools.wmflabs.org/wsexport/tool/book.php?lang=fr&format=epub&page=' + mw.config.get( 'wgPageName' ),
			'Download as EPUB',
			'n-epubExport',
			'Download an EPUB version of this page',
			'',
			'#t-print'
		);
		$('#n-epubExport > a').attr('rel', 'nofollow');
	} );
}

Or you can specify a category of pages "Ready for export":

// Link "Download as EPUB"
if ( $.inArray( 'Ready for export', mw.config.get( 'wgCategories' ) ) !== -1 ) {
	$( function () {
		mw.util.addPortletLink(
			'p-coll-print_export',
			'//tools.wmflabs.org/wsexport/tool/book.php?lang=fr&format=epub&page=' + mw.config.get( 'wgPageName' ),
			'Download as EPUB',
			'n-epubExport',
			'Download an EPUB version of this page',
			'',
			'#t-print'
		);
	} );
}

Bug reports[edit]

You can report any bug you find on the discussion page or on the French page fr:Wikisource:Wsexport.

Subpages[edit]

The current algorithm used in Wsexport to extract the table of content (TOC) of the book (and so, include the other pages of the book) is:

  • look for nodes in the pages with class="ws-summary" (it could be directly MY_TOC in the page wikitext of an equivalent thing done using templates)
  • if such nodes are found, use the list of links in them to build the TOC
  • if not look for all links to subpages and use the returned list as TOC

See also[edit]

Known bugs[edit]

  • The internal links don't work if there is a redirection in Wikisource.