c3d2-wiki/Ruby-MediaWiki%2FDocumentat...

369 lines
7.7 KiB
Plaintext
Raw Normal View History

2005-12-14 01:09:56 +01:00
=Ruby-MediaWiki Documentation=
==MediaWiki==
2005-12-14 01:15:17 +01:00
2006-06-11 00:47:44 +02:00
Logger is required by article.rb
2006-06-10 11:48:21 +02:00
===MediaWiki::dotfile(myrealm=nil,mywiki=nil)===
2005-12-14 02:24:53 +01:00
2005-12-14 01:09:56 +01:00
dotfile function reads the user's MediaWiki config and creates a Wiki instance.
The filename is determined by the environment variable MEDIAWIKI_RC or defaults to ~/.mediawikirc .
2006-06-10 11:48:21 +02:00
A configured wiki can be chosen with the MEDIAWIKI_WIKI environment variable, by the option mywiki or defaults to the wiki pointed by default.
2005-12-14 01:09:56 +01:00
A robot may set [myrealm] to retrieve a second result output: a section with this name in the current wiki's configuration file for configuration of specific robot tasks.
2005-12-14 01:15:17 +01:00
2006-06-10 11:57:25 +02:00
===MediaWiki::logger()===
2005-12-14 01:09:56 +01:00
==MediaWiki::Article==
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Inherited from '''Object'''
2005-12-14 01:09:56 +01:00
The Article class represents MediaWiki articles.
2005-12-15 01:32:13 +01:00
===MediaWiki::Article#name (RW)===
Article name, will be refreshed upon Article#reload
2006-06-10 11:48:21 +02:00
===MediaWiki::Article#read_only (RW)===
this Article is read_only
2005-12-15 01:32:13 +01:00
===MediaWiki::Article#text (RW)===
Article text, will be set by Article#reload
2005-12-15 01:34:43 +01:00
===MediaWiki::Article::new(wiki, name, section = nil, load_text=true)===
2005-12-14 02:24:53 +01:00
Create a new Article instance
; wiki:
: [Wiki] instance to be used to theive the MiniBrowser
; name:
: [String] Article name
; section:
: [Fixnum] Optional article section number
; load_text:
: [Boolean] Invoke Article#reload to retrieve Article#text
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#delete(reason)===
2005-12-14 02:24:53 +01:00
2005-12-14 01:09:56 +01:00
Delete this article
2005-12-14 02:24:53 +01:00
; reason:
: [String] Delete reason
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#full_name()===
2005-12-15 01:32:13 +01:00
Return the full article name
This will only return @name, but may be overriden by descendants to include namespaces.
; result:
: [String] Full name
2006-01-21 20:30:18 +01:00
===MediaWiki::Article#parse(html)===
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#protect(reason, moves_only=false)===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Protect this article
2005-12-14 02:24:53 +01:00
; reason:
: [String] Protect reason
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#reload()===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Reload Article#text, should be done by Article#initialize.
2005-12-14 01:15:17 +01:00
2006-01-21 20:30:18 +01:00
===MediaWiki::Article#submit(summary, minor_edit=false, watch_this=false, retries=10)===
2005-12-14 02:24:53 +01:00
2005-12-14 01:09:56 +01:00
Push the '''Submit''' button
Send the modified Article#text to the MediaWiki.
2005-12-14 02:24:53 +01:00
; summary:
: [String] Change summary
; minor_edit:
: [Boolean] This is a Minor Edit
; watch_this:
: [Boolean] Watch this article
2006-06-10 11:48:21 +02:00
===MediaWiki::Article#to_rexml( html )===
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#unprotect(reason)===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Unprotect this article
2005-12-14 02:24:53 +01:00
; reason:
: [String] Unprotect reason
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#what_links_here()===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
What articles link to this article?
2005-12-14 02:24:53 +01:00
; result:
: [Array] of [String] Article names
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#xhtml()===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Get the XHTML, will invoke Article#xhtml_reload if not already cached
2005-12-14 02:24:53 +01:00
; result:
: [REXML::Element] html root element
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::Article#xhtml_reload()===
2005-12-14 01:15:17 +01:00
2005-12-14 02:24:53 +01:00
Reload the xhtml, will be automatically done by Article#xhtml if not already cached.
2005-12-14 01:09:56 +01:00
2005-12-14 01:15:17 +01:00
2005-12-14 01:10:50 +01:00
==MediaWiki::Category==
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Inherited from '''Article'''
2005-12-14 01:09:56 +01:00
The Category class represents MediaWiki categories.
2005-12-15 01:34:43 +01:00
===MediaWiki::Category#articles()===
2005-12-14 02:24:53 +01:00
2005-12-15 01:32:13 +01:00
Which articles belong to this category?
2005-12-14 02:24:53 +01:00
2005-12-15 01:32:13 +01:00
; result:
: [Array] of [String] Article names
2005-12-14 02:24:53 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::Category#full_name()===
2005-12-14 02:24:53 +01:00
2005-12-15 01:32:13 +01:00
This returns the full article name prefixed with "Category:" instead of the name, which should not carry a prefix.
2005-12-14 01:09:56 +01:00
2005-12-14 01:15:17 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::Category#reload()===
2005-12-14 01:09:56 +01:00
2005-12-15 01:32:13 +01:00
Calls the reload function of the super-class (Article#reload) but removes the prefix (namespace) then.
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Use to full_name to obtain the name with namespace.
2005-12-14 01:09:56 +01:00
2005-12-14 01:15:17 +01:00
2005-12-14 01:10:50 +01:00
==MediaWiki::MiniBrowser==
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Inherited from '''Object'''
The MiniBrowser is used to perform GET and POST requests over HTTP and HTTPS, supporting:
* HTTP-Auth encoding in URLs (proto://user:password@host/...)
* Cookie support
* HTTP Redirection (max. 10 in a row)
All interaction with MiniBrowser is normally done by MediaWiki::Wiki.
2006-06-10 11:57:25 +02:00
===MediaWiki::MiniBrowser::new(url)===
2005-12-15 01:32:13 +01:00
Initialize a MiniBrowser instance
; url:
: [URI::HTTP] or [URI::HTTPS]
2005-12-15 01:34:43 +01:00
===MediaWiki::MiniBrowser#add_cookie(cookies)===
2005-12-15 01:32:13 +01:00
Add cookies to the volatile cookie cache
; cookies:
: [Array]
2005-12-14 02:24:53 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::MiniBrowser#cookies()===
2005-12-14 02:24:53 +01:00
2005-12-15 01:32:13 +01:00
Get the cookie cache in a serialized form ready for HTTP.
; result:
: [String]
2005-12-14 01:15:17 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::MiniBrowser#get_content(url)===
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Perform a GET request
2005-12-14 02:24:53 +01:00
2005-12-15 01:32:13 +01:00
This method accepts 10 HTTP redirects at max.
2005-12-14 02:24:53 +01:00
2005-12-15 01:32:13 +01:00
; url:
: [String]
; result:
: [String] Document
2005-12-15 01:34:43 +01:00
===MediaWiki::MiniBrowser#post_content(url, data)===
2005-12-15 01:32:13 +01:00
Perform a POST request
Will switch to MiniBrowser#get_content upon HTTP redirect.
; url:
: [String]
; data:
: [Hash] POST data
; result:
: [String] Document
2005-12-14 01:15:17 +01:00
2006-06-10 11:48:21 +02:00
==MediaWiki::SpecialPage==
Inherited from '''Article'''
The SpecialPage class represents MediaWiki special pages.
===MediaWiki::SpecialPage#xhtml_reload()===
Reload the xhtml, will be automatically done by SpecialPage#xhtml if not already cached.
2005-12-14 01:09:56 +01:00
==MediaWiki::Table==
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Inherited from '''Object'''
2005-12-14 02:24:53 +01:00
2006-01-21 20:30:18 +01:00
The MediaWiki::Table class is used to parse existing tables from mediawiki articles and to create tables from arrays. Currently only the mediawiki pipe syntax is supported.
2005-12-15 01:32:13 +01:00
===MediaWiki::Table#data (RW)===
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
===MediaWiki::Table#header (RW)===
===MediaWiki::Table#header_style (RW)===
===MediaWiki::Table#row_style (RW)===
2006-01-21 20:30:18 +01:00
===MediaWiki::Table#style (RW)===
2005-12-15 01:32:13 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::Table::new( data = [], header = [] )===
2005-12-15 01:32:13 +01:00
2006-01-21 20:30:18 +01:00
Initialize a Table instance
; data:
: [Array] 2-dimensional Array with the tables and cells
; header:
: [Array] 1-dimensional Array used as header
2005-12-15 01:32:13 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::Table::parse( text )===
2005-12-14 01:15:17 +01:00
2006-01-21 20:30:18 +01:00
Parses the wiki markup of a table and returns a 2-dimensional array representing rows and columns of the table. Currently only the mediawiki pipe syntax is supported.
2005-12-14 01:15:17 +01:00
2006-01-21 20:30:18 +01:00
; text:
: [String] String to parse
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
2005-12-15 01:34:43 +01:00
===MediaWiki::Table#text()===
2005-12-14 02:24:53 +01:00
2006-01-21 20:30:18 +01:00
Creates the mediawiki markup to be put in an article
2005-12-14 02:24:53 +01:00
2005-12-14 01:09:56 +01:00
==MediaWiki::Wiki==
2005-12-14 01:15:17 +01:00
2005-12-15 01:32:13 +01:00
Inherited from '''Object'''
===MediaWiki::Wiki#browser (R)===
The MiniBrowser instance used by this Wiki. This must be readable as it's used by Article and Category to fetch themselves.
2006-06-10 11:48:21 +02:00
===MediaWiki::Wiki::new(url, user = nil, password = nil, loglevel = Logger::WARN)===
2005-12-14 02:24:53 +01:00
Initialize a new Wiki instance.
; url:
: [String] URL-Path to index.php (without index.php), may containt <em>user:password</em> combination.
; user:
: [String] If not nil, log in with that MediaWiki username (see Wiki#login)
; password:
: [String] If not nil, log in with that MediaWiki password (see Wiki#login)
2006-06-10 11:48:21 +02:00
; loglevel:
: [Integer] Loglevel, default is to log all messages &gt;= Logger::WARN = 2
2005-12-14 02:24:53 +01:00
2006-06-11 00:47:44 +02:00
===MediaWiki::Wiki#allpages(namespace_id=nil)===
2005-12-14 02:24:53 +01:00
2005-12-14 01:09:56 +01:00
Returns the pages listed on "Special:Allpages"
2006-06-11 00:47:44 +02:00
TODO: Handle big wikis with chunked Special:Allpages
; namespace_id:
: Optional namespace for article index (see Wiki#namespace_ids to retrieve id)
2005-12-14 02:24:53 +01:00
; result:
: [Array] of [String] Articlenames
2005-12-15 01:34:43 +01:00
===MediaWiki::Wiki#article(name, section = nil)===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Return a new Article instance with given name, will be constructed with [self] (for MiniBrowser usage)
2005-12-14 02:24:53 +01:00
; name:
: [String] Article name
; section:
: [Fixnum] Optional section number
2005-12-15 01:34:43 +01:00
===MediaWiki::Wiki#article_url(name, section = nil)===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Construct the URL to a specific article
Uses the [url] the Wiki instance was constructed with, appends "index.php", the name parameter and, optionally, the section.
Often called by Article, Category, ...
2005-12-14 02:24:53 +01:00
; name:
: [String] Article name
; section:
: [Fixnum] Optional section number
2005-12-15 01:34:43 +01:00
===MediaWiki::Wiki#category(name)===
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
Return a new Category instance with given name, will be constructed with [self] (for MiniBrowser usage)
2005-12-14 02:24:53 +01:00
; name:
: [String] Category name (to be prepended with "Category:")
2005-12-14 01:15:17 +01:00
2005-12-14 01:09:56 +01:00
2006-06-10 11:48:21 +02:00
===MediaWiki::Wiki#full_article_url(name, section=nil)===
2005-12-15 01:34:43 +01:00
===MediaWiki::Wiki#login( username, password )===
2005-12-14 01:09:56 +01:00
2005-12-14 02:24:53 +01:00
Log in into MediaWiki
2005-12-14 01:09:56 +01:00
2005-12-14 02:24:53 +01:00
This is '''not''' HTTP authentication (put HTTP-Auth into [url] of Wiki#initialize!)
2005-12-14 01:15:17 +01:00
2005-12-14 02:24:53 +01:00
; user:
: [String] MediaWiki username
; password:
: [String] MediaWiki password
2005-12-14 01:09:56 +01:00
2005-12-14 02:24:53 +01:00
May raise an exception if cannot authenticate
2006-06-11 00:47:44 +02:00
===MediaWiki::Wiki#namespace_ids()===
Retrieve all namespaces and their IDs, which could be used for Wiki#allpages
; result:
: [Hash] String =&gt; Fixnum