Extension:ApiMagicWord
From MediaWiki.org
|
Release status: experimental |
|||
|---|---|---|---|
| Implementation | Parser function | ||
| Description | ApiMagicWord extension provide a wiki text access to enabled Application Programming Interfaces (API) of MediaWiki Web sites. | ||
| Author(s) | Eric LarcherTalk | ||
| Last Version | 0.1b | ||
| License | GPL | ||
| Download | no link | ||
|
|||
|
check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
With a simple magic word #api, ApiMagicWord extension enabled wiki text access to the (enabled :-) Application Programming Interfaces (API) of MediaWiki Web sites.
By this way, it permits to interact, to get and post data from within each wiki page, with all the contents of those sites .
From within each wiki page with all the contents of the local site included, if its API is enabled.
[edit] Usage
Here, you can find some examples of the syntax call to http://fr.wikipedia.org/w/api.php (the API of the french wikipedia) from another Mediawiki wiki:
Note 1 : That suppose that, in the local wiki, wfrapi was declared as an interwikilink for http://fr.wikipedia.org/w/api.php?action=$1.
Note 2 : ApiMagicWord suppose too a simple relation between interwikilink to index.php and interwikilink to api.php : if wfrapi is an interwikilink for http://fr.wikipedia.org/w/api.php?action=$1, wfr is (one of) the interwikilink for http://fr.wikipedia.org/w/index.php?title=$1.
- {{#api:wfrapi|action=query|list=recentchanges}}
- {{#api:wfrapi|action=query|list=recentchanges|rcprop=user{{!}}comment{{!}}flags{{!}}timestamp{{!}}title{{!}}ids{{!}}sizes}}
- {{#api:wfrapi|action=login|lgname=Eric Larcher|lgpassword=...}}
- {{#api:wfrapi|action=logout}}
Remark :For meaning of {{!}}, see Template:!.
[edit] To format the results
Templates can be used to filter and/or format items send to the current wiki page :
Remark : of course, for a correct rendering, the templates have to bee create before their usage.
- {{#api:wfrapi|action=login|lgname=Eric Larcher|lgpassword=...|template=Api/login}}
- {{#api:wfrapi|action=edit|title=Utilisateur:Eric Larcher/callintertrans|text=encore un nouvel essai api|summary=test api||notbot/template=Api/edit}}
- {{#api:wfrapi|action=query|list=recentchanges|template=Api/query/recentchanges}}
- {{#api:wfrapi|action=query|list=recentchanges|template=Api/query/recentchanges2|rcprop=user{{!}}comment{{!}}flags{{!}}timestamp{{!}}title{{!}}ids{{!}}sizes}}
- {{#api:|action=logout|template=Api/Void}}
Tips : As in the line above, it's possible to use an empty template to avoid all trace in the rendered wiki text.
Others ways, are :
- when the result is not a list of more than one list of results :
{{Api/query/anothertemplateapproach|{{subst:#api:wfrapi|action=query|list=recentchanges|rclimit=1}}}}.
- (since version 0.1c) when the result is a list of one or more list of results :
{{#arraymap:{{#api:wfrapi|action=query|list=recentchanges|rclimit=10|delimiter=&&}}|&&|x|{{Api/query/recentchanges|x}}|</tr><tr>}}, if for example we want to build a table.
Remark : Of course, for that,#arraymapshould be active. See Extension:Semantic Forms.
[edit] Access to the Api of a local Mediawiki wiki
For access to the Api of the local Mediawiki wiki, no need to specify an interwikilink :
- {{#api:|action=query|list=recentchanges|template=Api/query/recentchanges}}
- {{#api:|action=logout|template=Void}}
- {{#api:|action=edit|title=Utilisateur:Eric Larcher/callintertrans|text=je recommence encore encore un nouvel essai api|notbot|summary=test api}}
[edit] ToDo
A lot of work !! Every help is welcome !
[edit] Download instructions
Please cut and paste the codes found in subpages :
- ApiMagicWord.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord.php. - ApiMagicWord_body.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord_body.php. - ApiMagicWord.i18n.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord.i18n.php. - ApiMagicWord.i18n.magic.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord.i18n.magic.php. - customwikibot.classes.php : place it in
$IP/extensions/ApiMagicWord/customwikibot.classes.php.
Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
#add configuration parameters here #setup user rights here require_once("$IP/extensions/ApiMagicWord/ApiMagicWord.php");
[edit] Configuration parameters
If $wgApiMagicWordUseNoPrefixHash is set to true, then magic word api is without the preceding hash symbol, and more like a built-in function.
[edit] User rights
Have to be implemented.
[edit] Code
See :
- Extension:ApiMagicWord/ApiMagicWord.php
- Extension:ApiMagicWord/ApiMagicWord_body.php
- Extension:ApiMagicWord/ApiMagicWord.i18n.php
- Extension:ApiMagicWord/ApiMagicWord.i18n.magic.php
- Extension:ApiMagicWord/customwikibot.classes.php
[edit] See also
- ClueBot/Source
- this Sandbox for testing purpose.