Forked from Wardormeur/gist:5755649f587b2aa7ed0c
Last active
February 19, 2016 17:15
-
-
Save TheZoker/ce30f1ff289d5a4c9823 to your computer and use it in GitHub Desktop.
Revisions
-
TheZoker revised this gist
Feb 19, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ .map(function(index, item){ var id = $(item).find('td:first-child a').text(); var added = $(item).find('td:nth-child(4)').text(); var location = $(item).find('td:nth-child(2)').text(); objects.push({'id': id, 'added': added, 'location': location}); }); fs.writeFile('events.json', JSON.stringify(objects), function (err) { -
TheZoker revised this gist
Feb 19, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,8 +21,8 @@ $($('table.zebra.sortable')[1]).find('tr') .map(function(index, item){ var id = $(item).find('td:first-child a').text(); var added = $(item).find('td:nth-child(4)').text(); var location = $(item).find('td:nth-child(1)').text(); objects.push({'id': id, 'added': added, 'location': location}); }); fs.writeFile('events.json', JSON.stringify(objects), function (err) { @@ -53,7 +53,7 @@ }); events.forEach(function(event){ if(!event.found){ grunt.log.warn('Event '+ event.id + ' is not defined, added in version'+ event.added + 'and normally found in' + event.location); } }); }); -
TheZoker revised this gist
Feb 19, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ var objects = []; // grunt.log.writeln(srcContents); $($('table.zebra.sortable')[1]).find('tr') .map(function(index, item){ var id = $(item).find('td:first-child a').text(); var added = $(item).find('td:nth-child(3)').text(); @@ -53,7 +53,7 @@ }); events.forEach(function(event){ if(!event.found){ grunt.log.warn('Event '+ event.id + ' is not defined, added in version '+ event.added + 'and normally found in' + event.location); } }); }); -
Wardormeur revised this gist
Nov 21, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,7 @@ if(srcContents.indexOf(event.id) != -1) { event.found = true; grunt.verbose.writeln('event found ' + event.id +' in file '+ f); } }); -
Wardormeur created this gist
Nov 21, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ grunt.registerTask('getEvents', function(){ var http = require('https'); var cheerio = require('cheerio'); var fs = require('fs'); var url = 'https://wiki.phpbb.com/Event_List'; var done = this.async(); var dom = http.get(url, function(response){ var srcContents = ''; //another chunk of data has been recieved, so append it to `str` response.on('data', function (chunk) { srcContents += chunk; }); //the whole response has been recieved, so we just print it out here response.on('end', function () { var $ = cheerio.load(srcContents,{lowerCaseAttributeNames:false}); var objects = []; // grunt.log.writeln(srcContents); $($('table.zebra.sortable')[2]).find('tr') .map(function(index, item){ var id = $(item).find('td:first-child a').text(); var added = $(item).find('td:nth-child(3)').text(); var location = $(item).find('td:nth-child(2)').text(); objects.push({'id': id, 'added': added, 'location': location}); }); fs.writeFile('events.json', JSON.stringify(objects), function (err) { if (err) return console.log(err); console.log('Events successfully saved and updated with ' +objects.length + 'items'); done(); }); }); }).end(); }); grunt.registerTask('checkEvents', function(){ var path = require('path'); var fs = require('fs'); var src = ['template/*.html']; var events = grunt.file.readJSON('./events.json'); grunt.file.expand(src).forEach(function(f){ var srcContents = grunt.file.read(f); events.map(function(event){ if(srcContents.indexOf(event.id) != -1) { event.found = true; grunt.log.writeln('event found ' + event.id +' in file '+ f); } }); }); events.forEach(function(event){ if(!event.found){ grunt.log.warn('Event '+ event.id + 'is not defined, added in version '+ event.added + 'and normally found in' + event.location); } }); });