mediawiki-butt 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3bb16cf6fe52c692e7ca6aea0db8761fa4a3af0
4
- data.tar.gz: 6e5132d8fcc1972b89ccc3ad6ca666a0fd11446d
3
+ metadata.gz: 4f09a41fd00c3ff2e7f5bc1cafa03ed5d950b5cc
4
+ data.tar.gz: 60402f6721be863aeb428c13933cfdcc5e9214ed
5
5
  SHA512:
6
- metadata.gz: 6f2b25dfd88316f079dd30055e4b16788a16bc2397a9fa743aac8b6194961dad881628c12c60733e179f53150ab0785c3492865748753fdb48cc232721a570a4
7
- data.tar.gz: 0fd0998139a5687b931a74b125f9b60ed4aef78bac71544e87fd7c2e295ef155f1c900e349bf09c2011af2849257034f3933d4d74337c37f7af5ae41ce3d7a2e
6
+ metadata.gz: f4023e04f09486f94ad4b6af55d889e6b5aa39af713842c5b1574ddd2c0929d847c0d2581e2e6933676b9fb3877d3e0b577fa19ce11e4cbfa2d2b85b2b79252d
7
+ data.tar.gz: deea5c87cdf91d334f97e62f6c065ae6f71fed9ca9ac1ae56a512c17ebbfb207eaab7fd6f80ff032cc7bd5f900f90e832bab5534b23ca7822c9542239f79afd2
@@ -5,7 +5,8 @@ module MediaWiki
5
5
  # @param expiry [String] The expiry timestamp using a relative expiry time.
6
6
  # @param reason [String] The reason to show in the block log.
7
7
  # @param nocreate [Boolean] Whether to allow them to create an account.
8
- # @return [String/Int] The error code, or the block ID.
8
+ # @return [String] The error code.
9
+ # @return [Int] The block ID.
9
10
  def block(user, expiry = '2 weeks', reason = nil, nocreate = true)
10
11
  params = {
11
12
  action: 'block',
@@ -30,7 +31,8 @@ module MediaWiki
30
31
  # Unblocks the user.
31
32
  # @param user [String] The user to unblock.
32
33
  # @param reason [String] The reason to show in the block log.
33
- # @return [String/Int] The error code, or the block ID.
34
+ # @return [String] The error code.
35
+ # @return [Int] The block ID.
34
36
  def unblock(user, reason = nil)
35
37
  params = {
36
38
  action: 'unblock',
@@ -14,7 +14,7 @@ module MediaWiki
14
14
  include MediaWiki::Query::Meta::UserInfo
15
15
  include MediaWiki::Query::Properties
16
16
  include MediaWiki::Query::Lists
17
- include MediaWiki::Constants::Namespaces
17
+ include MediaWiki::Constants
18
18
  include MediaWiki::Edit
19
19
  include MediaWiki::Administration
20
20
 
@@ -23,14 +23,14 @@ module MediaWiki
23
23
  # @param url [String] The FULL wiki URL. api.php can be omitted, but it
24
24
  # will make harsh assumptions about your wiki configuration.
25
25
  # @param use_ssl [Boolean] Whether or not to use SSL. Will default to true.
26
- # @return [MediaWiki::Butt] new instance of MediaWiki::Butt
27
- def initialize(url, use_ssl = true)
26
+ # @param custom_agent [String] A custom User-Agent to use. Optional.
27
+ def initialize(url, use_ssl = true, custom_agent = nil)
28
28
  @url = url =~ /api.php$/ ? url : "#{url}/api.php"
29
-
30
29
  @client = HTTPClient.new
31
30
  @uri = URI.parse(@url)
32
31
  @ssl = use_ssl
33
32
  @logged_in = false
33
+ @custom_agent = custom_agent unless custom_agent.nil?
34
34
  @tokens = {}
35
35
  end
36
36
 
@@ -42,8 +42,8 @@ module MediaWiki
42
42
  # @param autoparse [Boolean] Whether or not to provide a parsed version
43
43
  # of the response's JSON. Will default to true.
44
44
  # @param header [Hash] The header hash. Optional.
45
- # @return [JSON/HTTPMessage] Parsed JSON if autoparse is true, or raw
46
- # response if not.
45
+ # @return [JSON/HTTPMessage] Parsed JSON if autoparse is true.
46
+ # @return [HTTPMessage] Raw HTTP response.
47
47
  def post(params, autoparse = true, header = nil)
48
48
  # Note that defining the header argument as a splat argument (*header)
49
49
  # causes errors in HTTPClient. We must use header.nil? rather than a
@@ -56,11 +56,8 @@ module MediaWiki
56
56
  params[:format] = 'json'
57
57
  header = {} if header.nil?
58
58
 
59
- if @logged_in == false
60
- header['User-Agent'] = 'NotLoggedIn/MediaWiki::Butt'
61
- else
62
- header['User-Agent'] = "#{@name}/MediaWiki::Butt"
63
- end
59
+ header['User-Agent'] = @logged_in ? "#{@name}/MediaWiki::Butt" : 'NotLoggedIn/MediaWiki::Butt'
60
+ header['User-Agent'] = @custom_agent if defined? @custom_agent
64
61
 
65
62
  res = @client.post(@uri, params, header)
66
63
 
@@ -1,219 +1,217 @@
1
1
  module MediaWiki
2
2
  module Constants
3
- # Constants Namespace IDs. Taken from https://www.mediawiki.org/wiki/Extension_default_namespaces
4
- module Namespaces
5
- $namespaces = {
6
- 'MAIN' => 0,
7
- 'TALK' => 1,
8
- 'USER' => 2,
9
- 'USER_TALK' => 3,
10
- 'PROJECT' => 4,
11
- 'PROJECT_TALK' => 5,
12
- 'FILE' => 6,
13
- 'FILE_TALK' => 7,
14
- 'MEDIAWIKI' => 8,
15
- 'MEDIAWIKI_TALK' => 9,
16
- 'TEMPLATE' => 10,
17
- 'TEMPLATE_TALK' => 11,
18
- 'HELP' => 12,
19
- 'HELP_TALK' => 13,
20
- 'CATEGORY' => 14,
21
- 'CATEGORY_TALK' => 15,
22
- 'SPECIAL' => -1,
23
- 'MEDIA' => -2,
24
-
25
- # Extension:LiquidThreads
26
- 'LQT_THREAD' => 90,
27
- 'LQT_THREAD_TALK' => 91,
28
- 'LQT_SUMMARY' => 92,
29
- 'LQT_SUMMARY_TALK' => 93,
30
-
31
- # Extension:Semantic MediaWiki / Extension:Semantic Forms
32
- 'SMW_RELATION' => 100,
33
- 'SMW_RELATION_TALK' => 101,
34
- 'SMW_PROPERTY' => 102,
35
- 'SMW_PROPERTY_TALK' => 103,
36
- 'SMW_TYPE' => 104,
37
- 'SMW_TYPE_TALK' => 105,
38
- 'SMW_FORM' => 106,
39
- 'SMW_FORM_TALK' => 107,
40
- 'SF_CONCEPT' => 108,
41
- 'SF_CONCEPT_TALK' => 109,
42
-
43
- # Extension:DPLforum
44
- 'DPLF_FORUM' => 110,
45
- 'DPLF_FORUM_TAlK' => 111,
46
-
47
- # Extension:RefHelper
48
- 'RFH_CITE' => 120,
49
- 'RFH_CITE_TALK' => 121,
50
-
51
- # Extension:SemanticAccessControl
52
- 'ACL_USERGROUP' => 160,
53
- 'ACL_ACL' => 162,
54
-
55
- # Extension:Semantic Drilldown
56
- 'SED_FILTER' => 170,
57
- 'SED_FILTER_TALK' => 171,
58
-
59
- # Extension:SocialProfile
60
- 'SCP_USERWIKI' => 200,
61
- 'SCP_USERWIKI_TALK' => 201,
62
- 'SCP_USERPROFILE' => 202,
63
- 'SCP_USERPROFILE_TALK' => 203,
64
-
65
- # Extension:Proofread Page
66
- 'PRP_PAGE' => 250,
67
- 'PRP_PAGE_TALK' => 251,
68
- 'PRP_INDEX' => 252,
69
- 'PRP_INDEX_TALK' => 253,
70
-
71
- # Extension:TrustedMath
72
- 'TRM_MATH' => 262,
73
- 'TRM_MATH_TALK' => 263,
74
-
75
- # Extension:Widgets
76
- 'WID_WIDGET' => 274,
77
- 'WID_WIDGET_TALK' => 275,
78
-
79
- # Extension:EmbedScript
80
- 'EMS_JSAPPLET' => 280,
81
- 'EMS_JSAPPLET_TALK' => 281,
82
-
83
- # Extension:PollNY
84
- 'PLN_POLL' => 300,
85
- 'PLN_POLL_TALK' => 301,
86
-
87
- # Extension:Semantic Image Annotator
88
- 'SIA_IMAGE_ANNOTATOR' => 380,
89
-
90
- # Extension:Wiki2LaTeX
91
- 'WTL_WIKI2LATEX' => 400,
92
- 'WTL_WIKI2LATEX_TALK' => 401,
93
-
94
- # Extension:Workflow
95
- 'WRF_WORKFLOW' => 410,
96
- 'WRF_WORKFLOW_TALK' => 411,
97
-
98
- # Extension:Maps
99
- 'MAP_LAYER' => 420,
100
- 'MAP_LAYER_TALK' => 421,
101
-
102
- # Extension:QuizTabulate
103
- 'QTB_QUIZ' => 430,
104
- 'QTB_QUIZ_TALK' => 431,
105
-
106
- # Extension:Education Program
107
- 'EDP_EDUCATION_PROGRAM' => 446,
108
- 'EDP_EDUCATION_PROGRAM_TALK' => 447,
109
-
110
- # Extension:BoilerRoom
111
- 'BLR_BOILERPLATE' => 450,
112
- 'BLR_BOILERPLATE_TALK' => 451,
113
-
114
- # Extension:UploadWizard
115
- 'UPW_CAMPAIGN' => 460,
116
- 'UPW_CAMPAIGN_TALK' => 461,
117
-
118
- # Extension:EventLogging
119
- 'ELG_SCHEMA' => 470,
120
- 'ELG_SCHEMA_TALK' => 471,
121
-
122
- # Extension:ZeroBanner
123
- 'ZRB_ZERO' => 480,
124
- 'ZRB_ZERO_TALK' => 481,
125
-
126
- # Extension:JsonConfig
127
- 'JSC_CONFIG' => 482,
128
- 'JSC_CONFIG_TALK' => 483,
129
- 'JSC_DATA' => 486,
130
- 'JSC_DATA_TALK' => 487,
131
-
132
- # Extension:Graph
133
- 'GRP_GRAPH' => 484,
134
- 'GRP_GRAPH_TALK' => 485,
135
-
136
- # Extension:OpenStackManager
137
- 'OSM_NOVA_RESOURCE' => 488,
138
- 'OSM_NOVA_RESOURCE_TALK' => 489,
139
-
140
- # Extension:GWToolset
141
- 'GWT_GWTOOLSET' => 490,
142
- 'GWT_GWTOOLSET_TALK' => 491,
143
-
144
- # Extension:BlogPage
145
- 'BLP_BLOG' => 500,
146
- 'BLP_BLOG_TALK' => 501,
147
-
148
- # Extension:XMLContentExtension
149
- 'XCE_XML' => 580,
150
- 'XCE_XML_TALK' => 581,
151
- 'XCE_SCHEMA' => 582,
152
- 'XCE_SCHEMA_TALK' => 583,
153
-
154
- # Extension:FanBoxes
155
- 'FNB_USERBOX' => 600,
156
- 'FNB_USERBOX_TALK' => 601,
157
-
158
- # Extension:LinkFilter
159
- 'LFT_LINK' => 700,
160
- 'LFT_LINK_TALK' => 701,
161
-
162
- # Extension:TimedMediaHandler
163
- 'TMH_TIMEDTEXT' => 710,
164
- 'TMH_TIMEDTEXT_TALK' => 711,
165
-
166
- # Extension:QPoll
167
- 'QPL_INTERPRETATION' => 800,
168
- 'QPL_INTERPRETATION_TALK' => 801,
169
-
170
- # Extension:SemanticMustacheFormat :3,
171
- 'SMF_MUSTACHE' => 806,
172
- 'SMF_MUSTACHE_TALK' => 807,
173
-
174
- # Extension:R
175
- 'R_R' => 814,
176
- 'R_R_TALK' => 815,
177
-
178
- # Extension:Scribunto
179
- 'SCR_MODULE' => 828,
180
- 'SCR_MODULE_TALK' => 829,
181
-
182
- # Extension:SecurePoll
183
- 'SEP_SECUREPOLL' => 830,
184
- 'SEP_SECUREPOLL_TALK' => 831,
185
-
186
- # Extension:CentralNotice
187
- 'CNT_CNBANNER' => 866,
188
- 'CNT_CNBANNER_TALK' => 867,
189
-
190
- # Extension:Translate
191
- 'TRN_TRANSLATIONS' => 1198,
192
- 'TRN_TRANSLATIOTALK' => 1199,
193
-
194
- # Extension:PackageForce
195
- 'PKF_PACKAGEFORCE' => 1300,
196
- 'PKF_PACKAGEFORCE_TALK' => 1301,
197
-
198
- # Extension:BlueSpice
199
- 'BLS_BLOG' => 1502,
200
- 'BLS_BLOG_TALK' => 1503,
201
- 'BLS_BOOK' => 1504,
202
- 'BLS_BOOK_TALK' => 1505,
203
-
204
- # Extension:Gadgets
205
- 'GDG_GADGET' => 2300,
206
- 'GDG_GADGET_TALK' => 2301,
207
- 'GDG_GADGET_DEFININTION' => 2302,
208
- 'GDG_GADGET_DEFININTION_TALK' => 2303,
209
-
210
- # Extension:VisualEditor
211
- 'VSE_VISUALEDITOR' => 2500,
212
- 'VSE_VISUALEDITOR_TALK' => 2501,
213
-
214
- # Extension:Flow
215
- 'FLW_TOPIC' => 2600
216
- }
217
- end
3
+ # Taken from https://www.mediawiki.org/wiki/Extension_default_namespaces
4
+ NAMESPACES = {
5
+ 'MAIN' => 0,
6
+ 'TALK' => 1,
7
+ 'USER' => 2,
8
+ 'USER_TALK' => 3,
9
+ 'PROJECT' => 4,
10
+ 'PROJECT_TALK' => 5,
11
+ 'FILE' => 6,
12
+ 'FILE_TALK' => 7,
13
+ 'MEDIAWIKI' => 8,
14
+ 'MEDIAWIKI_TALK' => 9,
15
+ 'TEMPLATE' => 10,
16
+ 'TEMPLATE_TALK' => 11,
17
+ 'HELP' => 12,
18
+ 'HELP_TALK' => 13,
19
+ 'CATEGORY' => 14,
20
+ 'CATEGORY_TALK' => 15,
21
+ 'SPECIAL' => -1,
22
+ 'MEDIA' => -2,
23
+
24
+ # Extension:LiquidThreads
25
+ 'LQT_THREAD' => 90,
26
+ 'LQT_THREAD_TALK' => 91,
27
+ 'LQT_SUMMARY' => 92,
28
+ 'LQT_SUMMARY_TALK' => 93,
29
+
30
+ # Extension:Semantic MediaWiki / Extension:Semantic Forms
31
+ 'SMW_RELATION' => 100,
32
+ 'SMW_RELATION_TALK' => 101,
33
+ 'SMW_PROPERTY' => 102,
34
+ 'SMW_PROPERTY_TALK' => 103,
35
+ 'SMW_TYPE' => 104,
36
+ 'SMW_TYPE_TALK' => 105,
37
+ 'SMW_FORM' => 106,
38
+ 'SMW_FORM_TALK' => 107,
39
+ 'SF_CONCEPT' => 108,
40
+ 'SF_CONCEPT_TALK' => 109,
41
+
42
+ # Extension:DPLforum
43
+ 'DPLF_FORUM' => 110,
44
+ 'DPLF_FORUM_TAlK' => 111,
45
+
46
+ # Extension:RefHelper
47
+ 'RFH_CITE' => 120,
48
+ 'RFH_CITE_TALK' => 121,
49
+
50
+ # Extension:SemanticAccessControl
51
+ 'ACL_USERGROUP' => 160,
52
+ 'ACL_ACL' => 162,
53
+
54
+ # Extension:Semantic Drilldown
55
+ 'SED_FILTER' => 170,
56
+ 'SED_FILTER_TALK' => 171,
57
+
58
+ # Extension:SocialProfile
59
+ 'SCP_USERWIKI' => 200,
60
+ 'SCP_USERWIKI_TALK' => 201,
61
+ 'SCP_USERPROFILE' => 202,
62
+ 'SCP_USERPROFILE_TALK' => 203,
63
+
64
+ # Extension:Proofread Page
65
+ 'PRP_PAGE' => 250,
66
+ 'PRP_PAGE_TALK' => 251,
67
+ 'PRP_INDEX' => 252,
68
+ 'PRP_INDEX_TALK' => 253,
69
+
70
+ # Extension:TrustedMath
71
+ 'TRM_MATH' => 262,
72
+ 'TRM_MATH_TALK' => 263,
73
+
74
+ # Extension:Widgets
75
+ 'WID_WIDGET' => 274,
76
+ 'WID_WIDGET_TALK' => 275,
77
+
78
+ # Extension:EmbedScript
79
+ 'EMS_JSAPPLET' => 280,
80
+ 'EMS_JSAPPLET_TALK' => 281,
81
+
82
+ # Extension:PollNY
83
+ 'PLN_POLL' => 300,
84
+ 'PLN_POLL_TALK' => 301,
85
+
86
+ # Extension:Semantic Image Annotator
87
+ 'SIA_IMAGE_ANNOTATOR' => 380,
88
+
89
+ # Extension:Wiki2LaTeX
90
+ 'WTL_WIKI2LATEX' => 400,
91
+ 'WTL_WIKI2LATEX_TALK' => 401,
92
+
93
+ # Extension:Workflow
94
+ 'WRF_WORKFLOW' => 410,
95
+ 'WRF_WORKFLOW_TALK' => 411,
96
+
97
+ # Extension:Maps
98
+ 'MAP_LAYER' => 420,
99
+ 'MAP_LAYER_TALK' => 421,
100
+
101
+ # Extension:QuizTabulate
102
+ 'QTB_QUIZ' => 430,
103
+ 'QTB_QUIZ_TALK' => 431,
104
+
105
+ # Extension:Education Program
106
+ 'EDP_EDUCATION_PROGRAM' => 446,
107
+ 'EDP_EDUCATION_PROGRAM_TALK' => 447,
108
+
109
+ # Extension:BoilerRoom
110
+ 'BLR_BOILERPLATE' => 450,
111
+ 'BLR_BOILERPLATE_TALK' => 451,
112
+
113
+ # Extension:UploadWizard
114
+ 'UPW_CAMPAIGN' => 460,
115
+ 'UPW_CAMPAIGN_TALK' => 461,
116
+
117
+ # Extension:EventLogging
118
+ 'ELG_SCHEMA' => 470,
119
+ 'ELG_SCHEMA_TALK' => 471,
120
+
121
+ # Extension:ZeroBanner
122
+ 'ZRB_ZERO' => 480,
123
+ 'ZRB_ZERO_TALK' => 481,
124
+
125
+ # Extension:JsonConfig
126
+ 'JSC_CONFIG' => 482,
127
+ 'JSC_CONFIG_TALK' => 483,
128
+ 'JSC_DATA' => 486,
129
+ 'JSC_DATA_TALK' => 487,
130
+
131
+ # Extension:Graph
132
+ 'GRP_GRAPH' => 484,
133
+ 'GRP_GRAPH_TALK' => 485,
134
+
135
+ # Extension:OpenStackManager
136
+ 'OSM_NOVA_RESOURCE' => 488,
137
+ 'OSM_NOVA_RESOURCE_TALK' => 489,
138
+
139
+ # Extension:GWToolset
140
+ 'GWT_GWTOOLSET' => 490,
141
+ 'GWT_GWTOOLSET_TALK' => 491,
142
+
143
+ # Extension:BlogPage
144
+ 'BLP_BLOG' => 500,
145
+ 'BLP_BLOG_TALK' => 501,
146
+
147
+ # Extension:XMLContentExtension
148
+ 'XCE_XML' => 580,
149
+ 'XCE_XML_TALK' => 581,
150
+ 'XCE_SCHEMA' => 582,
151
+ 'XCE_SCHEMA_TALK' => 583,
152
+
153
+ # Extension:FanBoxes
154
+ 'FNB_USERBOX' => 600,
155
+ 'FNB_USERBOX_TALK' => 601,
156
+
157
+ # Extension:LinkFilter
158
+ 'LFT_LINK' => 700,
159
+ 'LFT_LINK_TALK' => 701,
160
+
161
+ # Extension:TimedMediaHandler
162
+ 'TMH_TIMEDTEXT' => 710,
163
+ 'TMH_TIMEDTEXT_TALK' => 711,
164
+
165
+ # Extension:QPoll
166
+ 'QPL_INTERPRETATION' => 800,
167
+ 'QPL_INTERPRETATION_TALK' => 801,
168
+
169
+ # Extension:SemanticMustacheFormat :3,
170
+ 'SMF_MUSTACHE' => 806,
171
+ 'SMF_MUSTACHE_TALK' => 807,
172
+
173
+ # Extension:R
174
+ 'R_R' => 814,
175
+ 'R_R_TALK' => 815,
176
+
177
+ # Extension:Scribunto
178
+ 'SCR_MODULE' => 828,
179
+ 'SCR_MODULE_TALK' => 829,
180
+
181
+ # Extension:SecurePoll
182
+ 'SEP_SECUREPOLL' => 830,
183
+ 'SEP_SECUREPOLL_TALK' => 831,
184
+
185
+ # Extension:CentralNotice
186
+ 'CNT_CNBANNER' => 866,
187
+ 'CNT_CNBANNER_TALK' => 867,
188
+
189
+ # Extension:Translate
190
+ 'TRN_TRANSLATIONS' => 1198,
191
+ 'TRN_TRANSLATIOTALK' => 1199,
192
+
193
+ # Extension:PackageForce
194
+ 'PKF_PACKAGEFORCE' => 1300,
195
+ 'PKF_PACKAGEFORCE_TALK' => 1301,
196
+
197
+ # Extension:BlueSpice
198
+ 'BLS_BLOG' => 1502,
199
+ 'BLS_BLOG_TALK' => 1503,
200
+ 'BLS_BOOK' => 1504,
201
+ 'BLS_BOOK_TALK' => 1505,
202
+
203
+ # Extension:Gadgets
204
+ 'GDG_GADGET' => 2300,
205
+ 'GDG_GADGET_TALK' => 2301,
206
+ 'GDG_GADGET_DEFININTION' => 2302,
207
+ 'GDG_GADGET_DEFININTION_TALK' => 2303,
208
+
209
+ # Extension:VisualEditor
210
+ 'VSE_VISUALEDITOR' => 2500,
211
+ 'VSE_VISUALEDITOR_TALK' => 2501,
212
+
213
+ # Extension:Flow
214
+ 'FLW_TOPIC' => 2600
215
+ }
218
216
  end
219
217
  end