Difference between revisions of "Tools/en"

From Kiwix
Jump to navigation Jump to search
(Perl module prerequisites)
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Translations}}
{{Translations}}


The Kiwix tools are a set of scripts (mostly in Perl) aiming to help creating content usable by Kiwix.
''This tools are deprecated. Although they may work under certain conditions, we don't provide support for them.''
 
The Kiwix tools are a set of scripts (mostly in Perl) aiming to help creating content usable by Kiwix. Current development code can be found at:
  <nowiki>svn co http://kiwix.svn.sourceforge.net/svnroot/kiwix/tools/ kiwix-tools</nowiki>


Kiwix is primarily designed as a tool to publish copies of Wikipedia, but every effort is made to ensure it would also be useful for:
Kiwix is primarily designed as a tool to publish copies of Wikipedia, but every effort is made to ensure it would also be useful for:
Line 66: Line 69:
* Log::Log4perl
* Log::Log4perl
* Getargs::Long
* Getargs::Long
=== Debian/Ubuntu dependencies ===
<pre>sudo apt-get install liblog-log4perl-perl libdata-dumper-simple-perl libxml-simple-perl
libxml-libxml-perl libarray-printcols-perl libgetargs-long-perl
liburi-perl libdata-dumper-simple-perl libhtml-linkextractor-perl
libhtml-parser-perl libdbd-pg-perl</pre>


==Usage==
==Usage==
Here is a list of available scripts (many of them are specific to Mediawiki):
Here is a list of available scripts (many of them are specific to Mediawiki):
===Mediawiki Maintenance===
===Mediawiki Maintenance===
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/backupMediawikiInstall.pl?view=log backupMediawikiInstall.pl] creates a tgz archive of a complete existing Mediawiki installation (code + resources + database).
* {{ScriptTool|backupMediawikiInstall.pl}} creates a tgz archive of a complete existing Mediawiki installation (code + resources + database).
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/installMediawiki.pl?view=log installMediawiki.pl] brings up an instance of Mediawiki from source code without human intervention. This actually simulates the manual Mediawiki installation process.
* {{ScriptTool|installMediawiki.pl}} brings up an instance of Mediawiki from source code without human intervention. This actually simulates the manual Mediawiki installation process.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/resetMediawikiDatabase.pl?view=log resetMediawikiDatabase.pl] empties a local instance of Mediawiki of all pages.
* {{ScriptTool|resetMediawikiDatabase.pl}} empties a local instance of Mediawiki of all pages.


===Mirroring Tools===
===Mirroring Tools===
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/buildHistoryFile.pl?view=log buildHistoryFile.pl] given a list of articles and an online Mediawiki site, obtains complete histories of each page on the list.
* {{ScriptTool|buildHistoryFile.pl}} given a list of articles and an online Mediawiki site, obtains complete histories of each page on the list.
** [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/extractContributorsFromHistoryFile.pl?view=log extractContributorsFromHistoryFile.pl] extracts a list of authors from the histories obtained by the buildHistoryFile.pl script.
** {{ScriptTool|extractContributorsFromHistoryFile.pl}} extracts a list of authors from the histories obtained by the buildHistoryFile.pl script.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/buildContributorsHtmlPages.pl?view=log buildContributorsHtmlPages.pl] given a template and a list of authors, builds a custom set of HTML pages containing all of the authors on the list.
* {{ScriptTool|buildContributorsHtmlPages.pl}} given a template and a list of authors, builds a custom set of HTML pages containing all of the authors on the list.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/checkMediawikiPageCompleteness.pl?view=log checkMediawikiPageCompleteness.pl] check if the local copies of pages from an online Mediawiki site are complete, i.e. have no dependencies (template files, multimedia resources, etc.) missing.
* {{ScriptTool|checkMediawikiPageCompleteness.pl}} check if the local copies of pages from an online Mediawiki site are complete, i.e. have no dependencies (template files, multimedia resources, etc.) missing.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/checkPageExistence.pl?view=log checkPageExistence.pl] given a list of page titles  and an online Mediawiki site, checks whether such pages exist in it.  This can be handy, for example, to see what pages have been replicated.
* {{ScriptTool|checkPageExistence.pl}} given a list of page titles  and an online Mediawiki site, checks whether such pages exist in it.  This can be handy, for example, to see what pages have been replicated.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/checkRedirects.pl?view=log checkRedirects.pl] checks if there are no pages redirecting to non-existent pages (i.e. broken redirects).  Eventually, it should also check against pages redirecting to each other.
* {{ScriptTool|checkRedirects.pl}} checks if there are no pages redirecting to non-existent pages (i.e. broken redirects).  Eventually, it should also check against pages redirecting to each other.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/listAllImages.pl?view=log listAllImages.pl] lists all images of an online Mediawiki site.
* {{ScriptTool|listAllImages.pl}} lists all images of an online Mediawiki site.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/listAllPages.pl?view=log listAllPages.pl] lists all pages in an online Mediawiki site.
* {{ScriptTool|listAllPages.pl}} lists all pages in an online Mediawiki site.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/listCategoryEntries.pl?view=log listCategoryEntries.pl] lists the pages belonging to a category, recursively.
* {{ScriptTool|listCategoryEntries.pl}} lists the pages belonging to a category, recursively.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/listRedirects.pl?view=log listRedirects.pl] list page redirects in an online Mediawiki site.
* {{ScriptTool|listRedirects.pl}} list page redirects in an online Mediawiki site.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/mirrorMediawikiCode.pl?view=log mirrorMediawikiCode.pl] downloads the exact same version used by an online MediaWiki site;  this includes both Mediawiki code and Mediawiki extensions.
* {{ScriptTool|mirrorMediawikiCode.pl}} downloads the exact same version used by an online MediaWiki site;  this includes both Mediawiki code and Mediawiki extensions.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/mirrorMediawikiInterwikis.pl?view=log mirrorMediawikiInterwikis.pl] installs to a local Mediawiki site the InterWikis (cross-language links) exactly identical to an online Mediawiki site.
* {{ScriptTool|mirrorMediawikiInterwikis.pl}} installs to a local Mediawiki site the InterWikis (cross-language links) exactly identical to an online Mediawiki site.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/mirrorMediawikiPages.pl?view=log mirrorMediawikiPages.pl] copies a set of pages and their dependencies (template and multimedia resources) from an online Mediawiki site to a local Mediawiki site.
* {{ScriptTool|mirrorMediawikiPages.pl}} copies a set of pages and their dependencies (template and multimedia resources) from an online Mediawiki site to a local Mediawiki site.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/mirroring_tools/scripts/modifyMediawikiEntry.pl?view=log modifyMediawikiEntry.pl] removes, deletes, or replaces a list of pages from an online Mediawiki site.
* {{ScriptTool|modifyMediawikiEntry.pl}} removes, deletes, or replaces a list of pages from an online Mediawiki site.


===Dumping Tools===
===Dumping Tools===
Line 98: Line 107:
===ZIM Generation===
===ZIM Generation===
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/dumping_tools/scripts/buildZimFileFromDirectory.pl?view=log buildZimFileFromDirectory.pl] creates a ZIM file from a directory tree containing static HTML and other content files.
* [http://kiwix.svn.sourceforge.net/viewvc/kiwix/dumping_tools/scripts/buildZimFileFromDirectory.pl?view=log buildZimFileFromDirectory.pl] creates a ZIM file from a directory tree containing static HTML and other content files.
[[Category:Developer's Guide]]
== Virtual machine ==
We have prepared a VM to help people to make ZIM files from their HTML files. Download it [http://download.kiwix.org/dev/ZIMmakerVMv3.ova there]. Unix login/pass are root/kiwix and for postgres: postgres/kiwix. To build your ZIM file go to root/dumping_tools/scripts and use buildZimFileFromdirectory.pl.
== See also ==
* [[:File:Pediapress zim creation approach with mediawiki collection extension.jpg]]
* [[:File:Kiwix zim creation approach.jpg]]

Latest revision as of 23:06, 2 January 2014


This tools are deprecated. Although they may work under certain conditions, we don't provide support for them.

The Kiwix tools are a set of scripts (mostly in Perl) aiming to help creating content usable by Kiwix. Current development code can be found at:

 svn co http://kiwix.svn.sourceforge.net/svnroot/kiwix/tools/ kiwix-tools

Kiwix is primarily designed as a tool to publish copies of Wikipedia, but every effort is made to ensure it would also be useful for:

As the heart of Kiwix is the HTML rendering engine Gecko, the objective of Kiwix tools is to produce:

  • first, a coherent set of static HTML files and their needed resources: Stylesheets, JavaScript code, images, etc.
  • Only then, and from these static files, the tools create a file in the ZIM format (see below)

Storage

We call such a coherent set of multimedia content a dump or a corpus. These dumps can take many forms: previous versions of Kiwix used a simple directory layout; Moulinwiki used a file compressed with bzip2 and indexed in an SQLite database.

Today, Kiwix uses the ZIM format: a single file contains the entire dump,allowing fast access, high compression and configurability.

ZIM is an open, standard format created and maintained by the openZIM project, of which Kiwix is a founding member. ZIM is itself based on an older format (Zeno). Zeno was created by the Berlin publishing house Directmedia and served for the German Wikipedia released on CD-ROM. Later, the Zeno format had been abandoned, but we wanted to continue development. The future will tell whether this initiative will be successful, but the goal is to make a standard and thus simplify the problem for each of the storage dumps. It is, anyway, already the best free solution.

Generating ZIM Files From Wikis

The question of how to generate a dump is not a simple one. For several reasons, Kiwix has so far concentrated on generating dumps offering a selection of a given Wiki site, even if the publication of complete Wikipedia dumps remains a clear objective. The Kiwix tools are designed to assist in the selection of entries, replication of content from the online site in a local mirror, and then from the mirror to a ZIM file.

But this is not the only method to generate a dump: theoretically, this can be done in different ways. Here is a small inexhaustive list of approaches:

  • If you want to produce a complete dump, you can:
    • obtain a ready HTML dump provided by the wiki admin, as provided here by the Wikimedia Foundation for example.
    • mount a local mirror of the wiki, uploading the data (the content from another wiki) into the database and then generating an HTML dump by yourself. One can find such data for the Wikimedia Foundation here. In the case of a selection rather than a complete dump, you can also retrieve the data dynamically from the site (since the wiki is open source).
    • generate an HTML dump directly (by retrieving the HTML pages) using software such as Vacuum on the website (be careful not to abuse the remote Web site by inordinate amounts of traffic, though!).
  • If you want a partial dump, you must make a selection of items; once you have only the items you want, then the same process applies as with a complete dump.

There are certain constraints that should be taken into account. Here are the most important ones:

  • material resources (equipment, power) of the server
  • your own material resources
  • the storage space you have for the final result
  • how to make the selection if necessary.

Prerequisites

You'll need a bunch of Perl modules to run these scripts. Here is a list of modules one tester (User:Ijon) had to install given a plain Perl 5.10 installation on Ubuntu Linux. Your mileage may vary. Install them using CPAN (perl -MCPAN -e shell), CPANPLUS (cpanp(1)), or your distro's Perl bundling mechanism.

  • Array::PrintCols
  • Getargs::Long
  • HTML::Parser
  • HTML::Tagset
  • LWP
  • Log::Agent
  • Log::Log4perl
  • Term::Query
  • URI
  • XML::DOM
  • XML::NamespaceSupport
  • XML::Parser
  • XML::Parser::PerlSAX
  • XML::RegExp
  • XML::SAX
  • XML::SAX::Expat
  • XML::Simple

I managed to install these by installing this subset and allowing automatic installation of dependencies:

  • XML::Simple
  • XML::DOM
  • Term::Query
  • Array::PrintCols
  • Log::Log4perl
  • Getargs::Long

Debian/Ubuntu dependencies

sudo apt-get install liblog-log4perl-perl libdata-dumper-simple-perl libxml-simple-perl
libxml-libxml-perl libarray-printcols-perl libgetargs-long-perl
liburi-perl libdata-dumper-simple-perl libhtml-linkextractor-perl
libhtml-parser-perl libdbd-pg-perl

Usage

Here is a list of available scripts (many of them are specific to Mediawiki):

Mediawiki Maintenance

  • backupMediawikiInstall.pl creates a tgz archive of a complete existing Mediawiki installation (code + resources + database).
  • installMediawiki.pl brings up an instance of Mediawiki from source code without human intervention. This actually simulates the manual Mediawiki installation process.
  • resetMediawikiDatabase.pl empties a local instance of Mediawiki of all pages.

Mirroring Tools

  • buildHistoryFile.pl given a list of articles and an online Mediawiki site, obtains complete histories of each page on the list.
  • buildContributorsHtmlPages.pl given a template and a list of authors, builds a custom set of HTML pages containing all of the authors on the list.
  • checkMediawikiPageCompleteness.pl check if the local copies of pages from an online Mediawiki site are complete, i.e. have no dependencies (template files, multimedia resources, etc.) missing.
  • checkPageExistence.pl given a list of page titles and an online Mediawiki site, checks whether such pages exist in it. This can be handy, for example, to see what pages have been replicated.
  • checkRedirects.pl checks if there are no pages redirecting to non-existent pages (i.e. broken redirects). Eventually, it should also check against pages redirecting to each other.
  • listAllImages.pl lists all images of an online Mediawiki site.
  • listAllPages.pl lists all pages in an online Mediawiki site.
  • listCategoryEntries.pl lists the pages belonging to a category, recursively.
  • listRedirects.pl list page redirects in an online Mediawiki site.
  • mirrorMediawikiCode.pl downloads the exact same version used by an online MediaWiki site; this includes both Mediawiki code and Mediawiki extensions.
  • mirrorMediawikiInterwikis.pl installs to a local Mediawiki site the InterWikis (cross-language links) exactly identical to an online Mediawiki site.
  • mirrorMediawikiPages.pl copies a set of pages and their dependencies (template and multimedia resources) from an online Mediawiki site to a local Mediawiki site.
  • modifyMediawikiEntry.pl removes, deletes, or replaces a list of pages from an online Mediawiki site.

Dumping Tools

ZIM Generation

Virtual machine

We have prepared a VM to help people to make ZIM files from their HTML files. Download it there. Unix login/pass are root/kiwix and for postgres: postgres/kiwix. To build your ZIM file go to root/dumping_tools/scripts and use buildZimFileFromdirectory.pl.

See also