User:Bawolff/sandbox/googleSitemap.js

importScript('User:Bawolff/mwapilib2.js'); //http://en.wikinews.org/w/api.php?action=query&prop=categories&generator=categorymembers&clprop=timestamp&gcmtitle=Category:Published&gcmdir=desc&gcmsort=timestamp&gcmnamespace=0&format=xml&gcmlimit=40&cllimit=max&cldir=asc genSitemap = {}; genSitemap.do = function (titleListHTML, catListXML) { if (!api) {throw new Error("could not load api lib.");} api.renderPage var sm; //sitemap sm = ''; sm += '';

/*        http://example.com/article123.html   2006-08-14T03:30:00Z  Business, Mergers, Acquisitions  }

genSitemap.init1 = function { //entry point if (!api) {throw new Error("could not load api lib.");} api.renderPage('User:Bawolff/simpleLatestNews').lift(genSitemap.init2).exec;

} genSitemap.init2 = function (titleListHTML) { var findHref = /h]*?href="([^"]*)"[^>]*>/g; var findName = /]*?title="([^"]*)"[^>]*>/g; var titlesLink = [], titlesName = [], link, name; for (var i = 0; (link = findHref.exec(titleListHTML)) && name = findName.exec(titleListHTML); i++) { titlesLink[i] = link; titlesName[i] = name; } if (i > 0) { genSitemap.getCatLinks(titlesLink, titlesName); }  else { throw new Error('problem geting latest pub'); } }

genSitemap.getCatLinks = function (titlesLink, titlesName) { api.makeRequest({action: 'query', prop: 'categories', clprop: 'timestamp', cllimt: 'max', 'titles' titlesName}, genSitemap.combineCats).exec; //genSitemap.combineCats = function }