Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #88 from ValentinBrclz/gettransclusion
Adding the getPagesTranscludedBy() function
  • Loading branch information
macbre committed Jan 14, 2016
2 parents 0e9280a + 34d40c0 commit 689bcf1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -166,6 +166,10 @@ Gets the list of pages in a given namespace - [read more](http://www.mediawiki.o

Gets the list of pages by a given prefix - [read more](https://www.mediawiki.org/wiki/API:Allpages)

### bot.getPagesTranscluding(page, callback)

Gets the list of pages that transclude the given pages - [read more](https://www.mediawiki.org/wiki/API:Transcludedin)

### bot.getArticle(title, callback)

Gets article content and its meta data - [read more](http://www.mediawiki.org/wiki/API:Properties#revisions_.2F_rv)
Expand Down
18 changes: 17 additions & 1 deletion lib/bot.js
Expand Up @@ -10,7 +10,7 @@ module.exports = (function() {
fs = require('fs'),
querystring = require('querystring');

// the upper limit for bots (will be reduced by MW for users with a bot right)
// the upper limit for bots (will be reduced by MW for users without a bot right)
var API_LIMIT = 5000;

// get the object being the first key/value entry of a given object
Expand Down Expand Up @@ -300,6 +300,22 @@ module.exports = (function() {
});
},

getPagesTranscluding: function (template, callback) {
this.log("Getting pages from " + template + "...");

this.getAll(
{
action: 'query',
prop: 'transcludedin',
titles: template
},
function (data) {
return getFirstItem(getFirstItem(data)).transcludedin;
},
callback
);
},

getArticle: function(title, callback) {
var params = {
action: 'query',
Expand Down

0 comments on commit 689bcf1

Please sign in to comment.