Jump to content

Wikisource:WS Export: Difference between revisions

From Wikisource
Content deleted Content added
Phe (talk | contribs)
add a rel="nofollow" to the link to avoid bot to spam wsexport
Samwilson (talk | contribs)
Translatewiki link, and GitHub → GitLab.
 
(28 intermediate revisions by 13 users not shown)
Line 1: Line 1:
<languages />
'''WSexport''' is a tool for exporting Wikisource's texts in [[w:EPUB|EPUB]], [[w:PDF|PDF]] and other file formats. It was created by user [[:fr:User:Tpt|Tpt]] for French Wikisource, but it's also available for the other Wikisource subdomains. It can be used directly from its page on [http://tools.wmflabs.org/wsexport/tool/book.php Wikimedia labs] (for texts in all languages, use "www" for oldwikisource).
<translate>
<!--T:1-->
'''WS Export''' is a tool for exporting Wikisource's texts in [[w:EPUB|EPUB]], [[w:PDF|PDF]] and other file formats.


<!--T:2-->
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.
It can be used directly from its page on Toolforge: <tvar name=url>https://ws-export.wmcloud.org/</tvar> (for texts in all languages; use "www" for Multilingual Wikisource, or "beta" for Beta Wikisource).


<!--T:3-->
== For books ==
This page explains how to configure a Wikisource project in order to get the best results from WS Export. For most of these operations you will need admin access.
===Microformat===
When exporting a page, WSexport looks for the page's metadata (title, author, year, etc.) using the [[Wikisource:Microformat|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 [https://fr.wikisource.org/w/index.php?title=Mod%C3%A8le:Proofreadpage_header_template&action=edit fr:Modèle:Proofreadpage header template].


== History == <!--T:4-->
===Hide unwanted elements===
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 '''<code>class="ws-noexport"</code>''' to each HTML element that you want to be excluded from the export.


<!--T:5-->
== For the wiki ==
The tool was created by user <tvar name=1>[[:fr:User:Tpt|Tpt]]</tvar> for French Wikisource, but it's also available for the other Wikisource subdomains.
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


== For books == <!--T:6-->
===CSS===
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.


=== Microformat === <!--T:7-->
===Translation===
</translate>
To translate the interface's messages, create [[MediaWiki:Wsexport i18n.ini]] (follow [https://github.com/wsexport/tool/blob/master/book/i18n.ini this file] as example).
<translate><!--T:8--> When exporting a page, WS Export looks for the page's metadata (title, author, year, etc.) using the [[Wikisource:Microformat|Microformat]] specification.</translate> <translate><!--T:9--> 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.</translate> <translate><!--T:10--> You can find an example at the bottom of [<tvar name=url>https://fr.wikisource.org/w/index.php?title=Mod%C3%A8le:Proofreadpage_header_template&action=edit</tvar> fr:Modèle:Proofreadpage header template].</translate>


<translate>
===About===
=== Hide unwanted elements === <!--T:11-->
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.


<!--T:12-->
==Direct link from Wikisource pages==
You may want to hide certain elements in your EPUBs, like the header box, or the page numbers generated by <tvar name=1>[[MediaWiki:Proofreadpage pagenum template]]</tvar>. Assign '''<tvar name=2><code>class="ws-noexport"</code></tvar>''' to each HTML element that you want to be excluded from the export.
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 <code>lang=fr</code> with the language code for your subdomain.
<syntaxhighlight lang="javascript" enclose="pre">
// 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');
} );
}
</syntaxhighlight>


== For the wiki == <!--T:13-->
Or you can specify a category of pages "Ready for export":
<syntaxhighlight lang="javascript" enclose="pre">
// 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'
);
} );
}
</syntaxhighlight>


<!--T:14-->
==Bug reports==
WS Export uses a cache system, you must follow this URL when you change the following files: <tvar name=1>https://ws-export.wmcloud.org/?refresh=true&lang=YOUR_LANG_CODE</tvar>
You can report any bug you find on the discussion page or on the French page [[:fr:Wikisource:Wsexport]].


=== CSS === <!--T:15-->
==See also==
*[https://github.com/wsexport Source code on github.com]


<!--T:16-->
==Known bugs==
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. If you want to keep certain content from appearing in the exported text, you can use the CSS class <tvar name=1><code>ws-noexport</code></tvar>. CSS style from the book's <code>styles.css</code> page in the index namespace is also exported in the ePub file.
* The internal links don't work if there is a redirection in Wikisource.


=== Translation === <!--T:17-->
[[ca:Ajuda:WSexport]]

[[fr:Wikisource:Wsexport]]
<!--T:18-->
To translate the interface's messages, see [[translatewiki:Translating:Wikisource Export]].

=== About === <!--T:19-->
</translate>
<translate><!--T:20--> You can provide your about file by creating <tvar name=1>[[MediaWiki:Wsexport about]]</tvar> (follow <tvar name=2>[[:fr:MediaWiki:Wsexport about]]</tvar> as example).</translate> <translate><!--T:21--> The list of contributors, bots excepted, is included by the <tvar name=1>"{CONTRIBUTORS}"</tvar> tag. For the bots list, use <tvar name=2>"{BOT-CONTRIBUTORS}"</tvar> tag.</translate>

<translate>

== Bug reports == <!--T:25-->
</translate>
<translate><!--T:26--> Please report any issues via Phabricator, with the project tag <tvar name=tag>[[phabricator:tag/ws_export|#ws_export]]</tvar>.</translate> <translate><!--T:27--> Alternatively, you can add them on the talk page here.</translate>

<translate>
== Subpages == <!--T:28-->

<!--T:29-->
The current algorithm used in WS Export to extract the table of content (TOC) of the book (and so, include the other pages of the book) is:
</translate>

*<translate><!--T:30--> 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)</translate>
*<translate><!--T:31--> if such nodes are found, use the list of links in them to build the TOC</translate>
*<translate><!--T:32--> if not look for all links to subpages and use the returned list as TOC</translate>

<translate>
== See also == <!--T:33-->
</translate>
*[https://gitlab.wikimedia.org/toolforge-repos/wsexport <translate><!--T:34--> Source code on GitLab</translate>]
* <translate><!--T:35--> Dumps of log SQL can be found at <tvar name=1>https://ws-export.wmcloud.org/logs/</tvar></translate>
* <translate><!--T:36--> Deployment documentation: <tvar name=1>[[wikitech:Nova Resource:Wikisource]]</tvar></translate>

<translate>
== Known bugs == <!--T:37-->
</translate>
* <translate><!--T:38--> The internal links don't work if there is a redirection in Wikisource.</translate>

{{Interwiki|Q20354561}}

[[Category:Wikisource]]

Latest revision as of 23:57, 20 August 2025

WS Export is a tool for exporting Wikisource's texts in EPUB, PDF and other file formats.

It can be used directly from its page on Toolforge: https://ws-export.wmcloud.org/ (for texts in all languages; use "www" for Multilingual Wikisource, or "beta" for Beta Wikisource).

This page explains how to configure a Wikisource project in order to get the best results from WS Export. For most of these operations you will need admin access.

History

[edit]

The tool was created by user Tpt for French Wikisource, but it's also available for the other Wikisource subdomains.

For books

[edit]

Microformat

[edit]

When exporting a page, WS Export 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]

WS Export uses a cache system, you must follow this URL when you change the following files: https://ws-export.wmcloud.org/?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. If you want to keep certain content from appearing in the exported text, you can use the CSS class ws-noexport. CSS style from the book's styles.css page in the index namespace is also exported in the ePub file.

Translation

[edit]

To translate the interface's messages, see translatewiki:Translating:Wikisource Export.

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.


Bug reports

[edit]

Please report any issues via Phabricator, with the project tag #ws_export. Alternatively, you can add them on the talk page here.

Subpages

[edit]

The current algorithm used in WS Export 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.