mediawiki-butt 0.11.1 → 1.0.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 +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
@@ -8,21 +8,16 @@ module MediaWiki
|
|
8
8
|
|
9
9
|
# Gets the RecentChanges log.
|
10
10
|
# @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
|
11
|
-
# @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
|
12
11
|
# @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
|
13
12
|
# @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
|
14
|
-
# @param limit [
|
15
|
-
# @see https://www.mediawiki.org/wiki/API:RecentChanges MediaWiki
|
16
|
-
# RecentChanges API Docs
|
13
|
+
# @param limit [Fixnum] See {MediaWiki::Query::Lists::Log#get_log}
|
14
|
+
# @see https://www.mediawiki.org/wiki/API:RecentChanges MediaWiki RecentChanges API Docs
|
17
15
|
# @since 0.10.0
|
18
|
-
# @return [Array<Hash
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
time_format = MediaWiki::Constants::TIME_FORMAT
|
24
|
-
prop = 'user|comment|parsedcomment|timestamp|title|ids|sha1|sizes' \
|
25
|
-
'|redirect|flags|loginfo'
|
16
|
+
# @return [Array<Hash<Symbol, Any>>] All of the changes, with the following keys: type, title, revid,
|
17
|
+
# old_revid, rcid, user, old_length, new_length, diff_length, timestamp, comment, parsed_comment, sha, new,
|
18
|
+
# minor, bot.
|
19
|
+
def get_recent_changes(user = nil, start = nil, stop = nil, limit = @query_limit_default)
|
20
|
+
prop = 'user|comment|parsedcomment|timestamp|title|ids|sha1|sizes|redirect|flags|loginfo'
|
26
21
|
rights = get_userrights
|
27
22
|
patrol = false
|
28
23
|
if rights != false && rights.include?('patrol')
|
@@ -36,8 +31,8 @@ module MediaWiki
|
|
36
31
|
rclimit: get_limited(limit)
|
37
32
|
}
|
38
33
|
params[:rcuser] = user unless user.nil?
|
39
|
-
params[:rcstart] = start.
|
40
|
-
params[:rcend] = stop.
|
34
|
+
params[:rcstart] = start.xmlschema unless start.nil?
|
35
|
+
params[:rcend] = stop.xmlschema unless stop.nil?
|
41
36
|
|
42
37
|
response = post(params)
|
43
38
|
ret = []
|
@@ -56,7 +51,7 @@ module MediaWiki
|
|
56
51
|
old_length: old_length,
|
57
52
|
new_length: new_length,
|
58
53
|
diff_length: diff_length,
|
59
|
-
timestamp: DateTime.
|
54
|
+
timestamp: DateTime.xmlschema(change['timestamp']),
|
60
55
|
comment: change['comment'],
|
61
56
|
parsed_comment: change['parsedcomment'],
|
62
57
|
sha: change['sha1']
|
@@ -80,34 +75,27 @@ module MediaWiki
|
|
80
75
|
end
|
81
76
|
|
82
77
|
# Gets the recent deleted revisions.
|
83
|
-
# @param
|
84
|
-
# @
|
85
|
-
# @param stop [DateTime] See {#get_recent_changes}
|
86
|
-
# @param limit [Int] See {#get_recent_changes}
|
87
|
-
# @see https://www.mediawiki.org/wiki/API:Deletedrevs MediaWiki
|
88
|
-
# Deletedrevs API Docs
|
78
|
+
# @param (see #get_recent_changes)
|
79
|
+
# @see https://www.mediawiki.org/wiki/API:Deletedrevs MediaWiki Deletedrevs API Docs
|
89
80
|
# @since 0.10.0
|
90
|
-
# @return [Array<Hash>] All of the changes, with the following keys:
|
91
|
-
|
92
|
-
def get_recent_deleted_revisions(user = nil, start = nil, stop = nil,
|
93
|
-
limit = 500)
|
94
|
-
time_format = MediaWiki::Constants::TIME_FORMAT
|
81
|
+
# @return [Array<Hash>] All of the changes, with the following keys: timestamp, user, comment, title.
|
82
|
+
def get_recent_deleted_revisions(user = nil, start = nil, stop = nil, limit = @query_limit_default)
|
95
83
|
prop = 'revid|parentid|user|comment|parsedcomment|minor|len|sh1|tags'
|
96
84
|
params = {
|
97
85
|
action: 'query',
|
98
86
|
list: 'deletedrevs',
|
99
87
|
drprop: prop,
|
100
|
-
|
88
|
+
drlimit: get_limited(limit)
|
101
89
|
}
|
102
|
-
params[:drstart] = start.
|
103
|
-
params[:drend] = stop.
|
90
|
+
params[:drstart] = start.xmlschema unless start.nil?
|
91
|
+
params[:drend] = stop.xmlschema unless stop.nil?
|
104
92
|
|
105
93
|
response = post(params)
|
106
94
|
ret = []
|
107
95
|
response['query']['deletedrevs'].each do |rev|
|
108
96
|
r = rev['revisions'][0]
|
109
97
|
hash = {
|
110
|
-
timestamp: DateTime.
|
98
|
+
timestamp: DateTime.xmlschema(r['timestamp']),
|
111
99
|
user: r['user'],
|
112
100
|
comment: r['comment'],
|
113
101
|
title: rev['title']
|
@@ -4,50 +4,36 @@ module MediaWiki
|
|
4
4
|
module Search
|
5
5
|
# Gets the amount of results for the search value.
|
6
6
|
# @param search_value [String] The thing to search for.
|
7
|
-
# @param namespace [
|
8
|
-
#
|
9
|
-
# @see https://www.mediawiki.org/wiki/API:Search MediaWiki Search API
|
10
|
-
# Docs
|
7
|
+
# @param namespace [Fixnum] The namespace to search in. Defaults to 0 (the main namespace).
|
8
|
+
# @see https://www.mediawiki.org/wiki/API:Search MediaWiki Search API Docs
|
11
9
|
# @since 0.4.0
|
12
|
-
# @return [
|
10
|
+
# @return [Fixnum] The number of pages that matched the search.
|
13
11
|
def get_search_result_amount(search_value, namespace = 0)
|
14
12
|
params = {
|
15
13
|
action: 'query',
|
16
14
|
list: 'search',
|
17
|
-
srsearch: search_value
|
15
|
+
srsearch: search_value,
|
16
|
+
srnamespace: validate_namespace(namespace)
|
18
17
|
}
|
19
18
|
|
20
|
-
if MediaWiki::Constants::NAMEPSACES.value?(namespace)
|
21
|
-
params[:srnamespace] = namespace
|
22
|
-
else
|
23
|
-
params[:srnamespace] = 0
|
24
|
-
end
|
25
|
-
|
26
19
|
response = post(params)
|
27
20
|
response['query']['searchinfo']['totalhits']
|
28
21
|
end
|
29
22
|
|
30
23
|
# Gets an array containing page titles that matched the search.
|
31
24
|
# @param search_value [String] The thing to search for.
|
32
|
-
# @param namespace [
|
33
|
-
#
|
34
|
-
# @see https://www.mediawiki.org/wiki/API:Search MediaWiki Search API
|
35
|
-
# Docs
|
25
|
+
# @param namespace [Fixnum] The namespace to search in. Defaults to 0 (the main namespace).
|
26
|
+
# @see https://www.mediawiki.org/wiki/API:Search MediaWiki Search API Docs
|
36
27
|
# @since 0.4.0
|
37
|
-
# @return [Array] The page titles that matched the search.
|
28
|
+
# @return [Array<String>] The page titles that matched the search.
|
38
29
|
def get_search_results(search_value, namespace = 0)
|
39
30
|
params = {
|
40
31
|
action: 'query',
|
41
32
|
list: 'search',
|
42
|
-
srsearch: search_value
|
33
|
+
srsearch: search_value,
|
34
|
+
srnamespace: validate_namespace(namespace)
|
43
35
|
}
|
44
36
|
|
45
|
-
if MediaWiki::Constants::NAMESPACES.value?(namespace)
|
46
|
-
params[:srnamespace] = namespace
|
47
|
-
else
|
48
|
-
params[:srnamespace] = 0
|
49
|
-
end
|
50
|
-
|
51
37
|
response = post(params)
|
52
38
|
|
53
39
|
ret = []
|
@@ -58,10 +44,9 @@ module MediaWiki
|
|
58
44
|
|
59
45
|
# Searches the wiki by a prefix.
|
60
46
|
# @param prefix [String] The prefix.
|
61
|
-
# @param limit [
|
62
|
-
#
|
63
|
-
# @see https://www.mediawiki.org/wiki/API:Prefixsearch MediaWiki
|
64
|
-
# Prefixsearch API Docs
|
47
|
+
# @param limit [Fixnum] The maximum number of results to get, maximum of 100 for users and 200 for bots. This is
|
48
|
+
# one of the methods that does *not* use the query_limit_default attribute.
|
49
|
+
# @see https://www.mediawiki.org/wiki/API:Prefixsearch MediaWiki Prefixsearch API Docs
|
65
50
|
# @since 0.10.0
|
66
51
|
# @return [Array<String>] All of the page titles that match the search.
|
67
52
|
def get_prefix_search(prefix, limit = 100)
|
@@ -69,7 +54,7 @@ module MediaWiki
|
|
69
54
|
action: 'query',
|
70
55
|
list: 'prefixsearch',
|
71
56
|
pssearch: prefix,
|
72
|
-
|
57
|
+
pslimit: get_limited(limit, 100, 200)
|
73
58
|
}
|
74
59
|
|
75
60
|
response = post(params)
|
@@ -5,20 +5,16 @@ module MediaWiki
|
|
5
5
|
# Gets user information. This method should rarely be used by
|
6
6
|
# normal users, unless they want a huge amount of user data at once.
|
7
7
|
# @param prop [String] The usprop parameter.
|
8
|
-
# @param username [String] The username to get info for. Optional.
|
9
|
-
#
|
10
|
-
# @see https://www.mediawiki.org/wiki/API:Users MediaWiki User Lists API
|
11
|
-
# Docs
|
8
|
+
# @param username [String] The username to get info for. Optional. Defaults to the currently logged in user
|
9
|
+
# if omitted.
|
10
|
+
# @see https://www.mediawiki.org/wiki/API:Users MediaWiki User Lists API Docs
|
12
11
|
# @since 0.3.0
|
13
12
|
# @return [String] Parsed full response if successful.
|
14
13
|
# @return [Nil] If the username is nil and the Butt is not logged in.
|
15
14
|
def get_userlists(prop, username = nil)
|
16
15
|
if username.nil?
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
return false
|
21
|
-
end
|
16
|
+
return unless @logged_in
|
17
|
+
response = get_current_user_meta(prop)
|
22
18
|
else
|
23
19
|
params = {
|
24
20
|
action: 'query',
|
@@ -34,25 +30,21 @@ module MediaWiki
|
|
34
30
|
end
|
35
31
|
|
36
32
|
# Gets an array of all the user's groups.
|
37
|
-
# @param username [String] The username to get groups of. Optional.
|
38
|
-
# Defaults to the currently logged in user.
|
33
|
+
# @param username [String] The username to get groups of. Optional. Defaults to the currently logged in user.
|
39
34
|
# @see get_userlists
|
40
35
|
# @since 0.3.0
|
41
|
-
# @return [Array] All of the user's groups.
|
36
|
+
# @return [Array<String>] All of the user's groups.
|
42
37
|
# @return [Boolean] False if username is nil and not logged in.
|
43
38
|
def get_usergroups(username = nil)
|
44
39
|
ret = []
|
45
40
|
if username.nil?
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
else
|
50
|
-
return false
|
51
|
-
end
|
41
|
+
return false unless @logged_in
|
42
|
+
info = get_userlists('groups')
|
43
|
+
info['query']['userinfo']['groups'].each { |i| ret << i }
|
52
44
|
else
|
53
45
|
info = get_userlists('groups', username)
|
54
46
|
info['query']['users'].each do |i|
|
55
|
-
i['groups'].each { |g| ret
|
47
|
+
i['groups'].each { |g| ret << g }
|
56
48
|
end
|
57
49
|
end
|
58
50
|
|
@@ -60,26 +52,22 @@ module MediaWiki
|
|
60
52
|
end
|
61
53
|
|
62
54
|
# Gets the user rights for the user.
|
63
|
-
# @param username [String] The user to get the rights for. Optional.
|
64
|
-
# Defaults to the currently logged in user.
|
55
|
+
# @param username [String] The user to get the rights for. Optional. Defaults to the currently logged in user.
|
65
56
|
# @see get_userlists
|
66
57
|
# @since 0.3.0
|
67
|
-
# @return [Array] All of the user's groups.
|
58
|
+
# @return [Array<String>] All of the user's groups.
|
68
59
|
# @return [Boolean] False if username is nil and not logged in.
|
69
60
|
def get_userrights(username = nil)
|
70
61
|
ret = []
|
71
62
|
if username.nil?
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
else
|
76
|
-
return false
|
77
|
-
end
|
63
|
+
return false unless @logged_in
|
64
|
+
info = get_userlists('rights')
|
65
|
+
info['query']['userinfo']['rights'].each { |i| ret << i }
|
78
66
|
else
|
79
67
|
info = get_userlists('rights', username)
|
80
68
|
info['query']['users'].each do |i|
|
81
69
|
i['rights'].each do |g|
|
82
|
-
ret
|
70
|
+
ret << g
|
83
71
|
end
|
84
72
|
end
|
85
73
|
end
|
@@ -88,21 +76,18 @@ module MediaWiki
|
|
88
76
|
end
|
89
77
|
|
90
78
|
# Gets contribution count for the user.
|
91
|
-
# @param username [String] The username to get the contribution count of.
|
92
|
-
#
|
79
|
+
# @param username [String] The username to get the contribution count of. Optional. Defaults to the currently
|
80
|
+
# logged in user.
|
93
81
|
# @see get_userlists
|
94
82
|
# @since 0.3.0
|
95
83
|
# @return [Boolean] False if username is nil and not logged in.
|
96
|
-
# @return [
|
84
|
+
# @return [Fixnum] The number of contributions the user has made.
|
97
85
|
def get_contrib_count(username = nil)
|
98
86
|
count = nil
|
99
87
|
if username.nil?
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
else
|
104
|
-
return false
|
105
|
-
end
|
88
|
+
return false unless @logged_in
|
89
|
+
info = get_userlists('editcount')
|
90
|
+
count = info['query']['userinfo']['editcount']
|
106
91
|
else
|
107
92
|
info = get_userlists('editcount', username)
|
108
93
|
info['query']['users'].each { |i| count = i['editcount'] }
|
@@ -112,8 +97,8 @@ module MediaWiki
|
|
112
97
|
end
|
113
98
|
|
114
99
|
# Gets when the user registered.
|
115
|
-
# @param username [String] The username to get the registration date and
|
116
|
-
#
|
100
|
+
# @param username [String] The username to get the registration date and time of. Optional. Defaults to the
|
101
|
+
# currently logged in user.
|
117
102
|
# @see get_userlists
|
118
103
|
# @since 0.4.0
|
119
104
|
# @return [DateTime] The registration date and time as a DateTime object.
|
@@ -122,12 +107,9 @@ module MediaWiki
|
|
122
107
|
time = nil
|
123
108
|
# Do note that in Userinfo, registration is called registrationdate.
|
124
109
|
if username.nil?
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
else
|
129
|
-
return false
|
130
|
-
end
|
110
|
+
return false unless @logged_in
|
111
|
+
info = get_userlists('registrationdate')
|
112
|
+
time = info['query']['userinfo']['registrationdate']
|
131
113
|
else
|
132
114
|
info = get_userlists('registration', username)
|
133
115
|
info['query']['users'].each { |i| time = i['registration'] }
|
@@ -153,14 +135,14 @@ module MediaWiki
|
|
153
135
|
|
154
136
|
# Gets the latest contributions by the user until the limit.
|
155
137
|
# @param user [String] The username.
|
156
|
-
# @param limit [
|
157
|
-
# @see https://www.mediawiki.org/wiki/API:Usercontribs MediaWiki
|
158
|
-
# User Contributions API Docs
|
138
|
+
# @param limit [Fixnum] See #{get_all_images}.
|
139
|
+
# @see https://www.mediawiki.org/wiki/API:Usercontribs MediaWiki User Contributions API Docs
|
159
140
|
# @since 0.8.0
|
160
|
-
# @return [Hash] Each contribution by its revid, containing the title,
|
161
|
-
#
|
162
|
-
#
|
163
|
-
|
141
|
+
# @return [Hash<Fixnum, Hash<Symbol, Any>>] Each contribution by its revid, containing the title, summary,
|
142
|
+
# total
|
143
|
+
# contribution size, and
|
144
|
+
# the size change relative to the previous edit.
|
145
|
+
def get_user_contributions(user, limit = @query_limit_default)
|
164
146
|
params = {
|
165
147
|
action: 'query',
|
166
148
|
list: 'usercontribs',
|
@@ -184,19 +166,19 @@ module MediaWiki
|
|
184
166
|
ret
|
185
167
|
end
|
186
168
|
|
187
|
-
# Gets the user's full watchlist. If no user is provided, it will use the
|
188
|
-
#
|
169
|
+
# Gets the user's full watchlist. If no user is provided, it will use the currently logged in user, according
|
170
|
+
# to the MediaWiki API.
|
189
171
|
# @param user [String] The username.
|
190
|
-
# @param limit [
|
191
|
-
# @see https://www.mediawiki.org/wiki/API:Watchlist MediaWiki Watchlist
|
192
|
-
# API Docs
|
172
|
+
# @param limit [Fixnum] See #{get_all_images}.
|
173
|
+
# @see https://www.mediawiki.org/wiki/API:Watchlist MediaWiki Watchlist API Docs
|
193
174
|
# @since 0.8.0
|
194
|
-
# @return [Array] All the watchlist page titles.
|
195
|
-
def get_full_watchlist(user = nil, limit =
|
175
|
+
# @return [Array<String>] All the watchlist page titles.
|
176
|
+
def get_full_watchlist(user = nil, limit = @query_limit_default)
|
196
177
|
params = {
|
197
178
|
action: 'query',
|
198
179
|
list: 'watchlist',
|
199
|
-
wlprop: 'title'
|
180
|
+
wlprop: 'title',
|
181
|
+
wllimit: get_limited(limit)
|
200
182
|
}
|
201
183
|
params[:wluser] = user unless user.nil?
|
202
184
|
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module MediaWiki
|
2
2
|
module Query
|
3
3
|
module Meta
|
4
|
-
# @see https://www.mediawiki.org/wiki/API:Filerepoinfo MediaWiki
|
5
|
-
# Filerepoinfo API Docs
|
4
|
+
# @see https://www.mediawiki.org/wiki/API:Filerepoinfo MediaWiki Filerepoinfo API Docs
|
6
5
|
module FileRepoInfo
|
7
6
|
# Gets FileRepoInfo for the property.
|
8
7
|
# @param prop [String] The friprop to get.
|
9
8
|
# @since 0.7.0
|
10
|
-
# @return [
|
9
|
+
# @return [Hash] The full parsed response.
|
11
10
|
def get_filerepoinfo(prop)
|
12
11
|
params = {
|
13
12
|
action: 'query',
|
@@ -20,33 +19,32 @@ module MediaWiki
|
|
20
19
|
|
21
20
|
# Returns an array of all the wiki's file repository names.
|
22
21
|
# @since 0.1.0
|
23
|
-
# @return [
|
22
|
+
# @return [Hash<String, String>] All wiki's file repository names. Keys are names, values are display names.
|
24
23
|
def get_filerepo_names
|
25
24
|
response = get_filerepoinfo('name|displayname')
|
26
25
|
ret = {}
|
27
|
-
response['query']['repos'].each { |
|
26
|
+
response['query']['repos'].each { |h| ret[h['name']] = h['displayname'] }
|
28
27
|
ret
|
29
28
|
end
|
30
29
|
|
31
30
|
# Gets the root URLs for the file repositories.
|
32
31
|
# @since 0.7.0
|
33
|
-
# @return [Hash] A hash containing keys of the names, and values of the
|
34
|
-
# root URLs.
|
32
|
+
# @return [Hash<String, String>] A hash containing keys of the names, and values of the root URLs.
|
35
33
|
def get_filerepo_rooturls
|
36
34
|
response = get_filerepoinfo('name|rootUrl')
|
37
35
|
ret = {}
|
38
|
-
response['query']['repos'].each { |
|
36
|
+
response['query']['repos'].each { |h| ret[h['name']] = h['rootUrl'] }
|
39
37
|
ret
|
40
38
|
end
|
41
39
|
|
42
40
|
# Gets an array containing all local repositories.
|
43
41
|
# @since 0.7.0
|
44
|
-
# @return [Array] All
|
42
|
+
# @return [Array<String>] All repository names that are marked as local.
|
45
43
|
def get_local_filerepos
|
46
44
|
response = get_filerepoinfo('name|local')
|
47
45
|
ret = []
|
48
|
-
response['query']['repos'].each do |
|
49
|
-
ret
|
46
|
+
response['query']['repos'].each do |h|
|
47
|
+
ret << h['name'] if h.key?('local')
|
50
48
|
end
|
51
49
|
|
52
50
|
ret
|
@@ -54,12 +52,12 @@ module MediaWiki
|
|
54
52
|
|
55
53
|
# Gets an array containing all repositories that aren't local.
|
56
54
|
# @since 0.7.0
|
57
|
-
# @return [Array] All repositories that are not marked as local.
|
55
|
+
# @return [Array<String>] All repositories that are not marked as local.
|
58
56
|
def get_nonlocal_filerepos
|
59
57
|
response = get_filerepoinfo('name|local')
|
60
58
|
ret = []
|
61
|
-
response['query']['repos'].each do |
|
62
|
-
ret
|
59
|
+
response['query']['repos'].each do |h|
|
60
|
+
ret << h['name'] unless h.key?('local')
|
63
61
|
end
|
64
62
|
|
65
63
|
ret
|
@@ -67,31 +65,31 @@ module MediaWiki
|
|
67
65
|
|
68
66
|
# Gets the repository names and their according URLs.
|
69
67
|
# @since 0.7.0
|
70
|
-
# @return [Hash] Names as the keys, with their URLs as the values.
|
68
|
+
# @return [Hash<String, String>] Names as the keys, with their URLs as the values.
|
71
69
|
def get_filerepo_urls
|
72
70
|
response = get_filerepoinfo('name|url')
|
73
71
|
ret = {}
|
74
|
-
response['query']['repos'].each { |
|
72
|
+
response['query']['repos'].each { |h| ret[h['name']] = h['url'] }
|
75
73
|
ret
|
76
74
|
end
|
77
75
|
|
78
76
|
# Gets the repository names and their accoring thumbnail URLs.
|
79
77
|
# @since 0.7.0
|
80
|
-
# @return [Hash] Names as the keys, with their URLs as the values.
|
78
|
+
# @return [Hash<String, String>] Names as the keys, with their URLs as the values.
|
81
79
|
def get_filerepo_thumburls
|
82
80
|
response = get_filerepoinfo('name|thumbUrl')
|
83
81
|
ret = {}
|
84
|
-
response['query']['repos'].each { |
|
82
|
+
response['query']['repos'].each { |h| ret[h['name']] = h['thumbUrl'] }
|
85
83
|
ret
|
86
84
|
end
|
87
85
|
|
88
86
|
# Gets the repository names and their according favicon URLs.
|
89
87
|
# @since 0.7.0
|
90
|
-
# @return [Hash] Names as the keys, with their favicons as the values.
|
88
|
+
# @return [Hash<String, String>] Names as the keys, with their favicons as the values.
|
91
89
|
def get_filerepo_favicons
|
92
90
|
response = get_filerepoinfo('name|favicon')
|
93
91
|
ret = {}
|
94
|
-
response['query']['repos'].each { |
|
92
|
+
response['query']['repos'].each { |h| ret[h['name']] = h['favicon'] }
|
95
93
|
ret
|
96
94
|
end
|
97
95
|
end
|