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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -5
  3. data/lib/mediawiki/administration.rb +18 -17
  4. data/lib/mediawiki/auth.rb +52 -193
  5. data/lib/mediawiki/butt.rb +51 -32
  6. data/lib/mediawiki/constants.rb +127 -130
  7. data/lib/mediawiki/edit.rb +58 -71
  8. data/lib/mediawiki/exceptions.rb +2 -123
  9. data/lib/mediawiki/query/lists/all.rb +35 -45
  10. data/lib/mediawiki/query/lists/backlinks.rb +23 -34
  11. data/lib/mediawiki/query/lists/categories.rb +17 -28
  12. data/lib/mediawiki/query/lists/log/block.rb +17 -33
  13. data/lib/mediawiki/query/lists/log/delete.rb +8 -24
  14. data/lib/mediawiki/query/lists/log/import.rb +9 -24
  15. data/lib/mediawiki/query/lists/log/log.rb +36 -63
  16. data/lib/mediawiki/query/lists/log/merge.rb +5 -12
  17. data/lib/mediawiki/query/lists/log/move.rb +6 -20
  18. data/lib/mediawiki/query/lists/log/newusers.rb +13 -36
  19. data/lib/mediawiki/query/lists/log/patrol.rb +5 -13
  20. data/lib/mediawiki/query/lists/log/protect.rb +20 -50
  21. data/lib/mediawiki/query/lists/log/rights.rb +10 -24
  22. data/lib/mediawiki/query/lists/log/upload.rb +10 -24
  23. data/lib/mediawiki/query/lists/miscellaneous.rb +10 -19
  24. data/lib/mediawiki/query/lists/querypage.rb +60 -62
  25. data/lib/mediawiki/query/lists/recent_changes.rb +18 -30
  26. data/lib/mediawiki/query/lists/search.rb +14 -29
  27. data/lib/mediawiki/query/lists/users.rb +43 -61
  28. data/lib/mediawiki/query/meta/filerepoinfo.rb +18 -20
  29. data/lib/mediawiki/query/meta/siteinfo.rb +30 -33
  30. data/lib/mediawiki/query/meta/userinfo.rb +48 -66
  31. data/lib/mediawiki/query/properties/contributors.rb +18 -22
  32. data/lib/mediawiki/query/properties/files.rb +18 -20
  33. data/lib/mediawiki/query/properties/pages.rb +129 -211
  34. data/lib/mediawiki/query/properties/properties.rb +20 -25
  35. data/lib/mediawiki/query/query.rb +0 -25
  36. data/lib/mediawiki/utils.rb +9 -8
  37. data/lib/mediawiki/watch.rb +52 -0
  38. metadata +6 -4
@@ -2,17 +2,14 @@ module MediaWiki
2
2
  module Query
3
3
  module Lists
4
4
  module Backlinks
5
- # Gets an array of backlinks to a given title, like
6
- # Special:WhatLinksHere.
5
+ # Gets an array of backlinks to a given title, like Special:WhatLinksHere.
7
6
  # @param title [String] The page to get the backlinks of.
8
- # @param limit [Int] The maximum number of pages to get. Defaults to
9
- # 500, and cannot be greater than that unless the user is a bot. If
10
- # the user is a bot, the limit cannot be greater than 5000.
11
- # @see https://www.mediawiki.org/wiki/API:Backlinks MediaWiki Backlinks
12
- # API Docs
7
+ # @param limit [Fixnum] The maximum number of pages to get. Defaults to query_limit_default attribute. Cannot be
8
+ # greater than 500 for users or 5000 for bots.
9
+ # @see https://www.mediawiki.org/wiki/API:Backlinks MediaWiki Backlinks API Docs
13
10
  # @since 0.1.0
14
11
  # @return [Array<String>] All backlinks until the limit
15
- def what_links_here(title, limit = 500)
12
+ def what_links_here(title, limit = @query_limit_default)
16
13
  params = {
17
14
  action: 'query',
18
15
  list: 'backlinks',
@@ -30,12 +27,11 @@ module MediaWiki
30
27
  # Gets interwiki backlinks by the prefix and title.
31
28
  # @param prefix [String] The wiki prefix, e.g., "mcw".
32
29
  # @param title [String] The title of the page on that wiki.
33
- # @param limit [Int] See #what_links_here.
34
- # @see https://www.mediawiki.org/wiki/API:Iwbacklinks MediaWiki
35
- # Iwbacklinks API Docs
30
+ # @param limit [Fixnum] See {#what_links_here}.
31
+ # @see https://www.mediawiki.org/wiki/API:Iwbacklinks MediaWiki Iwbacklinks API Docs
36
32
  # @since 0.10.0
37
33
  # @return [Array<String>] All interwiki backlinking page titles.
38
- def get_interwiki_backlinks(prefix = nil, title = nil, limit = 500)
34
+ def get_interwiki_backlinks(prefix = nil, title = nil, limit = @query_limit_default)
39
35
  params = {
40
36
  action: 'query',
41
37
  list: 'iwbacklinks',
@@ -53,14 +49,12 @@ module MediaWiki
53
49
 
54
50
  # Gets language backlinks by the language and title.
55
51
  # @param language [String] The language code
56
- # @param title [String] The page title.
57
- # @param limit [Int] See {#what_links_here}
58
- # @see https://www.mediawiki.org/wiki/API:Langlinks MediaWiki Langlinks
59
- # API Docs
52
+ # @param (see #what_links_here)
53
+ # @see https://www.mediawiki.org/wiki/API:Langlinks MediaWiki Langlinks API Docs
60
54
  # @since 0.10.0
61
55
  # @return [Array<String>] All pages that link to the language links.
62
- def get_language_backlinks(language = nil, title = nil, limit = 500)
63
- language.downcase! if language.match(/[^A-Z]*/)[0].size == 0
56
+ def get_language_backlinks(language = nil, title = nil, limit = @query_limit_default)
57
+ language.downcase! if language.match(/[^A-Z]*/)[0].empty?
64
58
  params = {
65
59
  action: 'query',
66
60
  list: 'langbacklinks',
@@ -77,19 +71,14 @@ module MediaWiki
77
71
  end
78
72
 
79
73
  # Gets image backlinks, or the pages that use a given image.
80
- # @param title [String] The image.
81
- # @param list_redirects [Nil/Boolean] Set to nil to list redirects and
82
- # non-redirects. Set to true to only list redirects. Set to false to
83
- # only list non-redirects.
84
- # @param thru_redirect [Boolean] Whether to list pages that link to a
85
- # redirect of the image.
86
- # @param limit [Int] See {#what_links_here}
87
- # @see https://www.mediawiki.org/wiki/API:Imageusage MediaWiki
88
- # Imageusage API Docs
74
+ # @param (see #what_links_here)
75
+ # @param list_redirects [Nil/Boolean] Set to nil to list redirects and non-redirects. Set to true to only
76
+ # list redirects. Set to false to only list non-redirects.
77
+ # @param thru_redir [Boolean] Whether to list pages that link to a redirect of the image.
78
+ # @see https://www.mediawiki.org/wiki/API:Imageusage MediaWiki Imageusage API Docs
89
79
  # @since 0.10.0
90
80
  # @return [Array<String>] All page titles that fit the requirements.
91
- def get_image_backlinks(title, list_redirects = nil, thru_redir = false,
92
- limit = 500)
81
+ def get_image_backlinks(title, list_redirects = nil, thru_redir = false, limit = @query_limit_default)
93
82
  params = {
94
83
  action: 'query',
95
84
  list: 'imageusage',
@@ -109,13 +98,13 @@ module MediaWiki
109
98
 
110
99
  # Gets all external link page titles.
111
100
  # @param url [String] The URL to get backlinks for.
112
- # @param limit [Int] See {#what_links_here}
113
- # @see https://www.mediawiki.org/wiki/API:Exturlusage MediaWiki
114
- # Exturlusage API Docs
101
+ # @param limit [Fixnum] See {#what_links_here}
102
+ # @see https://www.mediawiki.org/wiki/API:Exturlusage MediaWiki Exturlusage API Docs
115
103
  # @since 0.10.0
116
104
  # @return [Array<String>] All pages that link to the given URL.
117
- # @return [Array<Hash>] All pages that link to any external links.
118
- def get_url_backlinks(url = nil, limit = 500)
105
+ # @return [Array<Hash<Symbol, String>>] All pages that link to any external links. There are 2 keys in each
106
+ # hash, url and title.
107
+ def get_url_backlinks(url = nil, limit = @query_limit_default)
119
108
  params = {
120
109
  action: 'query',
121
110
  list: 'exturlusage',
@@ -2,24 +2,16 @@ module MediaWiki
2
2
  module Query
3
3
  module Lists
4
4
  module Categories
5
- # Returns an array of all page titles that belong to a given category.
6
- # By default, it will only get the pages. Files and subcategories can
7
- # be gotten through {#get_subcategories} and {#get_files_in_category}
8
- # or setting the type parameter.
9
- # @param category [String] The category title. It can include
10
- # "Category:", or not, it doesn't really matter because we will add it
11
- # if it is missing.
12
- # @param limit [Int] The maximum number of members to get. Defaults to
13
- # 500, and cannot be greater than that unless the user is a bot.
14
- # If the user is a bot, the limit cannot be greater than 5000.
15
- # @param type [String] The type of stuff to get. There are 3 valid
16
- # values: page, file, and subcat. Separate these with a pipe
17
- # character, e.g., 'page|file|subcat'.
18
- # @see https://www.mediawiki.org/wiki/API:Categorymembers MediaWiki
19
- # Category Members API Docs
5
+ # Returns an array of all page titles that belong to a given category. By default, it will only get the pages.
6
+ # Files and subcategories can be gotten through {#get_subcategories} and {#get_files_in_category} or setting
7
+ # the type parameter.
8
+ # @param (see #get_subcategories)
9
+ # @param type [String] The type of stuff to get. There are 3 valid values: page, file, and subcat. Separate
10
+ # these with a pipe character, e.g., 'page|file|subcat'.
11
+ # @see https://www.mediawiki.org/wiki/API:Categorymembers MediaWiki Category Members API Docs
20
12
  # @since 0.1.0
21
- # @return [Array] All category members until the limit
22
- def get_category_members(category, limit = 500, type = 'page')
13
+ # @return [Array<String>] All category members until the limit
14
+ def get_category_members(category, limit = @query_limit_default, type = 'page')
23
15
  params = {
24
16
  action: 'query',
25
17
  list: 'categorymembers',
@@ -28,11 +20,7 @@ module MediaWiki
28
20
  cmtype: type
29
21
  }
30
22
 
31
- if category =~ /[Cc]ategory\:/
32
- params[:cmtitle] = category
33
- else
34
- params[:cmtitle] = "Category:#{category}"
35
- end
23
+ params[:cmtitle] = category =~ /[Cc]ategory:/ ? category : "Category:#{category}"
36
24
  ret = []
37
25
  response = post(params)
38
26
  response['query']['categorymembers'].each { |cm| ret << cm['title'] }
@@ -41,22 +29,23 @@ module MediaWiki
41
29
  end
42
30
 
43
31
  # Gets the subcategories of a given category.
44
- # @param category [String] See {#get_category_members}
45
- # @param limit [Int] See {#get_category_members}
32
+ # @param category [String] The category title. It can include "Category:", or not, it doesn't really matter
33
+ # because we will add it if it is missing.
34
+ # @param limit [Fixnum] The maximum number of members to get. Defaults to query_limit_default attribute. Cannot
35
+ # be greater than 500 for users, 5000 for bots.
46
36
  # @see {#get_category_members}
47
37
  # @since 0.9.0
48
38
  # @return [Array<String>] All subcategories.
49
- def get_subcategories(category, limit = 500)
39
+ def get_subcategories(category, limit = @query_limit_default)
50
40
  get_category_members(category, limit, 'subcat')
51
41
  end
52
42
 
53
43
  # Gets all of the files in a given category.
54
- # @param category [String] See {#get_category_members}
55
- # @param limit [Int] See {#get_category_members}
44
+ # @param (see #get_subcategories)
56
45
  # @see {#get_category_members}
57
46
  # @since 0.9.0
58
47
  # @return [Array<String>] All files in the category.
59
- def get_files_in_category(category, limit = 500)
48
+ def get_files_in_category(category, limit = @query_limit_default)
60
49
  get_category_members(category, limit, 'file')
61
50
  end
62
51
  end
@@ -10,39 +10,30 @@ module MediaWiki
10
10
  # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
11
11
  # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
12
12
  # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
13
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
14
- # @see {MediaWiki::Query::Lists::Log#get_log}
15
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
16
- # Logevents API Docs
13
+ # @param limit [Fixnum] See {MediaWiki::Query::Lists::Log#get_log}
14
+ # @see MediaWiki::Query::Lists::Log#get_log
15
+ # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki Logevents API Docs
17
16
  # @since 0.10.0
18
- # @return [Array<Hash>] The events, containing the following keys: id,
19
- # blocked, flags, duration, expiry, blocker, comment, timestamp.
20
- def get_block_log(user = nil, title = nil, start = nil, stop = nil,
21
- limit = 500)
17
+ # @return [Array<Hash>] The events, containing the following keys: id, blocked, flags, duration, expiry,
18
+ # blocker, comment, timestamp.
19
+ def get_block_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
22
20
  response = get_log('block/block', user, title, start, stop, limit)
23
21
 
24
22
  ret = []
25
23
  response['query']['logevents'].each do |log|
26
- ret << get_blockblock(log)
24
+ ret << get_block(log)
27
25
  end
28
26
 
29
27
  ret
30
28
  end
31
29
 
32
30
  # Gets block/reblock logs.
33
- # @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
34
- # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
35
- # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
36
- # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
37
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
38
- # @see {MediaWiki::Query::Lists::Log#get_log}
39
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
40
- # Logevents API Docs
31
+ # @param (see #get_block_log)
32
+ # @see (see #get_block_log)
41
33
  # @since 0.10.0
42
- # @return [Array<Hash>] The events, containing the following keys: id,
43
- # blocked, flags, duration, expiry, blocker, comment, timestamp.
44
- def get_reblock_log(user = nil, title = nil, start = nil, stop = nil,
45
- limit = 500)
34
+ # @return [Array<Hash<Symbol, Any>>] The events, containing the following keys: id, blocked, flags, duration,
35
+ # expiry, blocker, comment, timestamp.
36
+ def get_reblock_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
46
37
  response = get_log('block/reblock', user, title, start, stop, limit)
47
38
 
48
39
  ret = []
@@ -54,19 +45,12 @@ module MediaWiki
54
45
  end
55
46
 
56
47
  # Gets block/unblock logs.
57
- # @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
58
- # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
59
- # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
60
- # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
61
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
62
- # @see {MediaWiki::Query::Lists::Log#get_log}
63
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
64
- # Logevents API Docs
48
+ # @param (see #get_block_log)
49
+ # @see (see #get_block_log)
65
50
  # @since 0.10.0
66
- # @return [Array<Hash>] The events, containing the following keys: id,
67
- # blocked, blocker, comment, timestamp.
68
- def get_unblock_log(user = nil, title = nil, start = nil, stop = nil,
69
- limit = 500)
51
+ # @return [Array<Hash<Symbol, Any>>] The events, containing the following keys: id, blocked, blocker,
52
+ # comment, timestamp.
53
+ def get_unblock_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
70
54
  response = get_log('block/unblock', user, title, start, stop, limit)
71
55
 
72
56
  ret = []
@@ -6,19 +6,11 @@ module MediaWiki
6
6
  # @todo delete/revision
7
7
  module Delete
8
8
  # Gets delete/delete logs.
9
- # @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
10
- # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
11
- # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
12
- # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
13
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
14
- # @see {MediaWiki::Query::Lists::Log#get_log}
15
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
16
- # Logevents API Docs
9
+ # @param (see MediaWiki::Query::Lists::Log::Block#get_block_log)
10
+ # @see (see MediaWiki::Query::Lists::Log::Block#get_block_log)
17
11
  # @since 0.10.0
18
- # @return [Array<Hash>] The events, containing the following keys: id,
19
- # title, user, comment, timestamp.
20
- def get_delete_log(user = nil, title = nil, start = nil, stop = nil,
21
- limit = 500)
12
+ # @return [Array<Hash>] The events, containing the following keys: id, title, user, comment, timestamp.
13
+ def get_delete_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
22
14
  response = get_log('delete/delete', user, title, start, stop, limit)
23
15
 
24
16
  ret = []
@@ -30,19 +22,11 @@ module MediaWiki
30
22
  end
31
23
 
32
24
  # Gets delete/restore logs.
33
- # @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
34
- # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
35
- # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
36
- # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
37
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
38
- # @see {MediaWiki::Query::Lists::Log#get_log}
39
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
40
- # Logevents API Docs
25
+ # @param (see MediaWiki::Query::Lists::Log::Block#get_block_log)
26
+ # @see (see MediaWiki::Query::Lists::Log::Block#get_block_log)
41
27
  # @since 0.10.0
42
- # @return [Array<Hash>] The events, containing the following keys: id,
43
- # title, user, comment, timestamp.
44
- def get_deletion_restore_log(user = nil, title = nil, start = nil,
45
- stop = nil, limit = 500)
28
+ # @return [Array<Hash>] The events, containing the following keys: id, title, user, comment, timestamp.
29
+ def get_deletion_restore_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
46
30
  resp = get_log('delete/restore', user, title, start, stop, limit)
47
31
 
48
32
  ret = []
@@ -4,19 +4,12 @@ module MediaWiki
4
4
  module Log
5
5
  module Import
6
6
  # Gets import/interwiki logs.
7
- # @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
8
- # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
9
- # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
10
- # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
11
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
12
- # @see {MediaWiki::Query::Lists::Log#get_log}
13
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
14
- # Logevents API Docs
7
+ # @param (see MediaWiki::Query::Lists::Log::Block#get_block_log)
8
+ # @see (see MediaWiki::Query::Lists::Log::Block#get_block_log)
15
9
  # @since 0.10.0
16
- # @return [Array<Hash>] The events, containing the following keys: id,
17
- # title, user, comment, timestamp, count, interwiki_title.
18
- def get_interwiki_import_log(user = nil, title = nil, start = nil,
19
- stop = nil, limit = 500)
10
+ # @return [Array<Hash>] The events, containing the following keys: id, title, user, comment, timestamp,
11
+ # count, interwiki_title.
12
+ def get_interwiki_import_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
20
13
  resp = get_log('import/interwiki', user, title, start, stop, limit)
21
14
 
22
15
  ret = []
@@ -28,19 +21,11 @@ module MediaWiki
28
21
  end
29
22
 
30
23
  # Gets import/upload logs.
31
- # @param user [String] See {MediaWiki::Query::Lists::Log#get_log}
32
- # @param title [String] See {MediaWiki::Query::Lists::Log#get_log}
33
- # @param start [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
34
- # @param stop [DateTime] See {MediaWiki::Query::Lists::Log#get_log}
35
- # @param limit [Int] See {MediaWiki::Query::Lists::Log#get_log}
36
- # @see {MediaWiki::Query::Lists::Log#get_log}
37
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki
38
- # Logevents API Docs
24
+ # @param (see MediaWiki::Query::Lists::Log::Block#get_block_log)
25
+ # @see (see MediaWiki::Query::Lists::Log::Block#get_block_log)
39
26
  # @since 0.10.0
40
- # @return [Array<Hash>] The events, containing the following keys: id,
41
- # title, user, timestamp, comment.
42
- def get_upload_import_log(user = nil, title = nil, start = nil,
43
- stop = nil, limit = 500)
27
+ # @return [Array<Hash>] The events, containing the following keys: id, title, user, timestamp, comment.
28
+ def get_upload_import_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
44
29
  resp = get_log('import/upload', user, title, start, stop, limit)
45
30
 
46
31
  ret = []
@@ -25,23 +25,18 @@ module MediaWiki
25
25
  include MediaWiki::Query::Lists::Log::Rights
26
26
  include MediaWiki::Query::Lists::Log::Upload
27
27
 
28
- # Gets the general log as seen in Special:Log. Since not every single
29
- # log type possible can be supported, non-default MW logs will be
30
- # represented exactly as provided by the API, with the :skipped key
31
- # as true.
32
- # @param user [String] See {#get_log}
33
- # @param title [String] See {#get_log}
34
- # @param start [DateTime] See {#get_log}
35
- # @param stop [DateTime] See {#get_log}
36
- # @param limit [Int] See {#get_log}
37
- # @see {#get_log}
38
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki Logevents
39
- # API Docs
28
+ # Gets the general log as seen in Special:Log. Since not every single log type possible can be supported,
29
+ # non-default MW logs will be represented exactly as provided by the API, with the :skipped key as true.
30
+ # @param user [String] The user to filter by.
31
+ # @param title [String] The title to filter by.
32
+ # @param start [DateTime] Where to start the log events at.
33
+ # @param stop [DateTime] Where to end the log events.
34
+ # @param limit [Fixnum] The limit, maximum 500 for users or 5000 for bots.
35
+ # @see #get_log
36
+ # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki Logevents API Docs
40
37
  # @since 0.10.0
41
38
  # @return [Array<Hash>] All the log events.
42
- def get_overall_log(user = nil, title = nil, start = nil, stop = nil,
43
- limit = 500)
44
- time_format = MediaWiki::Constants::TIME_FORMAT
39
+ def get_overall_log(user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
45
40
  params = {
46
41
  action: 'query',
47
42
  list: 'logevents',
@@ -49,8 +44,8 @@ module MediaWiki
49
44
  }
50
45
  params[:leuser] = user unless user.nil?
51
46
  params[:letitle] = title unless title.nil?
52
- params[:lestart] = start.strftime(time_format) unless start.nil?
53
- params[:leend] = stop.strftime(time_format) unless stop.nil?
47
+ params[:lestart] = start.xmlschema unless start.nil?
48
+ params[:leend] = stop.xmlschema unless stop.nil?
54
49
  response = post(params)
55
50
 
56
51
  ret = []
@@ -137,17 +132,11 @@ module MediaWiki
137
132
 
138
133
  # Gets log events.
139
134
  # @param action [String] The action, e.g., block/block.
140
- # @param user [String] The user to filter by.
141
- # @param title [String] The title to filter by.
142
- # @param start [DateTime] Where to start the log events at.
143
- # @param stop [DateTime] Where to end the log events.
144
- # @param limit [Int] The limit, maximum 500 for users or 5000 for bots.
145
- # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki Logevents
146
- # API Docs
135
+ # @param (see #get_overall_log)
136
+ # @see https://www.mediawiki.org/wiki/API:Logevents MediaWiki Logevents API Docs
147
137
  # @since 0.10.0
148
- # @return [JSON] The response json.
149
- def get_log(action, user = nil, title = nil, start = nil, stop = nil,
150
- limit = 500)
138
+ # @return [Hash] The response.
139
+ def get_log(action, user = nil, title = nil, start = nil, stop = nil, limit = @query_limit_default)
151
140
  params = {
152
141
  action: 'query',
153
142
  list: 'logevents',
@@ -156,8 +145,8 @@ module MediaWiki
156
145
  }
157
146
  params[:leuser] = user unless user.nil?
158
147
  params[:letitle] = title unless title.nil?
159
- params[:lestart] = start.strftime(MediaWiki::Constants::TIME_FORMAT) unless start.nil?
160
- params[:leend] = stop.strftime(MediaWiki::Constants::TIME_FORMAT) unless stop.nil?
148
+ params[:lestart] = start.xmlschema unless start.nil?
149
+ params[:leend] = stop.xmlschema unless stop.nil?
161
150
  post(params)
162
151
  end
163
152
 
@@ -167,12 +156,10 @@ module MediaWiki
167
156
  blocked: log['title'],
168
157
  flags: log['block']['flags'],
169
158
  duration: log['block']['duration'],
170
- expiry: DateTime.strptime(log['block']['expiry'],
171
- MediaWiki::Constants::TIME_FORMAT),
159
+ expiry: DateTime.xmlschema(log['block']['expiry']),
172
160
  blocker: log['user'],
173
161
  comment: log['comment'],
174
- timestamp: DateTime.strptime(log['timestamp'],
175
- MediaWiki::Constants::TIME_FORMAT)
162
+ timestamp: DateTime.xmlschema(log['timestamp'])
176
163
  }
177
164
  end
178
165
 
@@ -181,8 +168,7 @@ module MediaWiki
181
168
  id: log['logid'],
182
169
  blocked: log['title'],
183
170
  blocker: log['user'],
184
- timestamp: DateTime.strptime(log['timestamp'],
185
- MediaWiki::Constants::TIME_FORMAT),
171
+ timestamp: DateTime.xmlschema(log['timestamp']),
186
172
  comment: log['comment']
187
173
  }
188
174
  end
@@ -193,8 +179,7 @@ module MediaWiki
193
179
  title: log['title'],
194
180
  user: log['user'],
195
181
  comment: log['comment'],
196
- timestamp: DateTime.strptime(log['timestamp'],
197
- MediaWiki::Constants::TIME_FORMAT),
182
+ timestamp: DateTime.xmlschema(log['timestamp']),
198
183
  count: log['params']['count'],
199
184
  interwiki_title: log['params']['interwiki_title']
200
185
  }
@@ -205,8 +190,7 @@ module MediaWiki
205
190
  id: log['logid'],
206
191
  title: log['title'],
207
192
  user: log['user'],
208
- timestamp: DateTime.strptime(log['timestamp'],
209
- MediaWiki::Constants::TIME_FORMAT),
193
+ timestamp: DateTime.xmlschema(log['timestamp']),
210
194
  comment: log['comment']
211
195
  }
212
196
  end
@@ -218,18 +202,15 @@ module MediaWiki
218
202
  user: log['user'],
219
203
  comment: log['comment'],
220
204
  destination_title: log['params']['dest_title'],
221
- mergepoint: DateTime.strptime(log['params']['mergepoint'],
222
- MediaWiki::Constants::TIME_FORMAT),
223
- timestamp: DateTime.strptime(log['timestamp'],
224
- MediaWiki::Constants::TIME_FORMAT)
205
+ mergepoint: DateTime.xmlschema(log['params']['mergepoint']),
206
+ timestamp: DateTime.xmlschema(log['timestamp'])
225
207
  }
226
208
  end
227
209
 
228
210
  def get_move(log)
229
211
  hash = {
230
212
  id: log['logid'],
231
- timestamp: DateTime.strptime(log['timestamp'],
232
- MediaWiki::Constants::TIME_FORMAT)
213
+ timestamp: DateTime.xmlschema(log['timestamp'])
233
214
  }
234
215
 
235
216
  if log.key?('actionhidden')
@@ -255,8 +236,7 @@ module MediaWiki
255
236
  new_user: log['title'],
256
237
  user: log['user'],
257
238
  comment: log['comment'],
258
- timestamp: DateTime.strptime(log['timestamp'],
259
- MediaWiki::Constants::TIME_FORMAT)
239
+ timestamp: DateTime.xmlschema(log['timestamp'])
260
240
  }
261
241
  end
262
242
 
@@ -268,8 +248,7 @@ module MediaWiki
268
248
  comment: log['comment'],
269
249
  current_revision: log['patrol']['cur'],
270
250
  previous_revision: log['patrol']['prev'],
271
- timestamp: DateTime.strptime(log['timestamp'],
272
- MediaWiki::Constants::TIME_FORMAT)
251
+ timestamp: DateTime.xmlschema(log['timestamp'])
273
252
  }
274
253
  auto = log['patrol']['auto']
275
254
  hash[:automatic] = auto == 1
@@ -278,14 +257,13 @@ module MediaWiki
278
257
  end
279
258
 
280
259
  def get_protect(log)
281
- time_format = MediaWiki::Constants::TIME_FORMAT
282
260
  hash = {
283
261
  id: log['logid'],
284
262
  title: log['title'],
285
263
  description: log['params']['description'],
286
264
  user: log['user'],
287
265
  comment: log['comment'],
288
- timestamp: DateTime.strptime(log['timestamp'], time_format)
266
+ timestamp: DateTime.xmlschema(log['timestamp'])
289
267
  }
290
268
 
291
269
  hash[:details] = []
@@ -297,9 +275,9 @@ module MediaWiki
297
275
  }
298
276
  expire = detail['expiry']
299
277
  if expire != 'infinite'
300
- details_hash[:expiry] = DateTime.strptime(expire, time_format)
278
+ details_hash[:expiry] = DateTime.xmlschema(expire)
301
279
  end
302
- hash[:details] << detail_hash
280
+ hash[:details] << details_hash
303
281
  end
304
282
 
305
283
  hash
@@ -312,8 +290,7 @@ module MediaWiki
312
290
  old_title: log['params']['oldtitle_title'],
313
291
  user: log['user'],
314
292
  comment: log['comment'],
315
- timestamp: DateTime.strptime(log['timestamp'],
316
- MediaWiki::Constants::TIME_FORMAT)
293
+ timestamp: DateTime.xmlschema(log['timestamp'])
317
294
  }
318
295
  end
319
296
 
@@ -323,8 +300,7 @@ module MediaWiki
323
300
  title: log['title'],
324
301
  user: log['user'],
325
302
  comment: log['comment'],
326
- timestamp: DateTime.strptime(log['timestamp'],
327
- MediaWiki::Constants::TIME_FORMAT)
303
+ timestamp: DateTime.xmlschema(log['timestamp'])
328
304
  }
329
305
  end
330
306
 
@@ -336,8 +312,7 @@ module MediaWiki
336
312
  new_rights: log['rights']['new'].split(', '),
337
313
  old_rights: log['rights']['old'].split(', '),
338
314
  comment: log['comment'],
339
- timestamp: DateTime.strptime(log['timestamp'],
340
- MediaWiki::Constants::TIME_FORMAT)
315
+ timestamp: DateTime.xmlschema(log['timestamp'])
341
316
  }
342
317
  end
343
318
 
@@ -350,8 +325,7 @@ module MediaWiki
350
325
  new_rights: log['rights']['new'].split(', '),
351
326
  old_rights: log['rights']['old'].split(', '),
352
327
  comment: log['comment'],
353
- timestamp: DateTime.strptime(log['timestamp'],
354
- MediaWiki::Constants::TIME_FORMAT)
328
+ timestamp: DateTime.xmlschema(log['timestamp'])
355
329
  }
356
330
  end
357
331
 
@@ -362,8 +336,7 @@ module MediaWiki
362
336
  user: log['user'],
363
337
  sha: log['img_sha1'],
364
338
  comment: log['comment'],
365
- timestamp: DateTime.strptime(log['timestamp'],
366
- MediaWiki::Constants::TIME_FORMAT)
339
+ timestamp: DateTime.xmlschema(log['timestamp'])
367
340
  }
368
341
  end
369
342
  end