### Install Debian/Ubuntu Prerequisites Source: https://www.openzim.org/wiki/Wiki2html Installs necessary packages on Debian-based systems like Ubuntu for mediawiki setup. ```bash sudo apt-get install apache2 php5 php5-mysql mysql-server php5-xsl php5-tidy php5-cli subversion gij bzip2 ``` -------------------------------- ### Example Program Start Notice Source: https://www.openzim.org/wiki/Special%3AVersion/License/Iframe This notice should be displayed when a program starts in interactive mode, providing copyright, warranty, and redistribution information. ```text Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Start linking an account from 'Example' Source: https://www.openzim.org/wiki/Special%3AApiHelp/linkaccount Initiates the process of linking an account from a specified provider. Requires a provider name, a return URL, and a CSRF token. ```api api.php?action=linkaccount&provider=Example&linkreturnurl=http://example.org/&linktoken=123ABC ``` -------------------------------- ### Install CentOS/Fedora Prerequisites Source: https://www.openzim.org/wiki/Wiki2html Installs necessary packages on Red Hat-based systems like CentOS or Fedora for mediawiki setup. ```bash yum install httpd php php-mysql mysql-server mysql-client php-xml php-tidy php-cli subversion java-1.5.0-gcj bzip2 ``` -------------------------------- ### Query API Examples Source: https://www.openzim.org/wiki/Special%3AApiHelp/query Examples demonstrating how to use the query action with different parameters and modules. ```APIDOC ## Query API Examples ### Example 1: Fetch site info and revisions of `Main Page` ``` api.php?action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user|comment&continue= [open in sandbox] ``` ### Example 2: Fetch revisions of pages beginning with `API/` ``` api.php?action=query&generator=allpages&gapprefix=API/&prop=revisions&continue= [open in sandbox] ``` ``` -------------------------------- ### Query Site Info in JSON Format Source: https://www.openzim.org/wiki/Special%3AApiHelp/json Use this example to retrieve site information, including namespaces, formatted as JSON. This is a common starting point for interacting with the MediaWiki API. ```json api.php?action=query&meta=siteinfo&siprop=namespaces&format=json ``` -------------------------------- ### Zimdump Examples Source: https://www.openzim.org/wiki/ZimDump Illustrates common use cases for zimdump, such as printing file info, listing articles, finding specific articles by title or URL, and dumping content. These examples demonstrate practical application of the tool's options. ```bash zimDump -F wikipedia.zim ``` ```bash zimDump -l wikipedia.zim ``` ```bash zimDump -f Auto -i wikipedia.zim ``` ```bash zimDump -f Auto -d wikipedia.zim ``` ```bash zimDump -f Auto -l wikipedia.zim ``` ```bash zimDump -f Auto -l -i -v wikipedia.zim ``` ```bash zimDump -o 123159 -l -i wikipedia.zim ``` -------------------------------- ### JSON Format Example Source: https://www.openzim.org/wiki/Special%3AApiHelp/json This example demonstrates how to request site information in JSON format using the MediaWiki API. ```APIDOC ## GET api.php ### Description Retrieves query results in JSON format. ### Method GET ### Endpoint /api.php ### Parameters #### Query Parameters - **action** (string) - Required - The action to perform (e.g., 'query'). - **meta** (string) - Required - The metadata to retrieve (e.g., 'siteinfo'). - **siprop** (string) - Required - Specific site information properties to retrieve (e.g., 'namespaces'). - **format** (string) - Required - The desired output format, set to 'json'. - **callback** (string) - Optional - Wraps the output into a given function call. - **utf8** (boolean) - Optional - Encodes most non-ASCII characters as UTF-8. Default when formatversion is not '1'. - **ascii** (boolean) - Optional - Encodes all non-ASCII using hexadecimal escape sequences. Default when formatversion is '1'. - **formatversion** (integer) - Optional - Output formatting version. One of: 1, 2, latest. Default: 1 ### Request Example ``` api.php?action=query&meta=siteinfo&siprop=namespaces&format=json ``` ### Response #### Success Response (200) - **query** (object) - Contains the requested site information. - **namespaces** (object) - Information about namespaces. #### Response Example ```json { "batchcomplete": "", "query": { "namespaces": { "-2": { "id": -2, "name": "$1", "canonical": "MediaWiki:", "defaultfor": "", "content": null, "isdefault": null }, "0": { "id": 0, "name": "", "canonical": null, "defaultfor": "", "content": true, "isdefault": true } } } } ``` ``` -------------------------------- ### Retrieve Site Info in PHP Format Source: https://www.openzim.org/wiki/Special%3AApiHelp/php Use this example to get MediaWiki site information, specifically namespaces, formatted as PHP. Ensure you are using the correct API endpoint. ```api api.php?action=query&meta=siteinfo&siprop=namespaces&format=php ``` -------------------------------- ### Query with PHP format Source: https://www.openzim.org/wiki/Special%3AApiHelp/php This example demonstrates how to retrieve site information in PHP format using the MediaWiki API. ```APIDOC ## GET api.php ### Description Retrieves query results in PHP format. ### Method GET ### Endpoint /api.php ### Parameters #### Query Parameters - **action** (string) - Required - The action to perform (e.g., query). - **meta** (string) - Required - The metadata to retrieve (e.g., siteinfo). - **siprop** (string) - Required - The specific site information properties to retrieve (e.g., namespaces). - **format** (string) - Required - The desired output format. Must be 'php'. - **formatversion** (integer) - Optional - Specifies the format version. Accepts 1, 2, or latest. Defaults to 1. ### Request Example ``` api.php?action=query&meta=siteinfo&siprop=namespaces&format=php ``` ### Response #### Success Response (200) - **query** (object) - Contains the query results. - **namespaces** (object) - Information about namespaces. #### Response Example ```json { "batchcomplete": "", "query": { "namespaces": { "-2": { "id": -2, "case": "case-sensitive", "content": "" }, "-1": { "id": -1, "case": "case-sensitive", "content": "" } // ... other namespaces } } } ``` ``` -------------------------------- ### Get query result in RAW format Source: https://www.openzim.org/wiki/Special%3AApiHelp/rawfm Use this example to retrieve query results in the raw format. This module requires read rights. ```api api.php?action=query&meta=siteinfo&siprop=namespaces&format=rawfm ``` -------------------------------- ### Start Login Process Source: https://www.openzim.org/wiki/Special%3AApiHelp/clientlogin Initiates the login process for a user by providing username, password, a return URL, and a login token. This is the first step in a standard login flow. ```api api.php?action=clientlogin&username=Example&password=ExamplePassword&loginreturnurl=http://example.org/&logintoken=123ABC ``` -------------------------------- ### Create Mediawiki Database Source: https://www.openzim.org/wiki/Wiki2html Creates a new database named 'wikidb' with binary character set for mediawiki. ```bash echo "CREATE DATABASE wikidb DEFAULT CHARACTER SET binary;" | mysql -u root ``` -------------------------------- ### Find pages beginning with 'Te' Source: https://www.openzim.org/wiki/Special%3AApiHelp/opensearch This example demonstrates how to find pages whose titles start with 'Te' using the opensearch action. It requires read rights and uses the default namespace. ```api api.php?action=opensearch&search=Te ``` -------------------------------- ### Dump HTML Content with Range Source: https://www.openzim.org/wiki/Wiki2html This command dumps HTML content for a specified range of page IDs. It's useful for multicore setups where work can be split using start and end IDs. Be aware that earlier articles generally take longer to process. ```php php extensions/DumpHTML/dumpHTML.php -d /folder/to/dump -s -e --interlang ``` -------------------------------- ### Query Site Info in XML Format Source: https://www.openzim.org/wiki/Special%3AApiHelp/xml Use this example to retrieve site information, specifically namespaces, formatted as XML. Ensure the 'format' parameter is set to 'xml'. ```api api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml ``` -------------------------------- ### Namespace Start and Count Record Structure Source: https://www.openzim.org/wiki/Zeno_File_Format Defines the record structure for storing the start index and count of articles within a specific namespace. The start index is 1-based. ```Pascal RNamespaceStartCount = record rNamespaceStart: integer; // Startindex ist 1, nicht 0 rNamespaceCount: integer; end; RNamespaceStartCountArray = array [TLibNamespaceChar] of RNamespaceStartCount; ``` -------------------------------- ### Reset All and Change Specific Preferences Source: https://www.openzim.org/wiki/Special%3AApiHelp/options This example first resets all preferences and then sets specific ones like 'skin' and 'nickname'. Note the use of 'optionname' and 'optionvalue' for individual settings. ```api api.php?action=options&reset=&change=skin=monobook&optionname=nickname&optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC ``` -------------------------------- ### Interactive Program Notice (GPL) Source: https://www.openzim.org/wiki/Special%3AVersion/License/Gadgets This notice should be displayed by interactive programs when they start, informing users about warranty and redistribution conditions. ```text Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Get Page ID Count Source: https://www.openzim.org/wiki/Wiki2html Use this command to get the maximum page ID from the database, which can be used for estimations on how to split work over multiple cores. ```bash echo "SELECT MAX(page_id) FROM page" | mysql -u root wikidb -sN ``` -------------------------------- ### Remove Linked Account Example Source: https://www.openzim.org/wiki/Special%3AApiHelp/unlinkaccount This example demonstrates how to remove a linked third-party account using the unlinkaccount module. Ensure you have a valid authentication request ID and a CSRF token. ```api api.php?action=unlinkaccount&request=FooAuthenticationRequest&token=123ABC ``` -------------------------------- ### Remove Authentication Data Example Source: https://www.openzim.org/wiki/Special%3AApiHelp/removeauthenticationdata This example demonstrates how to remove authentication data for the current user using the `removeauthenticationdata` action. It requires a valid `request` ID and a 'csrf' `token`. ```api api.php?action=removeauthenticationdata&request=FooAuthenticationRequest&token=123ABC ```