commit 273d3c2729341a62de9496174d7ab1d3e4ac33a5 Author: Tim Schumacher Date: Tue Jan 15 22:32:31 2013 +0100 Init diff --git a/config.js b/config.js new file mode 100644 index 0000000..ad2cf92 --- /dev/null +++ b/config.js @@ -0,0 +1,6 @@ +exports.url = { + hostname: 'www.krautspace.de', + port: 443, + path: '/user:0xaffe?do=edit&rev=0', + method: 'GET' +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ceee6ee --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ "name": "termintool" +, "version": "0.0.1" +, "engines": ["node >= 0.8.0"] +, "main": "termine.js" +, "dependencies": + { "ejs": "*" + , "ejs-ext": "latest" + , "jsdom": "latest" + , "email-templates": "latest" + , "nodemailer": "latest" + } +} diff --git a/termine.js b/termine.js new file mode 100644 index 0000000..8f0f945 --- /dev/null +++ b/termine.js @@ -0,0 +1,48 @@ +var config = require('./config'); +var http = require('https'); +var jsdom = require('jsdom'); + + +var data = ''; + +function parseData() { + jsdom.env( + data, + ["http://code.jquery.com/jquery.js"], + function (errors, window) { + var wiki_text = window.$("#wiki__text").val(); + var re = /\s\* (\d{4})\-(\d{2})\-(\d{2}) (\d{2})\:(\d{2}) - (\d{2})\:(\d{2}) (.*)/g; + var match = null; + var events = []; + while (match = re.exec(wiki_text)) { + var event = { + startdate : new Date(match[1], match[2], match[3], match[4], match[5]) + ,enddate : new Date(match[1], match[2], match[3], match[6], match[7]) + ,text : match[8] + }; + events.push(event); + } + + //var matches = wiki_text.match(); + //console.log(matches); + } + ); +} + +function processResponse(res) { + if (res.statusCode == 200) { + res.on('data', function(d) { + data = data + d; + }); + + res.on('end',parseData); + } +} + +var req = http.request(config.url,processResponse); + +req.end(); + +req.on('error', function(e) { + console.error(e); +});