mediawiki-butt 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +250 -0
- data/lib/mediawiki/auth.rb +4 -4
- data/lib/mediawiki/constants.rb +3 -0
- data/lib/mediawiki/edit.rb +2 -2
- data/lib/mediawiki/query/lists/all.rb +188 -0
- data/lib/mediawiki/query/lists/backlinks.rb +145 -0
- data/lib/mediawiki/query/lists/categories.rb +65 -0
- data/lib/mediawiki/query/lists/lists.rb +25 -0
- data/lib/mediawiki/query/lists/log/block.rb +83 -0
- data/lib/mediawiki/query/lists/log/delete.rb +59 -0
- data/lib/mediawiki/query/lists/log/import.rb +57 -0
- data/lib/mediawiki/query/lists/log/log.rb +372 -0
- data/lib/mediawiki/query/lists/log/merge.rb +33 -0
- data/lib/mediawiki/query/lists/log/move.rb +57 -0
- data/lib/mediawiki/query/lists/log/newusers.rb +82 -0
- data/lib/mediawiki/query/lists/log/patrol.rb +34 -0
- data/lib/mediawiki/query/lists/log/rights.rb +59 -0
- data/lib/mediawiki/query/lists/log/upload.rb +58 -0
- data/lib/mediawiki/query/lists/miscellaneous.rb +55 -0
- data/lib/mediawiki/query/lists/querypage.rb +203 -0
- data/lib/mediawiki/query/lists/recent_changes.rb +124 -0
- data/lib/mediawiki/query/lists/search.rb +86 -0
- data/lib/mediawiki/query/lists/users.rb +210 -0
- data/lib/mediawiki/query/query.rb +1 -1
- metadata +22 -3
- data/lib/mediawiki/query/lists.rb +0 -561
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df04952bdb2d1140a9043e184d00306437d76f8f
|
4
|
+
data.tar.gz: 4fc43b654cb22b125f3aa8762c1365658b00c301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e17acafbe7a11c7d51c75fc96d69f2d4b709ac386b27cf5e0117bd4dbe352884783c46594eb5b8435435eadbea19430afb227fce3df27387a29449eb0c3e08df
|
7
|
+
data.tar.gz: c716d6a0a2d6e3c589f1b155d6d7a3a62ff8ac6552e25803d8e5a7a0a050a73c11a1f6197e3cc93f517ca9caf6592bb4b0d118fb94e98fe4d354a450b327ef04
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
# Changelog
|
2
|
+
## Version 0
|
3
|
+
### Version 0.10.0
|
4
|
+
* Remove all incorrectly splatted method arguments, so account creation reasons and edit summaries work now (#12).
|
5
|
+
* Support a bunch of more Lists (#17). All of the old methods still exist in various submodules. The new methods are:
|
6
|
+
* Log:
|
7
|
+
* get_interwiki_backlinks
|
8
|
+
* get_language_backlinks
|
9
|
+
* get_image_backlinks
|
10
|
+
* get_url_backlinks
|
11
|
+
* get_block_log
|
12
|
+
* get_reblock_log
|
13
|
+
* get_unblock_log
|
14
|
+
* get_delete_log
|
15
|
+
* get_deletion_restore_log
|
16
|
+
* get_interwiki_import_log
|
17
|
+
* get_upload_import_log
|
18
|
+
* get_overall_log
|
19
|
+
* get_merge_log
|
20
|
+
* get_move_log
|
21
|
+
* get_move_redirect_log
|
22
|
+
* get_autocreate_users_log
|
23
|
+
* get_user_create2_log
|
24
|
+
* get_user_create2_log
|
25
|
+
* get_patrol_log
|
26
|
+
* get_modify_protection_log
|
27
|
+
* get_move_protected_log
|
28
|
+
* get_protect_log
|
29
|
+
* get_unprotect_log
|
30
|
+
* get_autopromotion_log
|
31
|
+
* get_rights_log
|
32
|
+
* get_upload_overwrite_log
|
33
|
+
* get_upload_log
|
34
|
+
* The logs not explicitly supported (they are still supported in get_overall_log) are:
|
35
|
+
* upload/revert
|
36
|
+
* rights/erevoke
|
37
|
+
* delete/event
|
38
|
+
* delete/revision
|
39
|
+
* Miscellaneous:
|
40
|
+
* get_tags
|
41
|
+
* QueryPage:
|
42
|
+
* get_mostrevisions_page
|
43
|
+
* get_mostlinked_page
|
44
|
+
* get_mostlinkedtemplates_page
|
45
|
+
* get_mostlinkedcategories_page
|
46
|
+
* get_mostinterwikis_page
|
47
|
+
* get_mostimages_page
|
48
|
+
* get_mostlinkedcategories_page
|
49
|
+
* get_listduplicatedfiles_page
|
50
|
+
* get_listredirects_page
|
51
|
+
* get_wantedtemplates_page
|
52
|
+
* get_wantedpages_page
|
53
|
+
* get_wantedfiles_page
|
54
|
+
* get_wantedcategories_page
|
55
|
+
* get_unwatchedpages_page
|
56
|
+
* get_unusedtemplates_page
|
57
|
+
* get_unusedcategories_page
|
58
|
+
* get_uncategorizedtemplates_page
|
59
|
+
* get_uncategorizedpages_page
|
60
|
+
* get_uncategorizedcategories_page
|
61
|
+
* get_shortpages_page
|
62
|
+
* get_withoutinterwiki_page
|
63
|
+
* get_fewestrevisions_page
|
64
|
+
* get_lonelypages_page
|
65
|
+
* get_ancientpages_page
|
66
|
+
* get_longpages_page
|
67
|
+
* get_doubleredirects_page
|
68
|
+
* get_brokenredirects_page
|
69
|
+
* get_querypage
|
70
|
+
* RecentChanges:
|
71
|
+
* get_recent_changes
|
72
|
+
* get_recent_deleted_revisions
|
73
|
+
* Search
|
74
|
+
* get_prefix_search
|
75
|
+
* New constant MediaWiki::Constants::TIME_FORMAT for the standard MediaWiki timestamp format.
|
76
|
+
* Improve performance slightly by using Array#<< instead of Array#push.
|
77
|
+
|
78
|
+
### Version 0.9.0
|
79
|
+
* get_category_members has a new parameter, type, which can be used to get more data in a single result.
|
80
|
+
* get_category_members no longer gets files and subcategories by default. Use the above to get more data at once.
|
81
|
+
* New get_subcategories and get_files_in_category for specifically getting files or subcategories.
|
82
|
+
|
83
|
+
### Version 0.8.2
|
84
|
+
* Fix outdated usage of @namespaces variable, causing a NoMethodError on get_random_pages calls.
|
85
|
+
* Greatly improved documentation.
|
86
|
+
|
87
|
+
### Version 0.8.1
|
88
|
+
* Fix get_limited's NoMethodError on user_bot?
|
89
|
+
* Fix user_bot? always returning false.
|
90
|
+
|
91
|
+
### Version 0.8.0
|
92
|
+
* A ton of property query methods (#7). View their docs for info:
|
93
|
+
* get_all_links_in_page
|
94
|
+
* get_other_langs_of_page
|
95
|
+
* get_interwiki_links_in_page
|
96
|
+
* get_templates_in_page
|
97
|
+
* get_images_in_page
|
98
|
+
* get_page_size
|
99
|
+
* get_protection_levels
|
100
|
+
* get_display_title
|
101
|
+
* get_number_of_watchers
|
102
|
+
* page_new?
|
103
|
+
* page_redirect?
|
104
|
+
* can_i_read?
|
105
|
+
* do_i_watch?
|
106
|
+
* get_external_links
|
107
|
+
* get_duplicated_files_of
|
108
|
+
* get_image_bytes
|
109
|
+
* get_image_dimensions
|
110
|
+
* get_image_sizes
|
111
|
+
* A ton of list query methods (#8). View their docs for info:
|
112
|
+
* get_all_pages_in_namespace
|
113
|
+
* get_all_users
|
114
|
+
* get_all_blocks
|
115
|
+
* get_all_transcluders
|
116
|
+
* get_all_deleted_files
|
117
|
+
* get_all_protected_titles
|
118
|
+
* get_user_contributions
|
119
|
+
* get_full_watchlist
|
120
|
+
* get_all_duplicated_files
|
121
|
+
* Fix a NoMethodError on what_links_here caused by not actually setting the list in that query (#14).
|
122
|
+
* User-Agents are optionally customizable in the MediaWiki::Butt initialization. If this is not used, the old defaults will still be used ('NotLoggedIn/MediaWiki-Butt' and 'Username/MediaWiki-Butt') (#13).
|
123
|
+
* Fix @returns in docs.
|
124
|
+
* Got rid of false things in docs.
|
125
|
+
* Remove dependency on string-utility. That should be something the user does on their end.
|
126
|
+
* get_contrib_count no longer has a second parameter, because of the above change.
|
127
|
+
* Fix open-ended dependency for HTTPClient.
|
128
|
+
* New get_logged_in_contributors method for getting all logged in user's usernames that have contributed to a page.
|
129
|
+
* New get_total_contributors method for getting the total number of contributors to a page.
|
130
|
+
* Refactor Properties to be more like Meta.
|
131
|
+
* New get_limited protected method that limits the 'limit' parameter for queries. It's essentially just reducing duplicated code.
|
132
|
+
* Remove all global variables. MediaWiki::Constants::Namespaces' $namespaces is now MediaWiki::Constants with the hash being defined as NAMESPACES (#10).
|
133
|
+
|
134
|
+
### Version 0.7.0
|
135
|
+
* upload's filename argument is no longer splat, because arrays.
|
136
|
+
* Fix incorrect regex $ when ^ should be used in upload.
|
137
|
+
* New get_all_categories method.
|
138
|
+
* New get_all_images method.
|
139
|
+
* Fix broken user_bot? calls.
|
140
|
+
* user_bot? returns false when not logged in and username is not set.
|
141
|
+
* Refactor Query module to have its own folder, and subfolder for meta. This shouldn't change anything on the user's end.
|
142
|
+
* A couple methods no longer stupidly print stuff.
|
143
|
+
* New get_categories_in_page method.
|
144
|
+
|
145
|
+
### Version 0.6.0
|
146
|
+
* Slightly expanded Gem description.
|
147
|
+
* Finished all Meta modules and their methods, except for the allmessages meta query. [#6](https://github.com/ftb-gamepedia/mediawiki-butt-ruby/issues/6)
|
148
|
+
* New get_variables method.
|
149
|
+
* New get_function_hooks method.
|
150
|
+
* New get_extension_tags method.
|
151
|
+
* New get_skins method.
|
152
|
+
* New get_restriction_levels method.
|
153
|
+
* New get_restriction_types method.
|
154
|
+
* New get_restrictions_data method for the above methods.
|
155
|
+
* New get_allowed_file_extensions method, and refactored #upload to only allow files with those extensions.
|
156
|
+
* New get_all_usergroups method.
|
157
|
+
* New get_magic_words method.
|
158
|
+
* New get_special_page_aliases method.
|
159
|
+
* New get_namespace_aliases method.
|
160
|
+
* New get_namespaces method.
|
161
|
+
* New get_filerepo_favicons method.
|
162
|
+
* New get_filerepo_thumburls method.
|
163
|
+
* New get_nonlocal_filerepos method.
|
164
|
+
* New get_local_filerepos method.
|
165
|
+
* New get_filerepo_urls method.
|
166
|
+
* New get_filerepo_rooturls method.
|
167
|
+
* Refactor get_filerepo_names to use new get_filerepoinfo method.
|
168
|
+
* New get_filerepoinfo method, in a similar style to get_userlists.
|
169
|
+
* New get_current_user_options for getting a hash containing all of the currently logged in user's preferences.
|
170
|
+
* New get_email_address method for getting the currently logged in user's email address.
|
171
|
+
* New get_realname method for getting the currently logged in user's real name.
|
172
|
+
* New get_changeable_groups method for getting the currently logged in user's groups that they can change (add/remove people from)
|
173
|
+
* New current_user_hasmsg? method for checking if the user has any unread messages.
|
174
|
+
* check_login no longer returns false, ever, because any code after a fail is unreachable.
|
175
|
+
* prop parameter in get_current_user_meta is now optional, for get_current_user_name.
|
176
|
+
* New get_current_user_name method, for getting the currently logged in user's username.
|
177
|
+
* New get_siteinfo method, in a similar style to get_userlists.
|
178
|
+
* New get_statistics method, for getting a hash of the wiki's statistics.
|
179
|
+
* New get_general method, for getting hash of the 'general' wiki information.
|
180
|
+
* New get_extensions method, for getting an array of all extension names installed.
|
181
|
+
* New get_languages method, for getting a hash of all the languages, formatted as code => name.
|
182
|
+
* User-Agent header is now set for each post. It defaults to 'NotLoggedIn/MediaWiki::Butt', or "#{name}/MediaWiki::Butt" if logged in. This might cause some slight performance issues ([#5](https://github.com/FTB-Gamepedia/MediaWiki-Butt-Ruby/issues/5))
|
183
|
+
|
184
|
+
### Version 0.5.0
|
185
|
+
* New Administration module for administrative methods.
|
186
|
+
* New block and unblock methods, for (un)blocking users.
|
187
|
+
* Refactor token stuff. It still doesn't work exactly how I'd like yet, but it's better than it was before. Ideally I'd like to have it get the login-specific tokens on login and set them to some well-named instance variables. Then clear those on logout.
|
188
|
+
* Single-line each `do end` loops have been converted into `{...}` style loops.
|
189
|
+
* New delete method for deleting pages.
|
190
|
+
* New move method for moving pages.
|
191
|
+
|
192
|
+
### Version 0.4.1
|
193
|
+
* params[:format] is now automatically set to 'json', so it no longer needs to be defined in each method.
|
194
|
+
* Fixed a lot of styling issues thanks to Rubocop.
|
195
|
+
* check_login and check_create now use case/when statements instead of elsifs.
|
196
|
+
* check_create no longer returns anything.
|
197
|
+
* Update minimum Ruby version to 2.1, for refinements.
|
198
|
+
* Fix $namespaces hash syntax.
|
199
|
+
* Generally improved if statement syntax.
|
200
|
+
* Generally shortened a lot of code by using better syntax.
|
201
|
+
|
202
|
+
### Version 0.4.0
|
203
|
+
* New get_userrights method for getting an array of all user rights that user has.
|
204
|
+
* New get_user_gender method for getting the gender of the provided user.
|
205
|
+
* New get_current_user_meta for getting userlists about the currently logged in user. Essentially the equivalent of get_userlists for logged in users.
|
206
|
+
* Fix all userlist methods to work without supplying a username.
|
207
|
+
* New get_registration_time method to get when the user registered.
|
208
|
+
* Update to work with latest version of string-utility.
|
209
|
+
* Namespaces are now in a hash instead of a bunch of variables.
|
210
|
+
* Namespace parameters are now actually limited to the valid namespaces constant. It will default to the main namespace (0) if the integer provided is not in the namespaces hash.
|
211
|
+
* get_random_pages no longer wrongly sets the rnlimit to the namespaces argument rather than the namespace argument.
|
212
|
+
|
213
|
+
### Version 0.3.1
|
214
|
+
* Fix edit and create_page NoMethodErrors.
|
215
|
+
* Remove dependency for JSON as the version we use is included in the Ruby standard library.
|
216
|
+
|
217
|
+
### Version 0.3.0
|
218
|
+
* New upload method to upload by URL.
|
219
|
+
* New create_page method.
|
220
|
+
* New get_userlists method.
|
221
|
+
* New get_usergroups method.
|
222
|
+
* New get_contrib_count method.
|
223
|
+
* Refactor get_usergroups and is_current_user_bot? to use new get_userinfo method.
|
224
|
+
* Minor refactors to make optional arguments more Ruby-like with splat arguments.
|
225
|
+
* #edit no longer prints the edit token, because that's stupid.
|
226
|
+
* #edit no longer sets the summary if it is nil.
|
227
|
+
|
228
|
+
### Version 0.2.1
|
229
|
+
* Fix gemspec. You should actually have the new stuff now.
|
230
|
+
|
231
|
+
### Version 0.2.0
|
232
|
+
* New get_id method to get the pageid from the title.
|
233
|
+
* New get_random_pages method to get an array of random articles.
|
234
|
+
* New Namespace module full of constants.
|
235
|
+
* is_current_user_bot is now called as is_current_user_bot?.
|
236
|
+
* New get_edit_token method for obtaining an edit token based on the page title.
|
237
|
+
* New edit method and module for editing pages.
|
238
|
+
* Fix logout parsing error
|
239
|
+
|
240
|
+
### Version 0.1.1
|
241
|
+
* Got rid of pointless array in is_current_user_bot
|
242
|
+
* Potentially fixed docs
|
243
|
+
* Raise errors on unsuccessful account creation
|
244
|
+
* #login properly returns true if the login is successful on the first try
|
245
|
+
* #logout returns true/false if it logs the user out. Basically returns true if @logged_in is true, and false if not, because the logout action has no errors.
|
246
|
+
* Account creation stuff actually returns true/false on success/fail. It also handles errors now.
|
247
|
+
* Better Category title regex in get_category_members
|
248
|
+
|
249
|
+
### Version 0.1.0
|
250
|
+
* Initial version.
|
data/lib/mediawiki/auth.rb
CHANGED
@@ -177,14 +177,14 @@ module MediaWiki
|
|
177
177
|
# Creation Docs
|
178
178
|
# @since 0.1.0
|
179
179
|
# @return [Boolean] True if successful, false if not.
|
180
|
-
def create_account(username, password, language = 'en',
|
180
|
+
def create_account(username, password, language = 'en', reason = nil)
|
181
181
|
params = {
|
182
182
|
name: username,
|
183
183
|
password: password,
|
184
|
-
reason: reason,
|
185
184
|
language: language,
|
186
185
|
token: ''
|
187
186
|
}
|
187
|
+
params[:reason] = reason unless reason.nil?
|
188
188
|
|
189
189
|
result = post(params)
|
190
190
|
unless result['error'].nil?
|
@@ -229,15 +229,15 @@ module MediaWiki
|
|
229
229
|
# Creation Docs
|
230
230
|
# @since 0.1.0
|
231
231
|
# @return [Boolean] True if successful, false if not.
|
232
|
-
def create_account_email(username, email, language = 'en',
|
232
|
+
def create_account_email(username, email, language = 'en', reason = nil)
|
233
233
|
params = {
|
234
234
|
name: username,
|
235
235
|
email: email,
|
236
236
|
mailpassword: 'value',
|
237
|
-
reason: reason,
|
238
237
|
language: language,
|
239
238
|
token: ''
|
240
239
|
}
|
240
|
+
params[:reason] = reason unless reason.nil?
|
241
241
|
|
242
242
|
result = post(params)
|
243
243
|
unless result['error'].nil?
|
data/lib/mediawiki/constants.rb
CHANGED
data/lib/mediawiki/edit.rb
CHANGED
@@ -13,7 +13,7 @@ module MediaWiki
|
|
13
13
|
# @see https://www.mediawiki.org/wiki/API:Edit MediaWiki Edit API Docs
|
14
14
|
# @since 0.2.0
|
15
15
|
# @return [String] The new revision ID, or if it failed, the error code.
|
16
|
-
def edit(title, text, minor = false, bot = true,
|
16
|
+
def edit(title, text, minor = false, bot = true, summary = nil)
|
17
17
|
params = {
|
18
18
|
action: 'edit',
|
19
19
|
title: title,
|
@@ -24,7 +24,7 @@ module MediaWiki
|
|
24
24
|
|
25
25
|
token = get_token('edit', title)
|
26
26
|
|
27
|
-
params[:summary] = summary
|
27
|
+
params[:summary] = summary unless summary.nil?
|
28
28
|
params[:minor] = '1' if minor
|
29
29
|
params[:bot] = '1' if bot
|
30
30
|
params[:token] = token
|
@@ -0,0 +1,188 @@
|
|
1
|
+
module MediaWiki
|
2
|
+
module Query
|
3
|
+
module Lists
|
4
|
+
module All
|
5
|
+
# Gets all categories on the entire wiki.
|
6
|
+
# @param limit [Int] The maximum number of categories to get. Defaults
|
7
|
+
# to 500. Cannot be greater than 500 for normal users, or 5000 for
|
8
|
+
# bots.
|
9
|
+
# @see https://www.mediawiki.org/wiki/API:Allcategories MediaWiki
|
10
|
+
# Allcategories API Docs
|
11
|
+
# @since 0.7.0
|
12
|
+
# @return [Array] An array of all categories.
|
13
|
+
def get_all_categories(limit = 500)
|
14
|
+
params = {
|
15
|
+
action: 'query',
|
16
|
+
list: 'allcategories',
|
17
|
+
aclimit: get_limited(limit)
|
18
|
+
}
|
19
|
+
|
20
|
+
response = post(params)
|
21
|
+
|
22
|
+
ret = []
|
23
|
+
response['query']['allcategories'].each { |c| ret << c['*'] }
|
24
|
+
|
25
|
+
ret
|
26
|
+
end
|
27
|
+
|
28
|
+
# Gets all the images on the wiki.
|
29
|
+
# @param limit [Int] The maximum number of images to get. Defaults to
|
30
|
+
# 500. Cannot be greater than 500 for normal users, or 5000 for bots.
|
31
|
+
# @see https://www.mediawiki.org/wiki/API:Allimages MediaWiki Allimages
|
32
|
+
# API Docs
|
33
|
+
# @since 0.7.0
|
34
|
+
# @return [Array] An array of all images.
|
35
|
+
def get_all_images(limit = 500)
|
36
|
+
params = {
|
37
|
+
action: 'query',
|
38
|
+
list: 'allimages',
|
39
|
+
ailimit: get_limited(limit)
|
40
|
+
}
|
41
|
+
|
42
|
+
response = post(params)
|
43
|
+
|
44
|
+
ret = []
|
45
|
+
response['query']['allimages'].each { |i| ret << i['name'] }
|
46
|
+
|
47
|
+
ret
|
48
|
+
end
|
49
|
+
|
50
|
+
# Gets all pages within a namespace integer.
|
51
|
+
# @param namespace [Int] The namespace ID.
|
52
|
+
# @param limit [Int] See #get_all_images
|
53
|
+
# @see https://www.mediawiki.org/wiki/API:Allpages MediaWiki Allpages
|
54
|
+
# API Docs
|
55
|
+
# @since 0.8.0
|
56
|
+
# @return [Array] An array of all page titles.
|
57
|
+
def get_all_pages_in_namespace(namespace, limit = 500)
|
58
|
+
params = {
|
59
|
+
action: 'query',
|
60
|
+
list: 'allpages',
|
61
|
+
apnamespace: namespace,
|
62
|
+
aplimit: get_limited(limit)
|
63
|
+
}
|
64
|
+
|
65
|
+
response = post(params)
|
66
|
+
|
67
|
+
ret = []
|
68
|
+
response['query']['allpages'].each { |p| ret << p['title'] }
|
69
|
+
|
70
|
+
ret
|
71
|
+
end
|
72
|
+
|
73
|
+
# Gets all users, or all users in a group.
|
74
|
+
# @param group [String] The group to limit this query to.
|
75
|
+
# @param limit [Int] See #get_all_images.
|
76
|
+
# @see https://www.mediawiki.org/wiki/API:Allusers MediaWiki Allusers
|
77
|
+
# API Docs
|
78
|
+
# @since 0.8.0
|
79
|
+
# @return [Hash] A hash of all users, names are keys, IDs are values.
|
80
|
+
def get_all_users(group = nil, limit = 500)
|
81
|
+
params = {
|
82
|
+
action: 'query',
|
83
|
+
list: 'allusers',
|
84
|
+
aulimit: get_limited(limit)
|
85
|
+
}
|
86
|
+
params[:augroup] = group unless group.nil?
|
87
|
+
|
88
|
+
response = post(params)
|
89
|
+
|
90
|
+
ret = {}
|
91
|
+
response['query']['allusers'].each { |u| ret[u['name']] = u['userid'] }
|
92
|
+
|
93
|
+
ret
|
94
|
+
end
|
95
|
+
|
96
|
+
# Gets all block IDs on the wiki. It seems like this only gets non-IP
|
97
|
+
# blocks, but the MediaWiki docs are a bit unclear.
|
98
|
+
# @param limit [Int] See #get_all_images.
|
99
|
+
# @see https://www.mediawiki.org/wiki/API:Blocks MediaWiki Blocks API Docs
|
100
|
+
# @since 0.8.0
|
101
|
+
# @return [Array] All block IDs as strings.
|
102
|
+
def get_all_blocks(limit = 500)
|
103
|
+
params = {
|
104
|
+
action: 'query',
|
105
|
+
list: 'blocks',
|
106
|
+
bklimit: get_limited(limit),
|
107
|
+
bkprop: 'id'
|
108
|
+
}
|
109
|
+
|
110
|
+
response = post(params)
|
111
|
+
|
112
|
+
ret = []
|
113
|
+
response['query']['blocks'].each { |b| ret.push(b['id']) }
|
114
|
+
|
115
|
+
ret
|
116
|
+
end
|
117
|
+
|
118
|
+
# Gets all page titles that transclude a given page.
|
119
|
+
# @param page [String] The page name.
|
120
|
+
# @param limit [Int] See #get_all_images.
|
121
|
+
# @see https://www.mediawiki.org/wiki/API:Embeddedin MediaWiki Embeddedin
|
122
|
+
# API Docs
|
123
|
+
# @since 0.8.0
|
124
|
+
# @return [Array] All transcluder page titles.
|
125
|
+
def get_all_transcluders(page, limit = 500)
|
126
|
+
params = {
|
127
|
+
action: 'query',
|
128
|
+
list: 'embeddedin',
|
129
|
+
eititle: page,
|
130
|
+
eilimit: get_limited(limit)
|
131
|
+
}
|
132
|
+
|
133
|
+
response = post(params)
|
134
|
+
|
135
|
+
ret = []
|
136
|
+
response['query']['embeddedin'].each { |e| ret << e['title'] }
|
137
|
+
|
138
|
+
ret
|
139
|
+
end
|
140
|
+
|
141
|
+
# Gets an array of all deleted or archived files on the wiki.
|
142
|
+
# @param limit [Int] See #get_all_images
|
143
|
+
# @see https://www.mediawiki.org/wiki/API:Filearchive MediaWiki
|
144
|
+
# Filearchive API Docs
|
145
|
+
# @since 0.8.0
|
146
|
+
# @return [Array] All deleted file names. These are not titles, so they do
|
147
|
+
# not include "File:".
|
148
|
+
def get_all_deleted_files(limit = 500)
|
149
|
+
params = {
|
150
|
+
action: 'query',
|
151
|
+
list: 'filearchive',
|
152
|
+
falimit: get_limited(limit)
|
153
|
+
}
|
154
|
+
|
155
|
+
response = post(params)
|
156
|
+
|
157
|
+
ret = []
|
158
|
+
response['query']['filearchive'].each { |f| ret.push(f['name']) }
|
159
|
+
|
160
|
+
ret
|
161
|
+
end
|
162
|
+
|
163
|
+
# Gets a list of all protected pages, by protection level if provided.
|
164
|
+
# @param protection_level [String] The protection level, e.g., sysop
|
165
|
+
# @param limit [Int] See #get_all_images.
|
166
|
+
# @see https://www.mediawiki.org/wiki/API:Protectedtitles MediaWiki
|
167
|
+
# Protectedtitles API Docs
|
168
|
+
# @since 0.8.0
|
169
|
+
# @return [Array] All protected page titles.
|
170
|
+
def get_all_protected_titles(protection_level = nil, limit = 500)
|
171
|
+
params = {
|
172
|
+
action: 'query',
|
173
|
+
list: 'protectedtitles',
|
174
|
+
ptlimit: get_limited(limit)
|
175
|
+
}
|
176
|
+
params[:ptlevel] = protection_level unless protection_level.nil?
|
177
|
+
|
178
|
+
response = post(params)
|
179
|
+
|
180
|
+
ret = []
|
181
|
+
response['query']['protectedtitles'].each { |t| ret << t['title'] }
|
182
|
+
|
183
|
+
ret
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|