Wikisource:WSexport

From Wikisource
Jump to: navigation, search

WSexport is a tool for exporting Wikisource's texts in EPUB, ODT 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), or browsing http://wsexport.fr.nf (currently only for French Wikisource's texts).

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 need to 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 use now a cache system, you must follow this url when you change following files: http://wsexport.wmflabs.org/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, bot excepts, is included by the "{CONTRIBUTORS}" tag. For the list of bots 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',
			'http://wsexport.wmflabs.org/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'
		);
	} );
}

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',
			'http://wsexport.wmflabs.org/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.

See also[edit]

Known bugs[edit]

  • The internal links doesn't work when there are a redirection in Wikisource.