Skip to content

Commit bd70222

Browse files
committed
Update for breaking MediaWiki API changes
- switch continuation behavior to the new-style MediaWiki API - clean up query string building in the process - pull in core-js for es6 compatibility Change-Id: I58fb25a7ac64b3c065c11ad59fca5654513b8c39
1 parent c8bece9 commit bd70222

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

lib/htmldump.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"use strict";
2+
// Upgrade to es6
3+
require('core-js/shim');
24

35
var P = require('bluebird');
46

@@ -29,13 +31,22 @@ function getArticles (options, res) {
2931
}
3032
var next = res.next || '';
3133

32-
var url = options.apiURL + '?action=query&generator=allpages'
33-
+ '&gaplimit=500&prop=revisions&gapnamespace='
34-
+ options.ns + '&format=json&rawcontinue=1&gapcontinue=' + encodeURIComponent( next );
35-
//console.log(url);
36-
34+
var query = {
35+
action: 'query',
36+
generator: 'allpages',
37+
gaplimit: '500',
38+
prop: 'revisions',
39+
gapnamespace: options.ns,
40+
format: 'json',
41+
'continue': '',
42+
}
43+
// merge in the paging parameters
44+
if (next) {
45+
Object.assign(query, next);
46+
}
3747
return preq.get({
38-
uri: url,
48+
uri: options.apiURL,
49+
query: query,
3950
timeout: 60* 1000,
4051
retries: 5
4152
})
@@ -50,8 +61,7 @@ function getArticles (options, res) {
5061
articles.push([title, article.revisions[0].revid]);
5162
}
5263
});
53-
var next2 = res2['query-continue']
54-
&& res2['query-continue'].allpages.gapcontinue || 'finished';
64+
var next2 = res2['continue'] || 'finished';
5565
// XXX
5666
//next = 'finished';
5767
return {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "htmldump",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Parsoid HTML dump utility",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)