mediawiki-gateway 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/classes/MediaWiki/Config.html +12 -12
- data/doc/classes/MediaWiki/Gateway.html +167 -163
- data/doc/classes/MediaWiki.html +49 -12
- data/doc/created.rid +1 -1
- data/doc/files/README.html +6 -1
- data/doc/files/lib/media_wiki/config_rb.html +1 -1
- data/doc/files/lib/media_wiki/gateway_rb.html +1 -1
- data/doc/files/lib/media_wiki/utils_rb.html +1 -1
- data/doc/files/script/create_page_rb.html +1 -1
- data/doc/files/script/delete_batch_rb.html +1 -1
- data/doc/files/script/export_xml_rb.html +1 -1
- data/doc/files/script/get_page_rb.html +1 -1
- data/doc/files/script/import_xml_rb.html +1 -1
- data/doc/files/script/run_fake_media_wiki_rb.html +1 -1
- data/doc/files/script/upload_commons_rb.html +7 -1
- data/doc/files/script/upload_file_rb.html +1 -1
- data/doc/fr_method_index.html +24 -23
- data/lib/media_wiki/utils.rb +8 -1
- data/mediawiki-gateway.gemspec +6 -4
- data/spec/gateway_spec.rb +0 -24
- data/spec/utils_spec.rb +48 -0
- metadata +6 -4
@@ -86,27 +86,27 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
93
|
-
<a href="#
|
94
|
-
<a href="#
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
101
|
-
<a href="#
|
102
|
-
<a href="#
|
103
|
-
<a href="#
|
104
|
-
<a href="#
|
105
|
-
<a href="#
|
106
|
-
<a href="#
|
107
|
-
<a href="#
|
108
|
-
<a href="#
|
109
|
-
<a href="#
|
89
|
+
<a href="#M000008">create</a>
|
90
|
+
<a href="#M000009">delete</a>
|
91
|
+
<a href="#M000015">download</a>
|
92
|
+
<a href="#M000017">export</a>
|
93
|
+
<a href="#M000019">extensions</a>
|
94
|
+
<a href="#M000006">get</a>
|
95
|
+
<a href="#M000024">get_response</a>
|
96
|
+
<a href="#M000021">get_token</a>
|
97
|
+
<a href="#M000022">get_undelete_token</a>
|
98
|
+
<a href="#M000014">image_info</a>
|
99
|
+
<a href="#M000016">import</a>
|
100
|
+
<a href="#M000011">list</a>
|
101
|
+
<a href="#M000005">login</a>
|
102
|
+
<a href="#M000023">make_api_request</a>
|
103
|
+
<a href="#M000018">namespaces_by_prefix</a>
|
104
|
+
<a href="#M000004">new</a>
|
105
|
+
<a href="#M000007">render</a>
|
106
|
+
<a href="#M000012">search</a>
|
107
|
+
<a href="#M000020">semantic_query</a>
|
108
|
+
<a href="#M000010">undelete</a>
|
109
|
+
<a href="#M000013">upload</a>
|
110
110
|
</div>
|
111
111
|
</div>
|
112
112
|
|
@@ -141,11 +141,11 @@
|
|
141
141
|
<div id="methods">
|
142
142
|
<h3 class="section-bar">Public Class methods</h3>
|
143
143
|
|
144
|
-
<div id="method-
|
145
|
-
<a name="
|
144
|
+
<div id="method-M000004" class="method-detail">
|
145
|
+
<a name="M000004"></a>
|
146
146
|
|
147
147
|
<div class="method-heading">
|
148
|
-
<a href="#
|
148
|
+
<a href="#M000004" class="method-signature">
|
149
149
|
<span class="method-name">new</span><span class="method-args">(url, loglevel = Logger::WARN)</span>
|
150
150
|
</a>
|
151
151
|
</div>
|
@@ -166,8 +166,8 @@ href="http://en.wikipedia.org/w/api.php">en.wikipedia.org/w/api.php</a>")
|
|
166
166
|
</dd>
|
167
167
|
</dl>
|
168
168
|
<p><a class="source-toggle" href="#"
|
169
|
-
onclick="toggleCode('
|
170
|
-
<div class="method-source-code" id="
|
169
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
170
|
+
<div class="method-source-code" id="M000004-source">
|
171
171
|
<pre>
|
172
172
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 15</span>
|
173
173
|
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">loglevel</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>)
|
@@ -184,22 +184,22 @@ href="http://en.wikipedia.org/w/api.php">en.wikipedia.org/w/api.php</a>")
|
|
184
184
|
|
185
185
|
<h3 class="section-bar">Public Instance methods</h3>
|
186
186
|
|
187
|
-
<div id="method-
|
188
|
-
<a name="
|
187
|
+
<div id="method-M000008" class="method-detail">
|
188
|
+
<a name="M000008"></a>
|
189
189
|
|
190
190
|
<div class="method-heading">
|
191
|
-
<a href="#
|
191
|
+
<a href="#M000008" class="method-signature">
|
192
192
|
<span class="method-name">create</span><span class="method-args">(title, content, options={})</span>
|
193
193
|
</a>
|
194
194
|
</div>
|
195
195
|
|
196
196
|
<div class="method-description">
|
197
197
|
<p>
|
198
|
-
Create a <a href="Gateway.html#
|
198
|
+
Create a <a href="Gateway.html#M000004">new</a> page, or overwrite an
|
199
199
|
existing one
|
200
200
|
</p>
|
201
201
|
<dl>
|
202
|
-
<dt>title</dt><dd>Page title to <a href="Gateway.html#
|
202
|
+
<dt>title</dt><dd>Page title to <a href="Gateway.html#M000008">create</a> or overwrite,
|
203
203
|
string
|
204
204
|
|
205
205
|
</dd>
|
@@ -221,13 +221,13 @@ Options:
|
|
221
221
|
|
222
222
|
</li>
|
223
223
|
<li>[token] Use this existing edit token instead requesting a <a
|
224
|
-
href="Gateway.html#
|
224
|
+
href="Gateway.html#M000004">new</a> one (useful for bulk loads)
|
225
225
|
|
226
226
|
</li>
|
227
227
|
</ul>
|
228
228
|
<p><a class="source-toggle" href="#"
|
229
|
-
onclick="toggleCode('
|
230
|
-
<div class="method-source-code" id="
|
229
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
230
|
+
<div class="method-source-code" id="M000008-source">
|
231
231
|
<pre>
|
232
232
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 101</span>
|
233
233
|
101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>(<span class="ruby-identifier">title</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">options</span>={})
|
@@ -240,11 +240,11 @@ href="Gateway.html#M000003">new</a> one (useful for bulk loads)
|
|
240
240
|
</div>
|
241
241
|
</div>
|
242
242
|
|
243
|
-
<div id="method-
|
244
|
-
<a name="
|
243
|
+
<div id="method-M000009" class="method-detail">
|
244
|
+
<a name="M000009"></a>
|
245
245
|
|
246
246
|
<div class="method-heading">
|
247
|
-
<a href="#
|
247
|
+
<a href="#M000009" class="method-signature">
|
248
248
|
<span class="method-name">delete</span><span class="method-args">(title)</span>
|
249
249
|
</a>
|
250
250
|
</div>
|
@@ -255,13 +255,13 @@ Delete one page. (<a href="../MediaWiki.html">MediaWiki</a> API does not
|
|
255
255
|
support deleting multiple pages at a time.)
|
256
256
|
</p>
|
257
257
|
<dl>
|
258
|
-
<dt>title</dt><dd>Title of page to <a href="Gateway.html#
|
258
|
+
<dt>title</dt><dd>Title of page to <a href="Gateway.html#M000009">delete</a>
|
259
259
|
|
260
260
|
</dd>
|
261
261
|
</dl>
|
262
262
|
<p><a class="source-toggle" href="#"
|
263
|
-
onclick="toggleCode('
|
264
|
-
<div class="method-source-code" id="
|
263
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
264
|
+
<div class="method-source-code" id="M000009-source">
|
265
265
|
<pre>
|
266
266
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 110</span>
|
267
267
|
110: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">title</span>)
|
@@ -273,11 +273,11 @@ support deleting multiple pages at a time.)
|
|
273
273
|
</div>
|
274
274
|
</div>
|
275
275
|
|
276
|
-
<div id="method-
|
277
|
-
<a name="
|
276
|
+
<div id="method-M000015" class="method-detail">
|
277
|
+
<a name="M000015"></a>
|
278
278
|
|
279
279
|
<div class="method-heading">
|
280
|
-
<a href="#
|
280
|
+
<a href="#M000015" class="method-signature">
|
281
281
|
<span class="method-name">download</span><span class="method-args">(file_name, options={})</span>
|
282
282
|
</a>
|
283
283
|
</div>
|
@@ -285,14 +285,14 @@ support deleting multiple pages at a time.)
|
|
285
285
|
<div class="method-description">
|
286
286
|
<p>
|
287
287
|
Download <em>file_name</em>. Returns file contents. All options are passed
|
288
|
-
to <a href="Gateway.html#
|
288
|
+
to <a href="Gateway.html#M000014">image_info</a> however
|
289
289
|
options[‘iiprop’] is forced to url. You can still set other
|
290
290
|
options to control what file you want to <a
|
291
|
-
href="Gateway.html#
|
291
|
+
href="Gateway.html#M000015">download</a>.
|
292
292
|
</p>
|
293
293
|
<p><a class="source-toggle" href="#"
|
294
|
-
onclick="toggleCode('
|
295
|
-
<div class="method-source-code" id="
|
294
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
295
|
+
<div class="method-source-code" id="M000015-source">
|
296
296
|
<pre>
|
297
297
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 302</span>
|
298
298
|
302: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">download</span>(<span class="ruby-identifier">file_name</span>, <span class="ruby-identifier">options</span>={})
|
@@ -310,11 +310,11 @@ href="Gateway.html#M000014">download</a>.
|
|
310
310
|
</div>
|
311
311
|
</div>
|
312
312
|
|
313
|
-
<div id="method-
|
314
|
-
<a name="
|
313
|
+
<div id="method-M000017" class="method-detail">
|
314
|
+
<a name="M000017"></a>
|
315
315
|
|
316
316
|
<div class="method-heading">
|
317
|
-
<a href="#
|
317
|
+
<a href="#M000017" class="method-signature">
|
318
318
|
<span class="method-name">export</span><span class="method-args">(page_titles)</span>
|
319
319
|
</a>
|
320
320
|
</div>
|
@@ -332,8 +332,8 @@ Exports a page or set of pages
|
|
332
332
|
Returns <a href="../MediaWiki.html">MediaWiki</a> XML dump
|
333
333
|
</p>
|
334
334
|
<p><a class="source-toggle" href="#"
|
335
|
-
onclick="toggleCode('
|
336
|
-
<div class="method-source-code" id="
|
335
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
336
|
+
<div class="method-source-code" id="M000017-source">
|
337
337
|
<pre>
|
338
338
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 333</span>
|
339
339
|
333: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">export</span>(<span class="ruby-identifier">page_titles</span>)
|
@@ -345,27 +345,27 @@ Returns <a href="../MediaWiki.html">MediaWiki</a> XML dump
|
|
345
345
|
</div>
|
346
346
|
</div>
|
347
347
|
|
348
|
-
<div id="method-
|
349
|
-
<a name="
|
348
|
+
<div id="method-M000019" class="method-detail">
|
349
|
+
<a name="M000019"></a>
|
350
350
|
|
351
351
|
<div class="method-heading">
|
352
|
-
<a href="#
|
352
|
+
<a href="#M000019" class="method-signature">
|
353
353
|
<span class="method-name">extensions</span><span class="method-args">()</span>
|
354
354
|
</a>
|
355
355
|
</div>
|
356
356
|
|
357
357
|
<div class="method-description">
|
358
358
|
<p>
|
359
|
-
Get a <a href="Gateway.html#
|
360
|
-
registered) <a href="Gateway.html#
|
359
|
+
Get a <a href="Gateway.html#M000011">list</a> of all installed (and
|
360
|
+
registered) <a href="Gateway.html#M000019">extensions</a>
|
361
361
|
</p>
|
362
362
|
<p>
|
363
|
-
Returns array of <a href="Gateway.html#
|
363
|
+
Returns array of <a href="Gateway.html#M000019">extensions</a> (name =>
|
364
364
|
version)
|
365
365
|
</p>
|
366
366
|
<p><a class="source-toggle" href="#"
|
367
|
-
onclick="toggleCode('
|
368
|
-
<div class="method-source-code" id="
|
367
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
368
|
+
<div class="method-source-code" id="M000019-source">
|
369
369
|
<pre>
|
370
370
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 354</span>
|
371
371
|
354: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extensions</span>
|
@@ -382,11 +382,11 @@ version)
|
|
382
382
|
</div>
|
383
383
|
</div>
|
384
384
|
|
385
|
-
<div id="method-
|
386
|
-
<a name="
|
385
|
+
<div id="method-M000006" class="method-detail">
|
386
|
+
<a name="M000006"></a>
|
387
387
|
|
388
388
|
<div class="method-heading">
|
389
|
-
<a href="#
|
389
|
+
<a href="#M000006" class="method-signature">
|
390
390
|
<span class="method-name">get</span><span class="method-args">(page_title)</span>
|
391
391
|
</a>
|
392
392
|
</div>
|
@@ -405,8 +405,8 @@ href="../MediaWiki.html">MediaWiki</a> format
|
|
405
405
|
Returns nil if the page does not exist
|
406
406
|
</p>
|
407
407
|
<p><a class="source-toggle" href="#"
|
408
|
-
onclick="toggleCode('
|
409
|
-
<div class="method-source-code" id="
|
408
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
409
|
+
<div class="method-source-code" id="M000006-source">
|
410
410
|
<pre>
|
411
411
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 44</span>
|
412
412
|
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">page_title</span>)
|
@@ -415,7 +415,7 @@ Returns nil if the page does not exist
|
|
415
415
|
47: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">page</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">page</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"missing"</span>]
|
416
416
|
48: <span class="ruby-keyword kw">nil</span>
|
417
417
|
49: <span class="ruby-keyword kw">else</span>
|
418
|
-
50: <span class="ruby-identifier">page</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"revisions/rev"</span>].<span class="ruby-identifier">text</span>
|
418
|
+
50: <span class="ruby-identifier">page</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"revisions/rev"</span>].<span class="ruby-identifier">text</span> <span class="ruby-operator">||</span> <span class="ruby-value str">""</span>
|
419
419
|
51: <span class="ruby-keyword kw">end</span>
|
420
420
|
52: <span class="ruby-keyword kw">end</span>
|
421
421
|
</pre>
|
@@ -423,11 +423,11 @@ Returns nil if the page does not exist
|
|
423
423
|
</div>
|
424
424
|
</div>
|
425
425
|
|
426
|
-
<div id="method-
|
427
|
-
<a name="
|
426
|
+
<div id="method-M000014" class="method-detail">
|
427
|
+
<a name="M000014"></a>
|
428
428
|
|
429
429
|
<div class="method-heading">
|
430
|
-
<a href="#
|
430
|
+
<a href="#M000014" class="method-signature">
|
431
431
|
<span class="method-name">image_info</span><span class="method-args">(file_name_or_page_id, options={})</span>
|
432
432
|
</a>
|
433
433
|
</div>
|
@@ -479,8 +479,8 @@ Output:
|
|
479
479
|
"user" => "Valdas"
|
480
480
|
</pre>
|
481
481
|
<p><a class="source-toggle" href="#"
|
482
|
-
onclick="toggleCode('
|
483
|
-
<div class="method-source-code" id="
|
482
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
483
|
+
<div class="method-source-code" id="M000014-source">
|
484
484
|
<pre>
|
485
485
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 271</span>
|
486
486
|
271: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_info</span>(<span class="ruby-identifier">file_name_or_page_id</span>, <span class="ruby-identifier">options</span>={})
|
@@ -515,11 +515,11 @@ Output:
|
|
515
515
|
</div>
|
516
516
|
</div>
|
517
517
|
|
518
|
-
<div id="method-
|
519
|
-
<a name="
|
518
|
+
<div id="method-M000016" class="method-detail">
|
519
|
+
<a name="M000016"></a>
|
520
520
|
|
521
521
|
<div class="method-heading">
|
522
|
-
<a href="#
|
522
|
+
<a href="#M000016" class="method-signature">
|
523
523
|
<span class="method-name">import</span><span class="method-args">(xmlfile)</span>
|
524
524
|
</a>
|
525
525
|
</div>
|
@@ -535,13 +535,13 @@ Imports a <a href="../MediaWiki.html">MediaWiki</a> XML dump
|
|
535
535
|
</dl>
|
536
536
|
<p>
|
537
537
|
Returns XML array <api><<a
|
538
|
-
href="Gateway.html#
|
538
|
+
href="Gateway.html#M000016">import</a>><page/><page/>…
|
539
539
|
<page revisions="1"> (or more) means successfully imported
|
540
540
|
<page revisions="0"> means duplicate, not imported
|
541
541
|
</p>
|
542
542
|
<p><a class="source-toggle" href="#"
|
543
|
-
onclick="toggleCode('
|
544
|
-
<div class="method-source-code" id="
|
543
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
544
|
+
<div class="method-source-code" id="M000016-source">
|
545
545
|
<pre>
|
546
546
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 320</span>
|
547
547
|
320: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">import</span>(<span class="ruby-identifier">xmlfile</span>)
|
@@ -556,18 +556,18 @@ href="Gateway.html#M000015">import</a>><page/><page/>…
|
|
556
556
|
</div>
|
557
557
|
</div>
|
558
558
|
|
559
|
-
<div id="method-
|
560
|
-
<a name="
|
559
|
+
<div id="method-M000011" class="method-detail">
|
560
|
+
<a name="M000011"></a>
|
561
561
|
|
562
562
|
<div class="method-heading">
|
563
|
-
<a href="#
|
563
|
+
<a href="#M000011" class="method-signature">
|
564
564
|
<span class="method-name">list</span><span class="method-args">(key)</span>
|
565
565
|
</a>
|
566
566
|
</div>
|
567
567
|
|
568
568
|
<div class="method-description">
|
569
569
|
<p>
|
570
|
-
Get a <a href="Gateway.html#
|
570
|
+
Get a <a href="Gateway.html#M000011">list</a> of matching page titles
|
571
571
|
</p>
|
572
572
|
<dl>
|
573
573
|
<dt>key</dt><dd>Search key, matched as a prefix (^key.*). May contain or equal a namespace.
|
@@ -578,8 +578,8 @@ Get a <a href="Gateway.html#M000010">list</a> of matching page titles
|
|
578
578
|
Returns array of page titles (empty if no matches)
|
579
579
|
</p>
|
580
580
|
<p><a class="source-toggle" href="#"
|
581
|
-
onclick="toggleCode('
|
582
|
-
<div class="method-source-code" id="
|
581
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
582
|
+
<div class="method-source-code" id="M000011-source">
|
583
583
|
<pre>
|
584
584
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 136</span>
|
585
585
|
136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list</span>(<span class="ruby-identifier">key</span>)
|
@@ -606,11 +606,11 @@ Returns array of page titles (empty if no matches)
|
|
606
606
|
</div>
|
607
607
|
</div>
|
608
608
|
|
609
|
-
<div id="method-
|
610
|
-
<a name="
|
609
|
+
<div id="method-M000005" class="method-detail">
|
610
|
+
<a name="M000005"></a>
|
611
611
|
|
612
612
|
<div class="method-heading">
|
613
|
-
<a href="#
|
613
|
+
<a href="#M000005" class="method-signature">
|
614
614
|
<span class="method-name">login</span><span class="method-args">(username, password, domain = 'local')</span>
|
615
615
|
</a>
|
616
616
|
</div>
|
@@ -632,11 +632,11 @@ defaults to ‘local’ if not given
|
|
632
632
|
</dd>
|
633
633
|
</dl>
|
634
634
|
<p>
|
635
|
-
Throws error if <a href="Gateway.html#
|
635
|
+
Throws error if <a href="Gateway.html#M000005">login</a> fails
|
636
636
|
</p>
|
637
637
|
<p><a class="source-toggle" href="#"
|
638
|
-
onclick="toggleCode('
|
639
|
-
<div class="method-source-code" id="
|
638
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
639
|
+
<div class="method-source-code" id="M000005-source">
|
640
640
|
<pre>
|
641
641
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 32</span>
|
642
642
|
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">login</span>(<span class="ruby-identifier">username</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">domain</span> = <span class="ruby-value str">'local'</span>)
|
@@ -650,25 +650,25 @@ Throws error if <a href="Gateway.html#M000004">login</a> fails
|
|
650
650
|
</div>
|
651
651
|
</div>
|
652
652
|
|
653
|
-
<div id="method-
|
654
|
-
<a name="
|
653
|
+
<div id="method-M000018" class="method-detail">
|
654
|
+
<a name="M000018"></a>
|
655
655
|
|
656
656
|
<div class="method-heading">
|
657
|
-
<a href="#
|
657
|
+
<a href="#M000018" class="method-signature">
|
658
658
|
<span class="method-name">namespaces_by_prefix</span><span class="method-args">()</span>
|
659
659
|
</a>
|
660
660
|
</div>
|
661
661
|
|
662
662
|
<div class="method-description">
|
663
663
|
<p>
|
664
|
-
Get a <a href="Gateway.html#
|
664
|
+
Get a <a href="Gateway.html#M000011">list</a> of all known namespaces
|
665
665
|
</p>
|
666
666
|
<p>
|
667
667
|
Returns array of namespaces (name => id)
|
668
668
|
</p>
|
669
669
|
<p><a class="source-toggle" href="#"
|
670
|
-
onclick="toggleCode('
|
671
|
-
<div class="method-source-code" id="
|
670
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
671
|
+
<div class="method-source-code" id="M000018-source">
|
672
672
|
<pre>
|
673
673
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 341</span>
|
674
674
|
341: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">namespaces_by_prefix</span>
|
@@ -685,11 +685,11 @@ Returns array of namespaces (name => id)
|
|
685
685
|
</div>
|
686
686
|
</div>
|
687
687
|
|
688
|
-
<div id="method-
|
689
|
-
<a name="
|
688
|
+
<div id="method-M000007" class="method-detail">
|
689
|
+
<a name="M000007"></a>
|
690
690
|
|
691
691
|
<div class="method-heading">
|
692
|
-
<a href="#
|
692
|
+
<a href="#M000007" class="method-signature">
|
693
693
|
<span class="method-name">render</span><span class="method-args">(page_title, options = {})</span>
|
694
694
|
</a>
|
695
695
|
</div>
|
@@ -726,8 +726,8 @@ Options:
|
|
726
726
|
Returns nil if the page does not exist
|
727
727
|
</p>
|
728
728
|
<p><a class="source-toggle" href="#"
|
729
|
-
onclick="toggleCode('
|
730
|
-
<div class="method-source-code" id="
|
729
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
730
|
+
<div class="method-source-code" id="M000007-source">
|
731
731
|
<pre>
|
732
732
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 65</span>
|
733
733
|
65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">page_title</span>, <span class="ruby-identifier">options</span> = {})
|
@@ -744,7 +744,7 @@ Returns nil if the page does not exist
|
|
744
744
|
76: <span class="ruby-comment cmt"># OPTIMIZE: unifiy the keys in +options+ like symbolize_keys! but w/o</span>
|
745
745
|
77: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">"linkbase"</span>] <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:linkbase</span>]
|
746
746
|
78: <span class="ruby-identifier">linkbase</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value str">"linkbase"</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:linkbase</span>]
|
747
|
-
79: <span class="ruby-identifier">rendered</span> = <span class="ruby-identifier">rendered</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\shref="\/wiki\/(
|
747
|
+
79: <span class="ruby-identifier">rendered</span> = <span class="ruby-identifier">rendered</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\shref="\/wiki\/([\w\(\)_\-\.%\d:,]*)"/</span>, <span class="ruby-value str">' href="'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">linkbase</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/wiki/\1"'</span>)
|
748
748
|
80: <span class="ruby-keyword kw">end</span>
|
749
749
|
81: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">"noeditsections"</span>] <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:noeditsections</span>]
|
750
750
|
82: <span class="ruby-identifier">rendered</span> = <span class="ruby-identifier">rendered</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/<span class="editsection">\[.+\]<\/span>/</span>, <span class="ruby-value str">''</span>)
|
@@ -760,25 +760,25 @@ Returns nil if the page does not exist
|
|
760
760
|
</div>
|
761
761
|
</div>
|
762
762
|
|
763
|
-
<div id="method-
|
764
|
-
<a name="
|
763
|
+
<div id="method-M000012" class="method-detail">
|
764
|
+
<a name="M000012"></a>
|
765
765
|
|
766
766
|
<div class="method-heading">
|
767
|
-
<a href="#
|
767
|
+
<a href="#M000012" class="method-signature">
|
768
768
|
<span class="method-name">search</span><span class="method-args">(key, namespaces=nil, limit=10)</span>
|
769
769
|
</a>
|
770
770
|
</div>
|
771
771
|
|
772
772
|
<div class="method-description">
|
773
773
|
<p>
|
774
|
-
Get a <a href="Gateway.html#
|
774
|
+
Get a <a href="Gateway.html#M000011">list</a> of pages with matching
|
775
775
|
content in given namespaces
|
776
776
|
</p>
|
777
777
|
<dl>
|
778
778
|
<dt>key</dt><dd>Search key
|
779
779
|
|
780
780
|
</dd>
|
781
|
-
<dt>namespaces</dt><dd>Array of namespace names to <a href="Gateway.html#
|
781
|
+
<dt>namespaces</dt><dd>Array of namespace names to <a href="Gateway.html#M000012">search</a>
|
782
782
|
(defaults to NS_MAIN only)
|
783
783
|
|
784
784
|
</dd>
|
@@ -790,8 +790,8 @@ content in given namespaces
|
|
790
790
|
Returns array of page titles (empty if no matches)
|
791
791
|
</p>
|
792
792
|
<p><a class="source-toggle" href="#"
|
793
|
-
onclick="toggleCode('
|
794
|
-
<div class="method-source-code" id="
|
793
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
794
|
+
<div class="method-source-code" id="M000012-source">
|
795
795
|
<pre>
|
796
796
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 163</span>
|
797
797
|
163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">search</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">namespaces</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">limit</span>=<span class="ruby-value">10</span>)
|
@@ -812,11 +812,11 @@ Returns array of page titles (empty if no matches)
|
|
812
812
|
</div>
|
813
813
|
</div>
|
814
814
|
|
815
|
-
<div id="method-
|
816
|
-
<a name="
|
815
|
+
<div id="method-M000020" class="method-detail">
|
816
|
+
<a name="M000020"></a>
|
817
817
|
|
818
818
|
<div class="method-heading">
|
819
|
-
<a href="#
|
819
|
+
<a href="#M000020" class="method-signature">
|
820
820
|
<span class="method-name">semantic_query</span><span class="method-args">(query, params = [])</span>
|
821
821
|
</a>
|
822
822
|
</div>
|
@@ -838,8 +838,8 @@ Execute Semantic Mediawiki query
|
|
838
838
|
Returns result as an HTML string
|
839
839
|
</p>
|
840
840
|
<p><a class="source-toggle" href="#"
|
841
|
-
onclick="toggleCode('
|
842
|
-
<div class="method-source-code" id="
|
841
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
842
|
+
<div class="method-source-code" id="M000020-source">
|
843
843
|
<pre>
|
844
844
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 370</span>
|
845
845
|
370: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">semantic_query</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">params</span> = [])
|
@@ -853,11 +853,11 @@ Returns result as an HTML string
|
|
853
853
|
</div>
|
854
854
|
</div>
|
855
855
|
|
856
|
-
<div id="method-
|
857
|
-
<a name="
|
856
|
+
<div id="method-M000010" class="method-detail">
|
857
|
+
<a name="M000010"></a>
|
858
858
|
|
859
859
|
<div class="method-heading">
|
860
|
-
<a href="#
|
860
|
+
<a href="#M000010" class="method-signature">
|
861
861
|
<span class="method-name">undelete</span><span class="method-args">(title)</span>
|
862
862
|
</a>
|
863
863
|
</div>
|
@@ -867,7 +867,7 @@ Returns result as an HTML string
|
|
867
867
|
Undelete all revisions of one page.
|
868
868
|
</p>
|
869
869
|
<dl>
|
870
|
-
<dt>title</dt><dd>Title of page to <a href="Gateway.html#
|
870
|
+
<dt>title</dt><dd>Title of page to <a href="Gateway.html#M000010">undelete</a>
|
871
871
|
|
872
872
|
</dd>
|
873
873
|
</dl>
|
@@ -875,8 +875,8 @@ Undelete all revisions of one page.
|
|
875
875
|
Returns number of revisions undeleted.
|
876
876
|
</p>
|
877
877
|
<p><a class="source-toggle" href="#"
|
878
|
-
onclick="toggleCode('
|
879
|
-
<div class="method-source-code" id="
|
878
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
879
|
+
<div class="method-source-code" id="M000010-source">
|
880
880
|
<pre>
|
881
881
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 120</span>
|
882
882
|
120: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">undelete</span>(<span class="ruby-identifier">title</span>)
|
@@ -894,18 +894,18 @@ Returns number of revisions undeleted.
|
|
894
894
|
</div>
|
895
895
|
</div>
|
896
896
|
|
897
|
-
<div id="method-
|
898
|
-
<a name="
|
897
|
+
<div id="method-M000013" class="method-detail">
|
898
|
+
<a name="M000013"></a>
|
899
899
|
|
900
900
|
<div class="method-heading">
|
901
|
-
<a href="#
|
901
|
+
<a href="#M000013" class="method-signature">
|
902
902
|
<span class="method-name">upload</span><span class="method-args">(path, options={})</span>
|
903
903
|
</a>
|
904
904
|
</div>
|
905
905
|
|
906
906
|
<div class="method-description">
|
907
907
|
<p>
|
908
|
-
Upload a file, or <a href="Gateway.html#
|
908
|
+
Upload a file, or <a href="Gateway.html#M000006">get</a> the status of
|
909
909
|
pending uploads. Several methods are available:
|
910
910
|
</p>
|
911
911
|
<ul>
|
@@ -924,7 +924,7 @@ Requires Mediawiki 1.16+
|
|
924
924
|
Arguments:
|
925
925
|
</p>
|
926
926
|
<ul>
|
927
|
-
<li>[path] Path to file to <a href="Gateway.html#
|
927
|
+
<li>[path] Path to file to <a href="Gateway.html#M000013">upload</a>. Set to
|
928
928
|
nil if uploading from URL.
|
929
929
|
|
930
930
|
</li>
|
@@ -934,7 +934,7 @@ nil if uploading from URL.
|
|
934
934
|
</ul>
|
935
935
|
<p>
|
936
936
|
Note that queries using session keys must be done in the same <a
|
937
|
-
href="Gateway.html#
|
937
|
+
href="Gateway.html#M000005">login</a> session as the query that originally
|
938
938
|
returned the key (i.e. do not log out and then log back in).
|
939
939
|
</p>
|
940
940
|
<p>
|
@@ -946,12 +946,12 @@ given), options[:target] is alias for this.
|
|
946
946
|
|
947
947
|
</li>
|
948
948
|
<li>‘comment’ - Upload comment. Also used as the initial page text
|
949
|
-
for <a href="Gateway.html#
|
949
|
+
for <a href="Gateway.html#M000004">new</a> files if "text" is not
|
950
950
|
specified.
|
951
951
|
|
952
952
|
</li>
|
953
953
|
<li>‘text’ - Initial page text for <a
|
954
|
-
href="Gateway.html#
|
954
|
+
href="Gateway.html#M000004">new</a> files
|
955
955
|
|
956
956
|
</li>
|
957
957
|
<li>‘watch’ - Watch the page
|
@@ -988,8 +988,8 @@ Examples:
|
|
988
988
|
mw.upload(nil, 'filename' => "RemoteFile2.jpg", 'url' => 'http://remote.com/server/file.jpg')
|
989
989
|
</pre>
|
990
990
|
<p><a class="source-toggle" href="#"
|
991
|
-
onclick="toggleCode('
|
992
|
-
<div class="method-source-code" id="
|
991
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
992
|
+
<div class="method-source-code" id="M000013-source">
|
993
993
|
<pre>
|
994
994
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 211</span>
|
995
995
|
211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">upload</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span>={})
|
@@ -1032,59 +1032,63 @@ Examples:
|
|
1032
1032
|
|
1033
1033
|
<h3 class="section-bar">Private Instance methods</h3>
|
1034
1034
|
|
1035
|
-
<div id="method-
|
1036
|
-
<a name="
|
1035
|
+
<div id="method-M000024" class="method-detail">
|
1036
|
+
<a name="M000024"></a>
|
1037
1037
|
|
1038
1038
|
<div class="method-heading">
|
1039
|
-
<a href="#
|
1039
|
+
<a href="#M000024" class="method-signature">
|
1040
1040
|
<span class="method-name">get_response</span><span class="method-args">(res)</span>
|
1041
1041
|
</a>
|
1042
1042
|
</div>
|
1043
1043
|
|
1044
1044
|
<div class="method-description">
|
1045
1045
|
<p>
|
1046
|
-
Get API XML response If there are errors,
|
1047
|
-
|
1046
|
+
Get API XML response If there are errors, raise exception Otherwise return
|
1047
|
+
XML root
|
1048
1048
|
</p>
|
1049
1049
|
<p><a class="source-toggle" href="#"
|
1050
|
-
onclick="toggleCode('
|
1051
|
-
<div class="method-source-code" id="
|
1050
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
1051
|
+
<div class="method-source-code" id="M000024-source">
|
1052
1052
|
<pre>
|
1053
1053
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 429</span>
|
1054
1054
|
429: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_response</span>(<span class="ruby-identifier">res</span>)
|
1055
|
-
430: <span class="ruby-
|
1056
|
-
431:
|
1057
|
-
432: <span class="ruby-
|
1058
|
-
433:
|
1059
|
-
434:
|
1060
|
-
435:
|
1061
|
-
436:
|
1062
|
-
437: <span class="ruby-keyword kw">
|
1063
|
-
438:
|
1064
|
-
439:
|
1055
|
+
430: <span class="ruby-keyword kw">begin</span>
|
1056
|
+
431: <span class="ruby-identifier">doc</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>).<span class="ruby-identifier">root</span>
|
1057
|
+
432: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseException</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
1058
|
+
433: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Response is not XML. Are you sure you are pointing to api.php?"</span>
|
1059
|
+
434: <span class="ruby-keyword kw">end</span>
|
1060
|
+
435: <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">"RES: #{doc}"</span>)
|
1061
|
+
436: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Response does not contain Mediawiki API XML: #{res}"</span> <span class="ruby-keyword kw">unless</span> [ <span class="ruby-value str">"api"</span>, <span class="ruby-value str">"mediawiki"</span> ].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">name</span>
|
1062
|
+
437: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"error"</span>]
|
1063
|
+
438: <span class="ruby-identifier">code</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"error"</span>].<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"code"</span>]
|
1064
|
+
439: <span class="ruby-identifier">info</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"error"</span>].<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"info"</span>]
|
1065
|
+
440: <span class="ruby-identifier">raise</span> <span class="ruby-node">"API error: code '#{code}', info '#{info}'"</span>
|
1066
|
+
441: <span class="ruby-keyword kw">end</span>
|
1067
|
+
442: <span class="ruby-identifier">doc</span>
|
1068
|
+
443: <span class="ruby-keyword kw">end</span>
|
1065
1069
|
</pre>
|
1066
1070
|
</div>
|
1067
1071
|
</div>
|
1068
1072
|
</div>
|
1069
1073
|
|
1070
|
-
<div id="method-
|
1071
|
-
<a name="
|
1074
|
+
<div id="method-M000021" class="method-detail">
|
1075
|
+
<a name="M000021"></a>
|
1072
1076
|
|
1073
1077
|
<div class="method-heading">
|
1074
|
-
<a href="#
|
1078
|
+
<a href="#M000021" class="method-signature">
|
1075
1079
|
<span class="method-name">get_token</span><span class="method-args">(type, page_titles)</span>
|
1076
1080
|
</a>
|
1077
1081
|
</div>
|
1078
1082
|
|
1079
1083
|
<div class="method-description">
|
1080
1084
|
<p>
|
1081
|
-
Fetch token (type ‘<a href="Gateway.html#
|
1085
|
+
Fetch token (type ‘<a href="Gateway.html#M000009">delete</a>’,
|
1082
1086
|
‘edit’, ‘<a
|
1083
|
-
href="Gateway.html#
|
1087
|
+
href="Gateway.html#M000016">import</a>’)
|
1084
1088
|
</p>
|
1085
1089
|
<p><a class="source-toggle" href="#"
|
1086
|
-
onclick="toggleCode('
|
1087
|
-
<div class="method-source-code" id="
|
1090
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
1091
|
+
<div class="method-source-code" id="M000021-source">
|
1088
1092
|
<pre>
|
1089
1093
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 380</span>
|
1090
1094
|
380: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_token</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">page_titles</span>)
|
@@ -1099,19 +1103,19 @@ href="Gateway.html#M000015">import</a>’)
|
|
1099
1103
|
</div>
|
1100
1104
|
</div>
|
1101
1105
|
|
1102
|
-
<div id="method-
|
1103
|
-
<a name="
|
1106
|
+
<div id="method-M000022" class="method-detail">
|
1107
|
+
<a name="M000022"></a>
|
1104
1108
|
|
1105
1109
|
<div class="method-heading">
|
1106
|
-
<a href="#
|
1110
|
+
<a href="#M000022" class="method-signature">
|
1107
1111
|
<span class="method-name">get_undelete_token</span><span class="method-args">(page_titles)</span>
|
1108
1112
|
</a>
|
1109
1113
|
</div>
|
1110
1114
|
|
1111
1115
|
<div class="method-description">
|
1112
1116
|
<p><a class="source-toggle" href="#"
|
1113
|
-
onclick="toggleCode('
|
1114
|
-
<div class="method-source-code" id="
|
1117
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
1118
|
+
<div class="method-source-code" id="M000022-source">
|
1115
1119
|
<pre>
|
1116
1120
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 388</span>
|
1117
1121
|
388: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_undelete_token</span>(<span class="ruby-identifier">page_titles</span>)
|
@@ -1130,11 +1134,11 @@ href="Gateway.html#M000015">import</a>’)
|
|
1130
1134
|
</div>
|
1131
1135
|
</div>
|
1132
1136
|
|
1133
|
-
<div id="method-
|
1134
|
-
<a name="
|
1137
|
+
<div id="method-M000023" class="method-detail">
|
1138
|
+
<a name="M000023"></a>
|
1135
1139
|
|
1136
1140
|
<div class="method-heading">
|
1137
|
-
<a href="#
|
1141
|
+
<a href="#M000023" class="method-signature">
|
1138
1142
|
<span class="method-name">make_api_request</span><span class="method-args">(form_data)</span>
|
1139
1143
|
</a>
|
1140
1144
|
</div>
|
@@ -1152,8 +1156,8 @@ Make generic request to API
|
|
1152
1156
|
Returns XML document
|
1153
1157
|
</p>
|
1154
1158
|
<p><a class="source-toggle" href="#"
|
1155
|
-
onclick="toggleCode('
|
1156
|
-
<div class="method-source-code" id="
|
1159
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
1160
|
+
<div class="method-source-code" id="M000023-source">
|
1157
1161
|
<pre>
|
1158
1162
|
<span class="ruby-comment cmt"># File lib/media_wiki/gateway.rb, line 405</span>
|
1159
1163
|
405: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_api_request</span>(<span class="ruby-identifier">form_data</span>)
|