Module: MediaWiki::Query::Lists::All

Included in:
MediaWiki::Query::Lists
Defined in:
lib/mediawiki/query/lists/all.rb

Instance Method Summary collapse

Instance Method Details

#get_all_blocks(limit = @query_limit_default) ⇒ Array<Fixnum>

Gets all block IDs on the wiki. It seems like this only gets non-IP blocks, but the MediaWiki docs are a bit unclear.

Parameters:

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<Fixnum>)

    All block IDs as strings.

See Also:

Since:

  • 0.8.0



74
75
76
77
78
79
80
81
82
# File 'lib/mediawiki/query/lists/all.rb', line 74

def get_all_blocks(limit = @query_limit_default)
  params = {
    list: 'blocks',
    bklimit: get_limited(limit),
    bkprop: 'id'
  }

  query_ary(params, 'blocks', 'id')
end

#get_all_categories(limit = @query_limit_default) ⇒ Array<String>

Gets all categories on the entire wiki.

Parameters:

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<String>)

    An array of all categories.

See Also:

Since:

  • 0.7.0



11
12
13
14
15
16
17
18
# File 'lib/mediawiki/query/lists/all.rb', line 11

def get_all_categories(limit = @query_limit_default)
  params = {
    list: 'allcategories',
    aclimit: get_limited(limit)
  }

  query_ary(params, 'allcategories', '*')
end

#get_all_deleted_files(limit = @query_limit_default) ⇒ Array<String>

Gets an array of all deleted or archived files on the wiki.

Parameters:

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<String>)

    All deleted file names. These are not titles, so they do not include “File:”.

See Also:

Since:

  • 0.8.0



105
106
107
108
109
110
111
112
# File 'lib/mediawiki/query/lists/all.rb', line 105

def get_all_deleted_files(limit = @query_limit_default)
  params = {
    list: 'filearchive',
    falimit: get_limited(limit)
  }

  query_ary(params, 'filearchive', 'name')
end

#get_all_images(limit = @query_limit_default) ⇒ Array<String>

Gets all the images on the wiki.

Parameters:

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<String>)

    An array of all images.

See Also:

Since:

  • 0.7.0



25
26
27
28
29
30
31
32
# File 'lib/mediawiki/query/lists/all.rb', line 25

def get_all_images(limit = @query_limit_default)
  params = {
    list: 'allimages',
    ailimit: get_limited(limit)
  }

  query_ary(params, 'allimages', 'name')
end

#get_all_pages_in_namespace(namespace, limit = @query_limit_default) ⇒ Array<String>

Gets all pages within a namespace integer.

Parameters:

  • namespace (Fixnum)

    The namespace ID.

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<String>)

    An array of all page titles.

See Also:

Since:

  • 0.8.0



40
41
42
43
44
45
46
47
48
# File 'lib/mediawiki/query/lists/all.rb', line 40

def get_all_pages_in_namespace(namespace, limit = @query_limit_default)
  params = {
    list: 'allpages',
    apnamespace: namespace,
    aplimit: get_limited(limit)
  }

  query_ary(params, 'allpages', 'title')
end

#get_all_protected_titles(protection_level = nil, limit = @query_limit_default) ⇒ Array<String>

Gets a list of all protected pages, by protection level if provided.

Parameters:

  • protection_level (String) (defaults to: nil)

    The protection level, e.g., sysop

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<String>)

    All protected page titles.

See Also:

Since:

  • 0.8.0



120
121
122
123
124
125
126
127
128
# File 'lib/mediawiki/query/lists/all.rb', line 120

def get_all_protected_titles(protection_level = nil, limit = @query_limit_default)
  params = {
    list: 'protectedtitles',
    ptlimit: get_limited(limit)
  }
  params[:ptlevel] = protection_level unless protection_level.nil?

  query_ary(params, 'protectedtitles', 'title')
end

#get_all_transcluders(page, limit = @query_limit_default) ⇒ Array<String>

Gets all page titles that transclude a given page.

Parameters:

  • page (String)

    The page name.

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Array<String>)

    All transcluder page titles.

See Also:

Since:

  • 0.8.0



90
91
92
93
94
95
96
97
98
# File 'lib/mediawiki/query/lists/all.rb', line 90

def get_all_transcluders(page, limit = @query_limit_default)
  params = {
    list: 'embeddedin',
    eititle: page,
    eilimit: get_limited(limit)
  }

  query_ary(params, 'embeddedin', 'title')
end

#get_all_users(group = nil, limit = @query_limit_default) ⇒ Hash<String, Fixnum>

Gets all users, or all users in a group.

Parameters:

  • group (String) (defaults to: nil)

    The group to limit this query to.

  • limit (Fixnum) (defaults to: @query_limit_default)

    The maximum number of categories to get. Cannot be greater than 500 for users or 5000 for bots.

Returns:

  • (Hash<String, Fixnum>)

    A hash of all users, names are keys, IDs are values.

See Also:

Since:

  • 0.8.0



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/mediawiki/query/lists/all.rb', line 56

def get_all_users(group = nil, limit = @query_limit_default)
  params = {
    list: 'allusers',
    aulimit: get_limited(limit)
  }
  params[:augroup] = group unless group.nil?

  query(params, {}) do |return_val, query|
    query['allusers'].each { |u| return_val[u['name']] = u['userid']}
  end
end