mediawiki-butt 0.11.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -5
- data/lib/mediawiki/administration.rb +18 -17
- data/lib/mediawiki/auth.rb +52 -193
- data/lib/mediawiki/butt.rb +51 -32
- data/lib/mediawiki/constants.rb +127 -130
- data/lib/mediawiki/edit.rb +58 -71
- data/lib/mediawiki/exceptions.rb +2 -123
- data/lib/mediawiki/query/lists/all.rb +35 -45
- data/lib/mediawiki/query/lists/backlinks.rb +23 -34
- data/lib/mediawiki/query/lists/categories.rb +17 -28
- data/lib/mediawiki/query/lists/log/block.rb +17 -33
- data/lib/mediawiki/query/lists/log/delete.rb +8 -24
- data/lib/mediawiki/query/lists/log/import.rb +9 -24
- data/lib/mediawiki/query/lists/log/log.rb +36 -63
- data/lib/mediawiki/query/lists/log/merge.rb +5 -12
- data/lib/mediawiki/query/lists/log/move.rb +6 -20
- data/lib/mediawiki/query/lists/log/newusers.rb +13 -36
- data/lib/mediawiki/query/lists/log/patrol.rb +5 -13
- data/lib/mediawiki/query/lists/log/protect.rb +20 -50
- data/lib/mediawiki/query/lists/log/rights.rb +10 -24
- data/lib/mediawiki/query/lists/log/upload.rb +10 -24
- data/lib/mediawiki/query/lists/miscellaneous.rb +10 -19
- data/lib/mediawiki/query/lists/querypage.rb +60 -62
- data/lib/mediawiki/query/lists/recent_changes.rb +18 -30
- data/lib/mediawiki/query/lists/search.rb +14 -29
- data/lib/mediawiki/query/lists/users.rb +43 -61
- data/lib/mediawiki/query/meta/filerepoinfo.rb +18 -20
- data/lib/mediawiki/query/meta/siteinfo.rb +30 -33
- data/lib/mediawiki/query/meta/userinfo.rb +48 -66
- data/lib/mediawiki/query/properties/contributors.rb +18 -22
- data/lib/mediawiki/query/properties/files.rb +18 -20
- data/lib/mediawiki/query/properties/pages.rb +129 -211
- data/lib/mediawiki/query/properties/properties.rb +20 -25
- data/lib/mediawiki/query/query.rb +0 -25
- data/lib/mediawiki/utils.rb +9 -8
- data/lib/mediawiki/watch.rb +52 -0
- metadata +6 -4
@@ -1,14 +1,12 @@
|
|
1
1
|
module MediaWiki
|
2
2
|
module Query
|
3
3
|
module Meta
|
4
|
-
# @see https://www.mediawiki.org/wiki/API:Siteinfo MediaWiki Siteinfo
|
5
|
-
# API Docs
|
4
|
+
# @see https://www.mediawiki.org/wiki/API:Siteinfo MediaWiki Siteinfo API Docs
|
6
5
|
module SiteInfo
|
7
|
-
# Gets wiki information. This method should rarely be used by
|
8
|
-
# normal users.
|
6
|
+
# Gets wiki information. This method should rarely be used by normal users.
|
9
7
|
# @param prop [String] The siprop parameter.
|
10
8
|
# @since 0.6.0
|
11
|
-
# @return [
|
9
|
+
# @return [Hash] Parsed full response.
|
12
10
|
def get_siteinfo(prop)
|
13
11
|
params = {
|
14
12
|
action: 'query',
|
@@ -21,7 +19,7 @@ module MediaWiki
|
|
21
19
|
|
22
20
|
# Gets the statistics for the wiki.
|
23
21
|
# @since 0.6.0
|
24
|
-
# @return [Hash] The statistics and their according values.
|
22
|
+
# @return [Hash<String, Fixnum>] The statistics and their according values.
|
25
23
|
def get_statistics
|
26
24
|
response = get_siteinfo('statistics')
|
27
25
|
ret = {}
|
@@ -31,7 +29,7 @@ module MediaWiki
|
|
31
29
|
|
32
30
|
# Gets the general information for the wiki.
|
33
31
|
# @since 0.6.0
|
34
|
-
# @return [Hash] The general info and their according values.
|
32
|
+
# @return [Hash<String, Any>] The general info and their according values.
|
35
33
|
def get_general
|
36
34
|
response = get_siteinfo('general')
|
37
35
|
ret = {}
|
@@ -41,18 +39,17 @@ module MediaWiki
|
|
41
39
|
|
42
40
|
# Gets all extensions installed on the wiki.
|
43
41
|
# @since 0.6.0
|
44
|
-
# @return [Array] All extension names.
|
42
|
+
# @return [Array<String>] All extension names.
|
45
43
|
def get_extensions
|
46
44
|
response = get_siteinfo('extensions')
|
47
45
|
ret = []
|
48
|
-
response['query']['extensions'].each { |e| ret
|
46
|
+
response['query']['extensions'].each { |e| ret << e['name'] }
|
49
47
|
ret
|
50
48
|
end
|
51
49
|
|
52
50
|
# Gets all languages and their codes.
|
53
51
|
# @since 0.6.0
|
54
|
-
# @return [Hash] All languages. Hash key value pair formatted as
|
55
|
-
# code => name.
|
52
|
+
# @return [Hash<String, String>] All languages. Hash key value pair formatted as code => name.
|
56
53
|
def get_languages
|
57
54
|
response = get_siteinfo('languages')
|
58
55
|
ret = {}
|
@@ -60,10 +57,9 @@ module MediaWiki
|
|
60
57
|
ret
|
61
58
|
end
|
62
59
|
|
63
|
-
# Gets all namespaces on the wiki and their IDs. Different from the
|
64
|
-
# Namespaces module.
|
60
|
+
# Gets all namespaces on the wiki and their IDs. Different from the Namespaces module.
|
65
61
|
# @since 0.6.0
|
66
|
-
# @return [Hash] All namespaces, formatted as ID => Name.
|
62
|
+
# @return [Hash<Fixnum, String>] All namespaces, formatted as ID => Name.
|
67
63
|
def get_namespaces
|
68
64
|
response = get_siteinfo('namespaces')
|
69
65
|
ret = {}
|
@@ -77,7 +73,7 @@ module MediaWiki
|
|
77
73
|
|
78
74
|
# Gets all namespace aliases and their IDs.
|
79
75
|
# @since 0.6.0
|
80
|
-
# @return [Hash] All aliases, formatted as ID => Alias.
|
76
|
+
# @return [Hash<Fixnum, String>] All aliases, formatted as ID => Alias.
|
81
77
|
def get_namespace_aliases
|
82
78
|
response = get_siteinfo('namespacealiases')
|
83
79
|
ret = {}
|
@@ -89,7 +85,7 @@ module MediaWiki
|
|
89
85
|
|
90
86
|
# Gets all special page aliases.
|
91
87
|
# @since 0.6.0
|
92
|
-
# @return [Hash] All aliases, formatted as RealName => Alias.
|
88
|
+
# @return [Hash<String, Array<String>>] All aliases, formatted as RealName => Alias.
|
93
89
|
def get_special_page_aliases
|
94
90
|
response = get_siteinfo('specialpagealiases')
|
95
91
|
ret = {}
|
@@ -101,7 +97,7 @@ module MediaWiki
|
|
101
97
|
|
102
98
|
# Gets all magic words and their aliases.
|
103
99
|
# @since 0.6.0
|
104
|
-
# @return [Hash] All magic words, formatted as Name => Alias.
|
100
|
+
# @return [Hash<String, Array<String>>] All magic words, formatted as Name => Alias.
|
105
101
|
def get_magic_words
|
106
102
|
response = get_siteinfo('magicwords')
|
107
103
|
ret = {}
|
@@ -113,7 +109,7 @@ module MediaWiki
|
|
113
109
|
|
114
110
|
# Gets all user groups total.
|
115
111
|
# @since 0.6.0
|
116
|
-
# @return [Hash] All groups, formatted as Name => [Rights].
|
112
|
+
# @return [Hash<String, Array<String>>] All groups, formatted as Name => [Rights].
|
117
113
|
def get_all_usergroups
|
118
114
|
response = get_siteinfo('usergroups')
|
119
115
|
ret = {}
|
@@ -125,19 +121,20 @@ module MediaWiki
|
|
125
121
|
|
126
122
|
# Gets all file extensions that are allowed to be uploaded.
|
127
123
|
# @since 0.6.0
|
128
|
-
# @return [Array] All file extensions.
|
124
|
+
# @return [Array<String>] All file extensions.
|
129
125
|
def get_allowed_file_extensions
|
130
126
|
response = get_siteinfo('fileextensions')
|
131
127
|
ret = []
|
132
128
|
response['query']['fileextensions'].each do |e|
|
133
|
-
ret
|
129
|
+
ret << e['ext']
|
134
130
|
end
|
135
131
|
ret
|
136
132
|
end
|
137
133
|
|
138
|
-
# Gets the response for the restrictions siteinfo API. Not really for
|
139
|
-
#
|
134
|
+
# Gets the response for the restrictions siteinfo API. Not really for use by users, mostly for the other two
|
135
|
+
# restriction methods.
|
140
136
|
# @since 0.6.0
|
137
|
+
# @return [Hash<String, Array<String>>] All restriction data. See the other restriction methods.
|
141
138
|
def get_restrictions_data
|
142
139
|
response = get_siteinfo('restrictions')
|
143
140
|
response['query']['restrictions']
|
@@ -145,27 +142,27 @@ module MediaWiki
|
|
145
142
|
|
146
143
|
# Gets all restriction/protection types.
|
147
144
|
# @since 0.6.0
|
148
|
-
# @return [Array] All protection types.
|
145
|
+
# @return [Array<String>] All protection types.
|
149
146
|
def get_restriction_types
|
150
147
|
restrictions = get_restrictions_data
|
151
148
|
ret = []
|
152
|
-
restrictions['types'].each { |t| ret
|
149
|
+
restrictions['types'].each { |t| ret << t }
|
153
150
|
ret
|
154
151
|
end
|
155
152
|
|
156
153
|
# Gets all restriction/protection levels.
|
157
154
|
# @since 0.6.0
|
158
|
-
# @return [Array] All protection levels.
|
155
|
+
# @return [Array<String>] All protection levels.
|
159
156
|
def get_restriction_levels
|
160
157
|
restrictions = get_restrictions_data
|
161
158
|
ret = []
|
162
|
-
restrictions['levels'].each { |l| ret
|
159
|
+
restrictions['levels'].each { |l| ret << l }
|
163
160
|
ret
|
164
161
|
end
|
165
162
|
|
166
163
|
# Gets all skins and their codes.
|
167
164
|
# @since 0.6.0
|
168
|
-
# @return [Hash] All skins, formatted as Code => Name
|
165
|
+
# @return [Hash<String, String>] All skins, formatted as Code => Name
|
169
166
|
def get_skins
|
170
167
|
response = get_siteinfo('skins')
|
171
168
|
ret = {}
|
@@ -177,36 +174,36 @@ module MediaWiki
|
|
177
174
|
|
178
175
|
# Gets all HTML tags added by installed extensions.
|
179
176
|
# @since 0.6.0
|
180
|
-
# @return [Array] All extension tags.
|
177
|
+
# @return [Array<String>] All extension tags.
|
181
178
|
def get_extension_tags
|
182
179
|
response = get_siteinfo('extensiontags')
|
183
180
|
ret = []
|
184
181
|
response['query']['extensiontags'].each do |t|
|
185
|
-
ret
|
182
|
+
ret << t
|
186
183
|
end
|
187
184
|
ret
|
188
185
|
end
|
189
186
|
|
190
187
|
# Gets all function hooks.
|
191
188
|
# @since 0.6.0
|
192
|
-
# @return [Array] All function hooks.
|
189
|
+
# @return [Array<String>] All function hooks.
|
193
190
|
def get_function_hooks
|
194
191
|
response = get_siteinfo('functionhooks')
|
195
192
|
ret = []
|
196
193
|
response['query']['functionhooks'].each do |h|
|
197
|
-
ret
|
194
|
+
ret << h
|
198
195
|
end
|
199
196
|
ret
|
200
197
|
end
|
201
198
|
|
202
199
|
# Gets all variables that are usable on the wiki, such as NUMBEROFPAGES.
|
203
200
|
# @since 0.6.0
|
204
|
-
# @return [Array] All variable string values.
|
201
|
+
# @return [Array<String>] All variable string values.
|
205
202
|
def get_variables
|
206
203
|
response = get_siteinfo('variables')
|
207
204
|
ret = []
|
208
205
|
response['query']['variables'].each do |v|
|
209
|
-
ret
|
206
|
+
ret << v
|
210
207
|
end
|
211
208
|
ret
|
212
209
|
end
|
@@ -1,87 +1,71 @@
|
|
1
1
|
module MediaWiki
|
2
2
|
module Query
|
3
3
|
module Meta
|
4
|
-
# @see https://www.mediawiki.org/wiki/API:Userinfo MediaWiki Userinfo
|
5
|
-
# API Docs
|
4
|
+
# @see https://www.mediawiki.org/wiki/API:Userinfo MediaWiki Userinfo API Docs
|
6
5
|
module UserInfo
|
7
6
|
# Gets meta information for the currently logged in user.
|
8
7
|
# @param prop [String] The uiprop to get. Optional.
|
9
8
|
# @since 0.4.0
|
10
|
-
# @return [
|
9
|
+
# @return [Hash] Full, parsed response.
|
11
10
|
# @return [Boolean] False if not logged in.
|
12
11
|
def get_current_user_meta(prop = nil)
|
13
|
-
|
14
|
-
params = {
|
15
|
-
action: 'query',
|
16
|
-
meta: 'userinfo',
|
17
|
-
uiprop: prop
|
18
|
-
}
|
12
|
+
return false unless @logged_in
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
params = {
|
15
|
+
action: 'query',
|
16
|
+
meta: 'userinfo',
|
17
|
+
uiprop: prop
|
18
|
+
}
|
19
|
+
|
20
|
+
post(params)
|
24
21
|
end
|
25
22
|
|
26
23
|
# Gets the current user's username.
|
27
24
|
# @since 0.7.0
|
28
25
|
# @return [String] Returns the username.
|
29
|
-
# @return [Boolean] False if
|
26
|
+
# @return [Boolean] False if not currently logged in.
|
30
27
|
def get_current_user_name
|
31
|
-
if
|
32
|
-
|
33
|
-
|
34
|
-
name = get_current_user_meta
|
35
|
-
name = name['query']['userinfo']['name'] if name != false
|
28
|
+
return @name if @name
|
29
|
+
name = get_current_user_meta
|
30
|
+
name = name['query']['userinfo']['name'] if name
|
36
31
|
|
37
|
-
|
38
|
-
end
|
32
|
+
name
|
39
33
|
end
|
40
34
|
|
41
|
-
# Returns whether or not the currently logged in user has any unread
|
42
|
-
# messages on their talk page.
|
35
|
+
# Returns whether or not the currently logged in user has any unread messages on their talk page.
|
43
36
|
# @since 0.7.0
|
44
37
|
# @return [Boolean] True if they have unreads, else false.
|
45
38
|
def current_user_hasmsg?
|
46
39
|
response = get_current_user_meta('hasmsg')
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
return true
|
52
|
-
end
|
53
|
-
else
|
54
|
-
return false
|
55
|
-
end
|
40
|
+
return false unless response
|
41
|
+
|
42
|
+
response['query']['userinfo']['messages'] == ''
|
56
43
|
end
|
57
44
|
|
58
|
-
# Gets a hash-of-arrays containing all the groups the user can add and
|
59
|
-
# remove people from.
|
45
|
+
# Gets a hash-of-arrays containing all the groups the user can add and remove people from.
|
60
46
|
# @since 0.7.0
|
61
47
|
# @return [Boolean] False if get_current_user_meta is false
|
62
|
-
# @return [Hash] All the groups that the user can add, remove, add-self,
|
63
|
-
# and remove-self.
|
48
|
+
# @return [Hash<String, Array<String>>] All the groups that the user can add, remove, add-self, and remove-self.
|
64
49
|
def get_changeable_groups
|
65
50
|
response = get_current_user_meta('changeablegroups')
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
51
|
+
return false unless response
|
52
|
+
|
53
|
+
ret = {}
|
54
|
+
add = []
|
55
|
+
remove = []
|
56
|
+
addself = []
|
57
|
+
removeself = []
|
58
|
+
changeablegroups = response['query']['userinfo']['changeablegroups']
|
59
|
+
changeablegroups['add'].each { |g| add.push(g) }
|
60
|
+
changeablegroups['remove'].each { |g| remove.push(g) }
|
61
|
+
changeablegroups['add-self'].each { |g| addself.push(g) }
|
62
|
+
changeablegroups['remove-self'].each { |g| removeself.push(g) }
|
63
|
+
ret['add'] = add
|
64
|
+
ret['remove'] = remove
|
65
|
+
ret['addself'] = addself
|
66
|
+
ret['removeself'] = removeself
|
67
|
+
|
68
|
+
ret
|
85
69
|
end
|
86
70
|
|
87
71
|
# Gets the currently logged in user's real name.
|
@@ -90,11 +74,10 @@ module MediaWiki
|
|
90
74
|
# @return [Nil] If they don't have a real name set.
|
91
75
|
def get_realname
|
92
76
|
response = get_current_user_meta('realname')
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
77
|
+
realname = response['query']['userinfo']['realname']
|
78
|
+
return if realname == ''
|
79
|
+
|
80
|
+
realname
|
98
81
|
end
|
99
82
|
|
100
83
|
# Gets the currently logged in user's email address.
|
@@ -103,16 +86,15 @@ module MediaWiki
|
|
103
86
|
# @return [Nil] If their email address is not set.
|
104
87
|
def get_email_address
|
105
88
|
response = get_current_user_meta('email')
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
89
|
+
email = response['query']['userinfo']['email']
|
90
|
+
return if email == ''
|
91
|
+
|
92
|
+
email
|
111
93
|
end
|
112
94
|
|
113
95
|
# Gets the user's options.
|
114
96
|
# @since 0.7.0
|
115
|
-
# @return [Hash] The user's options.
|
97
|
+
# @return [Hash<String, Any>] The user's options.
|
116
98
|
def get_current_user_options
|
117
99
|
response = get_current_user_meta('options')
|
118
100
|
ret = {}
|
@@ -6,14 +6,13 @@ module MediaWiki
|
|
6
6
|
module Contributors
|
7
7
|
# Gets the total amount of contributors for the given page.
|
8
8
|
# @param title [String] The page title.
|
9
|
-
# @param limit [
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# @see
|
13
|
-
# @see get_logged_in_contributors
|
9
|
+
# @param limit [Fixnum] The maximum number of users to get. Defaults to 500 and cannot be greater than that
|
10
|
+
# unless the user is a bot. If the user is a bot, the limit cannot be greater than 5000.
|
11
|
+
# @see #get_anonymous_contributors_count
|
12
|
+
# @see #get_logged_in_contributors
|
14
13
|
# @since 0.8.0
|
15
|
-
# @return [
|
16
|
-
def get_total_contributors(title, limit =
|
14
|
+
# @return [Fixnum] The number of contributors to that page.
|
15
|
+
def get_total_contributors(title, limit = @query_limit_default)
|
17
16
|
anon_users = get_anonymous_contributors_count(title, limit)
|
18
17
|
users = get_logged_in_contributors(title, limit)
|
19
18
|
|
@@ -21,12 +20,11 @@ module MediaWiki
|
|
21
20
|
end
|
22
21
|
|
23
22
|
# Gets the non-anonymous contributors for the given page.
|
24
|
-
# @param
|
25
|
-
# @
|
26
|
-
# @see get_contributors_response
|
23
|
+
# @param (see #get_total_contributors)
|
24
|
+
# @see #get_contributors_response
|
27
25
|
# @since 0.8.0
|
28
26
|
# @return [Array] All usernames for the contributors.
|
29
|
-
def get_logged_in_contributors(title, limit =
|
27
|
+
def get_logged_in_contributors(title, limit = @query_limit_default)
|
30
28
|
response = get_contributors_response(title, limit)
|
31
29
|
pageid = nil
|
32
30
|
response['query']['pages'].each { |r, _| pageid = r }
|
@@ -45,13 +43,11 @@ module MediaWiki
|
|
45
43
|
private
|
46
44
|
|
47
45
|
# Gets the parsed response for the contributors property.
|
48
|
-
# @param
|
49
|
-
# @
|
50
|
-
# @see https://www.mediawiki.org/wiki/API:Contributors MediaWiki
|
51
|
-
# Contributors Property API Docs
|
46
|
+
# @param (see #get_total_contributors)
|
47
|
+
# @see https://www.mediawiki.org/wiki/API:Contributors MediaWiki Contributors Property API Docs
|
52
48
|
# @since 0.8.0
|
53
|
-
# @return [
|
54
|
-
def get_contributors_response(title, limit =
|
49
|
+
# @return [Hash] See {MediaWiki::Butt#post}
|
50
|
+
def get_contributors_response(title, limit = @query_limit_default)
|
55
51
|
params = {
|
56
52
|
action: 'query',
|
57
53
|
prop: 'contributors',
|
@@ -63,12 +59,12 @@ module MediaWiki
|
|
63
59
|
end
|
64
60
|
|
65
61
|
# Gets the total number of anonymous contributors for the given page.
|
66
|
-
# @param
|
67
|
-
# @
|
68
|
-
# @see get_contributors_response
|
62
|
+
# @param (see #get_total_contributors)
|
63
|
+
# @see #get_contributors_response
|
69
64
|
# @since 0.8.0
|
70
|
-
# @return [
|
71
|
-
|
65
|
+
# @return [Fixnum] The number of anonymous contributors for the page.
|
66
|
+
# @return [Nil] If title is not a valid page.
|
67
|
+
def get_anonymous_contributors_count(title, limit = @query_limit_default)
|
72
68
|
response = get_contributors_response(title, limit)
|
73
69
|
pageid = nil
|
74
70
|
response['query']['pages'].each { |r, _| pageid = r }
|
@@ -6,13 +6,12 @@ module MediaWiki
|
|
6
6
|
module Files
|
7
7
|
# Gets the duplicated files of the title.
|
8
8
|
# @param title [String] The title to get duplicated files of.
|
9
|
-
# @param
|
10
|
-
# @see https://www.mediawiki.org/wiki/API:Duplicatefiles MediaWiki
|
11
|
-
# Duplicate Files API Docs
|
9
|
+
# @param (see #get_all_duplicated_files)
|
10
|
+
# @see https://www.mediawiki.org/wiki/API:Duplicatefiles MediaWiki Duplicate Files API Docs
|
12
11
|
# @since 0.8.0
|
13
|
-
# @return [Array] Array of all the duplicated file names.
|
12
|
+
# @return [Array<String>] Array of all the duplicated file names.
|
14
13
|
# @return [Nil] If there aren't any duplicated files.
|
15
|
-
def get_duplicated_files_of(title, limit =
|
14
|
+
def get_duplicated_files_of(title, limit = @query_limit_default)
|
16
15
|
params = {
|
17
16
|
action: 'query',
|
18
17
|
prop: 'duplicatefiles',
|
@@ -25,19 +24,18 @@ module MediaWiki
|
|
25
24
|
response['query']['pages'].each do |_, c|
|
26
25
|
return nil if c['duplicatefiles'].nil?
|
27
26
|
c['duplicatefiles'].each do |f|
|
28
|
-
ret
|
27
|
+
ret << f['name']
|
29
28
|
end
|
30
29
|
end
|
31
30
|
ret
|
32
31
|
end
|
33
32
|
|
34
33
|
# Gets all duplicated files on the wiki.
|
35
|
-
# @param limit [
|
36
|
-
# @see
|
37
|
-
# Duplicate Files API Docs
|
34
|
+
# @param limit [Fixnum] The maximum number of files to get.
|
35
|
+
# @see (see #get_duplicate_files_of)
|
38
36
|
# @since 0.8.0
|
39
|
-
# @return [Array] All duplicate file titles on the wiki.
|
40
|
-
def get_all_duplicated_files(limit =
|
37
|
+
# @return [Array<String>] All duplicate file titles on the wiki.
|
38
|
+
def get_all_duplicated_files(limit = @query_limit_default)
|
41
39
|
params = {
|
42
40
|
action: 'query',
|
43
41
|
generator: 'allimages',
|
@@ -48,14 +46,14 @@ module MediaWiki
|
|
48
46
|
response = post(params)
|
49
47
|
ret = []
|
50
48
|
response['query']['pages'].each do |_, c|
|
51
|
-
ret
|
49
|
+
ret << c['title']
|
52
50
|
end
|
53
51
|
ret
|
54
52
|
end
|
55
53
|
|
56
54
|
# Gets the size of an image in bytes.
|
57
|
-
# @param
|
58
|
-
# @see get_image_sizes
|
55
|
+
# @param (see #get_image_sizes)
|
56
|
+
# @see #get_image_sizes
|
59
57
|
# @since 0.8.0
|
60
58
|
# @return [Fixnum] The number of bytes.
|
61
59
|
# @return [Nil] If the image does not exist.
|
@@ -66,10 +64,11 @@ module MediaWiki
|
|
66
64
|
end
|
67
65
|
|
68
66
|
# Gets the dimensions of an image as width, height.
|
69
|
-
# @param
|
70
|
-
# @see get_image_sizes
|
67
|
+
# @param (see #get_image_sizes)
|
68
|
+
# @see #get_image_sizes
|
71
69
|
# @since 0.8.0
|
72
|
-
# @
|
70
|
+
# @todo Use data_types library to store the pair of width, height.
|
71
|
+
# @return [Array<Fixnum>] The dimensions as width, height.
|
73
72
|
# @return [Nil] If the image does not exist.
|
74
73
|
def get_image_dimensions(image)
|
75
74
|
response = get_image_sizes(image)
|
@@ -81,10 +80,9 @@ module MediaWiki
|
|
81
80
|
|
82
81
|
# Gets the imageinfo property 'size' for the image.
|
83
82
|
# @param image [String] The image to get info for.
|
84
|
-
# @see https://www.mediawiki.org/wiki/API:Imageinfo MediaWiki Imageinfo
|
85
|
-
# API Docs
|
83
|
+
# @see https://www.mediawiki.org/wiki/API:Imageinfo MediaWiki Imageinfo API Docs
|
86
84
|
# @since 0.8.0
|
87
|
-
# @return [Hash] A hash of the size, width, and height.
|
85
|
+
# @return [Hash<String, Fixnum>] A hash of the size, width, and height.
|
88
86
|
# @return [Nil] If the image does not exist.
|
89
87
|
def get_image_sizes(image)
|
90
88
|
params = {
|