Skip to content

Instantly share code, notes, and snippets.

@TheZoker
Forked from Wardormeur/gist:5755649f587b2aa7ed0c
Last active February 19, 2016 17:15
Show Gist options
  • Select an option

  • Save TheZoker/ce30f1ff289d5a4c9823 to your computer and use it in GitHub Desktop.

Select an option

Save TheZoker/ce30f1ff289d5a4c9823 to your computer and use it in GitHub Desktop.

Revisions

  1. TheZoker revised this gist Feb 19, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original 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(1)').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) {
  2. TheZoker revised this gist Feb 19, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.txt
    Original 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(3)').text();
    var location = $(item).find('td:nth-child(2)').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);
    grunt.log.warn('Event '+ event.id + ' is not defined, added in version'+ event.added + 'and normally found in' + event.location);
    }
    });
    });
  3. TheZoker revised this gist Feb 19, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@
    var objects = [];
    // grunt.log.writeln(srcContents);

    $($('table.zebra.sortable')[2]).find('tr')
    $($('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);
    grunt.log.warn('Event '+ event.id + ' is not defined, added in version '+ event.added + 'and normally found in' + event.location);
    }
    });
    });
  4. @Wardormeur Wardormeur revised this gist Nov 21, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@
    if(srcContents.indexOf(event.id) != -1)
    {
    event.found = true;
    grunt.log.writeln('event found ' + event.id +' in file '+ f);
    grunt.verbose.writeln('event found ' + event.id +' in file '+ f);
    }
    });

  5. @Wardormeur Wardormeur created this gist Nov 21, 2015.
    59 changes: 59 additions & 0 deletions gistfile1.txt
    Original 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);
    }
    });
    });