lib/media_wiki/gateway.rb in mediawiki-gateway-0.4.1 vs lib/media_wiki/gateway.rb in mediawiki-gateway-0.4.2
- old
+ new
@@ -185,25 +185,26 @@
end
# Get a list of matching page titles in a namespace
#
# [key] Search key, matched as a prefix (^key.*). May contain or equal a namespace, defaults to main (namespace 0) if none given.
+ # [options] Optional hash of additional options, eg. { 'apfilterredir' => 'nonredirects' }. See http://www.mediawiki.org/wiki/API:Allpages
#
# Returns array of page titles (empty if no matches)
- def list(key)
+ def list(key, options = {})
titles = []
apfrom = nil
key, namespace = key.split(":", 2).reverse
namespace = namespaces_by_prefix[namespace] || 0
begin
- form_data =
+ form_data = options.merge(
{'action' => 'query',
'list' => 'allpages',
'apfrom' => apfrom,
'apprefix' => key,
'aplimit' => @options[:limit],
- 'apnamespace' => namespace}
+ 'apnamespace' => namespace})
res, apfrom = make_api_request(form_data, '//query-continue/allpages/@apfrom')
titles += REXML::XPath.match(res, "//p").map { |x| x.attributes["title"] }
end while apfrom
titles
end
@@ -394,10 +395,10 @@
else
nil
end
end
- # Download _file_name_. Returns file contents. All options are passed to
+ # Download _file_name_ (without "File:" or "Image:" prefix). Returns file contents. All options are passed to
# #image_info however options['iiprop'] is forced to url. You can still
# set other options to control what file you want to download.
def download(file_name, options={})
options['iiprop'] = 'url'